Class BcCMSContentEncryptorBuilder
java.lang.Object
org.bouncycastle.cms.bc.BcCMSContentEncryptorBuilder
Lightweight builder for the content encryptor used in CMS
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 Summary
ConstructorsConstructorDescriptionBcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID) BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID, int keySize) -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the OutputEncryptor with an internally generated key.build(byte[] rawEncKey) Build the OutputEncryptor using a pre-generated key.build(org.bouncycastle.crypto.params.KeyParameter encKey) Build the OutputEncryptor using a pre-generated key in lightweightKeyParameterform.setSecureRandom(SecureRandom random)
-
Constructor Details
-
BcCMSContentEncryptorBuilder
public BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID) -
BcCMSContentEncryptorBuilder
public BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID, int keySize)
-
-
Method Details
-
setSecureRandom
-
build
Build the OutputEncryptor with an internally generated key.- Returns:
- an OutputEncryptor configured to use an internal key.
- Throws:
CMSException
-
build
Build the OutputEncryptor using a pre-generated key.- Parameters:
rawEncKey- a raw byte encoding of the key to be used for encryption.- Returns:
- an OutputEncryptor configured to use rawEncKey.
- Throws:
CMSException
-
build
public OutputEncryptor build(org.bouncycastle.crypto.params.KeyParameter encKey) throws CMSException Build the OutputEncryptor using a pre-generated key in lightweightKeyParameterform. The lightweight peer ofJceCMSContentEncryptorBuilder.build(SecretKey); useful when the caller already holds aKeyParameter(e.g. derived viaHKDFBytesGeneratoror returned by another BC lightweight key agreement) and would otherwise round-trip the key throughbyte[]for no reason.- Parameters:
encKey- the pre-generated key to use for content encryption.- Returns:
- an OutputEncryptor configured to use encKey.
- Throws:
CMSException
-