in src/aws_encryption_sdk/internal/formatting/deserialize.py [0:0]
def _verified_frame_length(frame_length, content_type):
# type: (int, ContentType) -> int
"""Verify a frame length value for a message content type.
:param int frame_length: Frame length to verify
:param ContentType content_type: Message content type to verify against
:return: frame length
:rtype: int
:raises SerializationError: if frame length is too large
:raises SerializationError: if frame length is not zero for unframed content type
"""
if content_type == ContentType.FRAMED_DATA and frame_length > MAX_FRAME_SIZE:
raise SerializationError(
"Specified frame length larger than allowed maximum: {found} > {max}".format(
found=frame_length, max=MAX_FRAME_SIZE
)
)
if content_type == ContentType.NO_FRAMING and frame_length != 0:
raise SerializationError("Non-zero frame length found for non-framed message")
return frame_length