Interface KnownLengthOutputEncryptor
- All Superinterfaces:
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
Modifier and TypeMethodDescriptionlonggetOutputLength(long inputLength) Return the exact number of ciphertext octets that encryptinginputLengthplaintext octets will produce, including any appended AEAD tag where the CMS structure carries the tag inside the encrypted content.Methods inherited from interface OutputEncryptor
getAlgorithmIdentifier, getKey, getOutputStream
-
Method Details
-
getOutputLength
long getOutputLength(long inputLength) Return the exact number of ciphertext octets that encryptinginputLengthplaintext 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
-