in src/main/java/com/amazonaws/encryptionsdk/model/CiphertextHeaders.java [123:161]
public CiphertextHeaders(
final CiphertextType type,
final CryptoAlgorithm cryptoAlgo,
final byte[] encryptionContext,
final List<KeyBlob> keyBlobs,
final ContentType contentType,
final int frameSize) {
version_ = cryptoAlgo.getMessageFormatVersion();
typeVal_ = type.getValue();
cryptoAlgoVal_ = cryptoAlgo.getValue();
encryptionContext_ = encryptionContext.clone();
if (encryptionContext_.length > Constants.UNSIGNED_SHORT_MAX_VAL) {
throw new AwsCryptoException(
"Size of encryption context exceeds the allowed maximum "
+ Constants.UNSIGNED_SHORT_MAX_VAL);
}
encryptionContextLen_ = encryptionContext.length;
// we only support the encoding of 1 data key in the cipher blob.
cipherKeyCount_ = keyBlobs.size();
cipherKeyBlobs_ = new ArrayList<>(keyBlobs);
contentTypeVal_ = contentType.getValue();
reservedField_ = 0;
nonceLen_ = cryptoAlgo.getNonceLen();
// generate random bytes and assign them as the unique identifier of the
// message wrapped by this header.
messageId_ = new byte[cryptoAlgo.getMessageIdLength()];
RND.nextBytes(messageId_);
frameLength_ = frameSize;
// Completed by construction
isComplete_ = true;
}