Bouncy Castle Cryptography Library 1.85

org.bouncycastle.operator
Interface KnownLengthOutputEncryptor

All Superinterfaces:
OutputEncryptor

public interface KnownLengthOutputEncryptor
extends OutputEncryptor

Extension of OutputEncryptor for encryptors that can predict the exact ciphertext length produced for a given plaintext length. This enables definite-length (DL/DER) streaming of CMS structures: the encrypted-content OCTET STRING's length has to be written before any ciphertext flows, so the producer needs the count up front.

For encryptors that do not implement this interface the CMS stream generators fall back to deriving the count from the encryptor's algorithm identifier where the algorithm is recognised; implement this interface to support definite-length output with algorithms outside that set.


Method Summary
 long getOutputLength(long inputLength)
          Return the exact number of ciphertext octets that encrypting plaintext octets will produce, including any appended AEAD tag where the CMS structure carries the tag inside the encrypted content.
 
Methods inherited from interface org.bouncycastle.operator.OutputEncryptor
getAlgorithmIdentifier, getKey, getOutputStream
 

Method Detail

getOutputLength

public long getOutputLength(long inputLength)
Return the exact number of ciphertext octets that encrypting plaintext octets will produce, including any appended AEAD tag where the CMS structure carries the tag inside the encrypted content.

Parameters:
inputLength - number of plaintext octets to be encrypted
Returns:
the exact ciphertext octet count, or -1 if it cannot be determined

Bouncy Castle Cryptography Library 1.85