in source/framefmt.c [249:271]
bool aws_cryptosdk_frame_serialized(
const struct aws_cryptosdk_frame *frame,
const struct aws_cryptosdk_alg_properties *alg_props,
size_t plaintext_size) {
if (frame == NULL || alg_props == NULL) {
return false;
}
// Check that both iv, authtag buffers contain the correct amount of bytes
bool iv_size_valid = (frame->iv.capacity == alg_props->iv_len);
bool tag_size_valid = (frame->authtag.capacity == alg_props->tag_len);
// Check that both iv, authtag buffers are empty and ready for writting
bool iv_empty = (frame->iv.len == 0);
bool tag_empty = (frame->authtag.len == 0);
// Check that the ciphertext buffer has the correct size
bool ciphertext_size_valid = ((frame->type == FRAME_TYPE_SINGLE || frame->type == FRAME_TYPE_FRAME) &&
frame->ciphertext.capacity == plaintext_size) ||
(frame->type == FRAME_TYPE_FINAL && frame->ciphertext.capacity <= plaintext_size);
return (ciphertext_size_valid && iv_empty && iv_size_valid && tag_empty && tag_size_valid);
}