ķ 9(Zc@sYdZddlmZd„Zd„Zd„Zd„Zd„Zd„Zd „Z d S( s,Formatting functions for aws_encryption_sdk.i(tserialize_headercCs6tt|ƒƒ}||jj7}||jj7}|S(sĪCalculates the ciphertext message header length, given a complete header. :param header: Complete message header object :type header: aws_encryption_sdk.structures.MessageHeader :rtype: int (tlenRt algorithmtiv_lentauth_len(theadert header_length((s[/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/internal/formatting/__init__.pyRs cCs4|jj}|d7}||7}||jj7}|S(sCalculates the length of a non-framed message body, given a complete header. :param header: Complete message header object :type header: aws_encryption_sdk.structures.MessageHeader :param int plaintext_length: Length of plaintext in bytes :rtype: int i(RRR(Rtplaintext_lengtht body_length((s[/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/internal/formatting/__init__.pyt_non_framed_body_length s    cCs7d}||jj7}||j7}||jj7}|S(sÔCalculates the length of a standard ciphertext frame, given a complete header. :param header: Complete message header object :type header: aws_encryption_sdk.structures.MessageHeader :rtype: int i(RRt frame_lengthR(RR ((s[/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/internal/formatting/__init__.pyt_standard_frame_length/s  cCsHd}|d7}||jj7}|d7}||7}||jj7}|S(sWCalculates the length of a final ciphertext frame, given a complete header and the number of bytes of ciphertext in the final frame. :param header: Complete message header object :type header: aws_encryption_sdk.structures.MessageHeader :param int final_frame_bytes: Bytes of ciphertext in the final frame :rtype: int i(RRR(Rtfinal_frame_bytestfinal_frame_length((s[/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/internal/formatting/__init__.pyt_final_frame_length=s    cCsnd}|jdkr+|t||ƒ7}n?t||jƒ\}}||t|ƒ7}|t||ƒ7}|S(s Calculates the ciphertext message body length, given a complete header. :param header: Complete message header object :type header: aws_encryption_sdk.structures.MessageHeader :param int plaintext_length: Length of plaintext in bytes :rtype: int i(R R tdivmodR R(RRRtframesR ((s[/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/internal/formatting/__init__.pyROscCs9d}|jjdk r5|d7}||jj7}n|S(sĪCalculates the ciphertext message footer length, given a complete header. :param header: Complete message header object :type header: aws_encryption_sdk.structures.MessageHeader :rtype: int iiN(Rtsigning_algorithm_infotNonet signature_len(Rt footer_length((s[/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/internal/formatting/__init__.pyRas  cCs3t|ƒ}|t||ƒ7}|t|ƒ7}|S(sCalculates the complete ciphertext message length, given a complete header. :param header: Complete message header object :type header: aws_encryption_sdk.structures.MessageHeader :param int plaintext_length: Length of plaintext in bytes :rtype: int (RRR(RRtciphertext_length((s[/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/internal/formatting/__init__.pyRos N( t__doc__t serializeRRR R RRRR(((s[/tmp/pip-build-wDUJoH/aws-encryption-sdk/aws_encryption_sdk/internal/formatting/__init__.pyt s