public class BcCMSContentEncryptorBuilder
extends java.lang.Object
EnvelopedData,
AuthEnvelopedData and EncryptedData structures — i.e. it
encrypts the actual transmitted (or stored) content.
The no-arg build() call generates a fresh content-encryption key
internally, which is the right behaviour for EnvelopedData where the
CEK is freshly drawn per message and wrapped per recipient. Callers that
already have a key — e.g. building an EncryptedData blob over
a long-lived locally-stored key (no recipients, no intermediate key wrap)
— should use build(byte[]) or build(KeyParameter)
instead.
| Constructor and Description |
|---|
BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID) |
BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID,
int keySize) |
| Modifier and Type | Method and Description |
|---|---|
OutputEncryptor |
build()
Build the OutputEncryptor with an internally generated key.
|
OutputEncryptor |
build(byte[] rawEncKey)
Build the OutputEncryptor using a pre-generated key.
|
OutputEncryptor |
build(org.bouncycastle.crypto.params.KeyParameter encKey)
Build the OutputEncryptor using a pre-generated key in lightweight
KeyParameter form. |
BcCMSContentEncryptorBuilder |
setSecureRandom(java.security.SecureRandom random) |
public BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID)
public BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID,
int keySize)
public BcCMSContentEncryptorBuilder setSecureRandom(java.security.SecureRandom random)
public OutputEncryptor build() throws CMSException
CMSExceptionpublic OutputEncryptor build(byte[] rawEncKey) throws CMSException
rawEncKey - a raw byte encoding of the key to be used for encryption.CMSExceptionpublic OutputEncryptor build(org.bouncycastle.crypto.params.KeyParameter encKey) throws CMSException
KeyParameter form. The lightweight peer of
JceCMSContentEncryptorBuilder.build(SecretKey); useful when the
caller already holds a KeyParameter (e.g. derived via
HKDFBytesGenerator or returned by another BC lightweight key
agreement) and would otherwise round-trip the key through
byte[] for no reason.encKey - the pre-generated key to use for content encryption.CMSException