aws_encryption_sdk.internal.formatting.encryption_context¶
Components for handling serialization and deserialization of encryption context data in AWS Encryption SDK messages.
Functions
assemble_content_aad (message_id, …) |
Assembles the Body AAD string for a message body structure. |
deserialize_encryption_context (…) |
Deserializes the contents of a byte string into a dictionary. |
read_short (source, offset) |
Reads a number from a byte array. |
read_string (source, offset, length) |
Reads a string from a byte string. |
serialize_encryption_context (encryption_context) |
Serializes the contents of a dictionary into a byte string. |
-
aws_encryption_sdk.internal.formatting.encryption_context.
assemble_content_aad
(message_id, aad_content_string, seq_num, length)¶ Assembles the Body AAD string for a message body structure.
Parameters: - message_id (str) – Message ID
- aad_content_string (aws_encryption_sdk.identifiers.ContentAADString) – ContentAADString object for frame type
- seq_num (int) – Sequence number of frame
- length (int) – Content Length
Returns: Properly formatted AAD bytes for message body structure.
Return type: Raises: SerializationError – if aad_content_string is not known
-
aws_encryption_sdk.internal.formatting.encryption_context.
deserialize_encryption_context
(serialized_encryption_context)¶ Deserializes the contents of a byte string into a dictionary.
Parameters: serialized_encryption_context (bytes) – Source byte string containing serialized dictionary
Returns: Deserialized encryption context
Return type: Raises: - SerializationError – if serialized encryption context is too large
- SerializationError – if duplicate key found in serialized encryption context
- SerializationError – if malformed data found in serialized encryption context
-
aws_encryption_sdk.internal.formatting.encryption_context.
read_short
(source, offset)¶ Reads a number from a byte array.
Parameters: Returns: Read number and offset at point after read data
Return type: tuple of ints
Raises: SerializationError if unable to unpack
-
aws_encryption_sdk.internal.formatting.encryption_context.
read_string
(source, offset, length)¶ Reads a string from a byte string.
Parameters: Returns: Read string and offset at point after read data
Return type: tuple of str and int
Raises: SerializationError – if unable to unpack
-
aws_encryption_sdk.internal.formatting.encryption_context.
serialize_encryption_context
(encryption_context)¶ Serializes the contents of a dictionary into a byte string.
Parameters: encryption_context (dict) – Dictionary of encrytion context keys/values. Returns: Serialized encryption context Return type: bytes