aws_encryption_sdk.internal.formatting.encryption_context¶
Components for handling serialization and deserialization of encryption context data in AWS Encryption SDK messages.
Functions
|
Assembles the Body AAD string for a message body structure. |
Deserializes the contents of a byte string into a dictionary. |
|
|
Reads a number from a byte array. |
|
Reads a string from a byte string. |
|
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.
serialize_encryption_context
(encryption_context)¶ Serializes the contents of a dictionary into a byte string.
-
aws_encryption_sdk.internal.formatting.encryption_context.
read_short
(source, offset)¶ Reads a number from a byte array.
-
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.
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