Bouncy Castle Cryptography Library 1.85

org.bouncycastle.cms.bc
Class BcCMSContentEncryptorBuilder

java.lang.Object
  extended byorg.bouncycastle.cms.bc.BcCMSContentEncryptorBuilder

public class BcCMSContentEncryptorBuilder
extends java.lang.Object

Lightweight builder for the content encryptor used in CMS , and 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 where the CEK is freshly drawn per message and wrapped per recipient. Callers that already have a key — e.g. building an blob over a long-lived locally-stored key (no recipients, no intermediate key wrap) — should use build(byte[]) or build(KeyParameter) instead.


Constructor Summary
BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID)
           
BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID, int keySize)
           
 
Method Summary
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BcCMSContentEncryptorBuilder

public BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID)

BcCMSContentEncryptorBuilder

public BcCMSContentEncryptorBuilder(org.bouncycastle.asn1.ASN1ObjectIdentifier encryptionOID,
                                    int keySize)
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 lightweight KeyParameter form. The lightweight peer of ; useful when the caller already holds a (e.g. derived via or returned by another BC lightweight key agreement) and would otherwise round-trip the key through for no reason.

Parameters:
encKey - the pre-generated key to use for content encryption.
Returns:
an OutputEncryptor configured to use encKey.
Throws:
CMSException

Bouncy Castle Cryptography Library 1.85