Package org.bouncycastle.cms.bc
Class BcCMSContentEncryptorBuilder
- java.lang.Object
-
- org.bouncycastle.cms.bc.BcCMSContentEncryptorBuilder
-
public class BcCMSContentEncryptorBuilder extends java.lang.ObjectLightweight builder for the content encryptor used in CMSEnvelopedData,AuthEnvelopedDataandEncryptedDatastructures — 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 forEnvelopedDatawhere the CEK is freshly drawn per message and wrapped per recipient. Callers that already have a key — e.g. building anEncryptedDatablob over a long-lived locally-stored key (no recipients, no intermediate key wrap) — should usebuild(byte[])orbuild(KeyParameter)instead.
-
-
Constructor Summary
Constructors Constructor Description BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID)BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID, int keySize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OutputEncryptorbuild()Build the OutputEncryptor with an internally generated key.OutputEncryptorbuild(byte[] rawEncKey)Build the OutputEncryptor using a pre-generated key.OutputEncryptorbuild(org.bouncycastle.crypto.params.KeyParameter encKey)Build the OutputEncryptor using a pre-generated key in lightweightKeyParameterform.BcCMSContentEncryptorBuildersetSecureRandom(java.security.SecureRandom random)
-
-
-
Method Detail
-
setSecureRandom
public BcCMSContentEncryptorBuilder setSecureRandom(java.security.SecureRandom random)
-
build
public OutputEncryptor build() throws CMSException
Build the OutputEncryptor with an internally generated key.- Returns:
- an OutputEncryptor configured to use an internal key.
- Throws:
CMSException
-
build
public OutputEncryptor build(byte[] rawEncKey) throws CMSException
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
-
-