Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _generate_data_key(self, algorithm: AlgorithmSuite, encryption_context: Dict
"""Perform the provider-specific data key generation task.

:param algorithm: Algorithm on which to base data key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param dict encryption_context: Encryption context to use in encryption
:returns: Generated data key
:rtype: aws_encryption_sdk.structures.DataKey
Expand All @@ -61,7 +61,7 @@ def _encrypt_data_key(
:type data_key: :class:`aws_encryption_sdk.structures.RawDataKey`
or :class:`aws_encryption_sdk.structures.DataKey`
:param algorithm: Algorithm object which directs how this Master Key will encrypt the data key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param dict encryption_context: Encryption context to use in encryption
:raises NotImplementedError: when called
"""
Expand All @@ -75,7 +75,7 @@ def _decrypt_data_key(
:param data_key: Encrypted data key
:type data_key: aws_encryption_sdk.structures.EncryptedDataKey
:param algorithm: Algorithm object which directs how this Master Key will encrypt the data key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param dict encryption_context: Encryption context to use in decryption
:returns: Data key containing decrypted data key
:rtype: aws_encryption_sdk.structures.DataKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _null_plaintext_data_key(algorithm: AlgorithmSuite) -> bytes:
"""Build the null data key of the correct length for the requested algorithm suite.

:param algorithm: Algorithm on which to base data key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:returns: Null data key
:rtype: bytes
"""
Expand All @@ -60,7 +60,7 @@ def _generate_data_key(self, algorithm: AlgorithmSuite, encryption_context: Dict
""":class:`NullMasterKey` does not support generate_data_key

:param algorithm: Algorithm on which to base data key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param dict encryption_context: Encryption context to use in encryption
:raises NotImplementedError: when called
"""
Expand All @@ -77,7 +77,7 @@ def _encrypt_data_key(
:type data_key: :class:`aws_encryption_sdk.structures.RawDataKey`
or :class:`aws_encryption_sdk.structures.DataKey`
:param algorithm: Algorithm object which directs how this Master Key will encrypt the data key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param dict encryption_context: Encryption context to use in encryption
:raises NotImplementedError: when called
"""
Expand All @@ -91,7 +91,7 @@ def _decrypt_data_key(
:param data_key: Encrypted data key
:type data_key: aws_encryption_sdk.structures.EncryptedDataKey
:param algorithm: Algorithm object which directs how this Master Key will encrypt the data key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param dict encryption_context: Encryption context to use in decryption
:returns: Data key containing decrypted data key
:rtype: aws_encryption_sdk.structures.DataKey
Expand Down
4 changes: 2 additions & 2 deletions examples/test/legacy/v3_default_cmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _generate_signing_key_and_update_encryption_context(self, algorithm, encrypt
"""Generates a signing key based on the provided algorithm.

:param algorithm: Algorithm for which to generate signing key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param dict encryption_context: Encryption context from request
:returns: Signing key bytes
:rtype: bytes or None
Expand Down Expand Up @@ -117,7 +117,7 @@ def _load_verification_key_from_encryption_context(self, algorithm, encryption_c
"""Loads the verification key from the encryption context if used by algorithm suite.

:param algorithm: Algorithm for which to generate signing key
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param dict encryption_context: Encryption context from request
:returns: Raw verification key
:rtype: bytes
Expand Down
2 changes: 1 addition & 1 deletion src/aws_encryption_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def encrypt(self, **kwargs):

:param dict encryption_context: Dictionary defining encryption context
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param int frame_length: Frame length in bytes
:returns: Tuple containing the encrypted ciphertext and the message header object
:rtype: tuple of bytes and :class:`aws_encryption_sdk.structures.MessageHeader`
Expand Down
4 changes: 2 additions & 2 deletions src/aws_encryption_sdk/identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def get_by_id(cls, algorithm_id):
:param algorithm_id: Value of algorithm_id field with which to retrieve Algorithm
:type algorithm_id: int
:returns: Algorithm with ID algorithm_id
:rtype: aws_encryption_sdk.identifiers.Algorithm
:rtype: aws_encryption_sdk.identifiers.AlgorithmSuite
"""
return cls.__rlookup__[algorithm_id]

Expand Down Expand Up @@ -293,7 +293,7 @@ class WrappingAlgorithm(Enum):
"""Wrapping Algorithms for use by RawMasterKey objects.

:param algorithm: Encryption algorithm to use for encryption of data keys
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param padding_type: Padding type to use for encryption of data keys
:type padding_type:
:param padding_algorithm: Padding algorithm to use for encryption of data keys
Expand Down
12 changes: 6 additions & 6 deletions src/aws_encryption_sdk/internal/crypto/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class _PrehashingAuthenticator(object):
"""Parent class for Signer/Verifier. Provides common behavior and interface.

:param algorithm: Algorithm on which to base authenticator
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param key: Key with which to build authenticator
"""

Expand Down Expand Up @@ -55,7 +55,7 @@ class Signer(_PrehashingAuthenticator):
"""Abstract signing handler.

:param algorithm: Algorithm on which to base signer
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param key: Private key from which a signer can be generated
:type key: currently only Elliptic Curve Private Keys are supported
"""
Expand All @@ -65,7 +65,7 @@ def from_key_bytes(cls, algorithm, key_bytes, encoding=serialization.Encoding.DE
"""Builds a `Signer` from an algorithm suite and a raw signing key.

:param algorithm: Algorithm on which to base signer
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes key_bytes: Raw signing key
:rtype: aws_encryption_sdk.internal.crypto.Signer
"""
Expand Down Expand Up @@ -123,7 +123,7 @@ class Verifier(_PrehashingAuthenticator):
For ECC curves, the signature must be DER encoded as specified in RFC 3279.

:param algorithm: Algorithm on which to base verifier
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param public_key: Appropriate public key object for algorithm
:type public_key: may vary
"""
Expand All @@ -133,7 +133,7 @@ def from_encoded_point(cls, algorithm, encoded_point):
"""Creates a Verifier object based on the supplied algorithm and encoded compressed ECC curve point.

:param algorithm: Algorithm on which to base verifier
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes encoded_point: ECC public point compressed and encoded with _ecc_encode_compressed_point
:returns: Instance of Verifier generated from encoded point
:rtype: aws_encryption_sdk.internal.crypto.Verifier
Expand All @@ -150,7 +150,7 @@ def from_key_bytes(cls, algorithm, key_bytes):
"""Creates a `Verifier` object based on the supplied algorithm and raw verification key.

:param algorithm: Algorithm on which to base verifier
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes encoded_point: Raw verification key
:returns: Instance of Verifier generated from encoded point
:rtype: aws_encryption_sdk.internal.crypto.Verifier
Expand Down
4 changes: 2 additions & 2 deletions src/aws_encryption_sdk/internal/crypto/data_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def derive_data_encryption_key(source_key, algorithm, message_id):

:param bytes source_key: Raw source key
:param algorithm: Algorithm used to encrypt this body
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes message_id: Message ID
:returns: Derived data encryption key
:rtype: bytes
Expand Down Expand Up @@ -54,7 +54,7 @@ def calculate_commitment_key(source_key, algorithm, message_id):

:param bytes source_key: Raw source key
:param algorithm: Algorithm used to encrypt this body
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes message_id: Message ID
:returns: Derived data encryption key
:rtype: bytes
Expand Down
4 changes: 2 additions & 2 deletions src/aws_encryption_sdk/internal/crypto/elliptic_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _ecc_static_length_signature(key, algorithm, digest):
:param key: Elliptic curve private key
:type key: cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey
:param algorithm: Master algorithm to use
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes digest: Pre-calculated hash digest
:returns: Signature with required length
:rtype: bytes
Expand Down Expand Up @@ -167,7 +167,7 @@ def generate_ecc_signing_key(algorithm):
"""Returns an ECC signing key.

:param algorithm: Algorithm object which determines what signature to generate
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:returns: Generated signing key
:raises NotSupportedError: if signing algorithm is not supported on this platform
"""
Expand Down
8 changes: 4 additions & 4 deletions src/aws_encryption_sdk/internal/crypto/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Encryptor(object):
"""Abstract encryption handler.

:param algorithm: Algorithm used to encrypt this body
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes key: Encryption key
:param bytes associated_data: Associated Data to send to encryption subsystem
:param bytes iv: IV to use when encrypting message
Expand Down Expand Up @@ -67,7 +67,7 @@ def encrypt(algorithm, key, plaintext, associated_data, iv):
"""Encrypts a frame body.

:param algorithm: Algorithm used to encrypt this body
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes key: Encryption key
:param bytes plaintext: Body plaintext
:param bytes associated_data: Body AAD Data
Expand All @@ -84,7 +84,7 @@ class Decryptor(object):
"""Abstract decryption handler.

:param algorithm: Algorithm used to encrypt this body
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes key: Raw source key
:param bytes associated_data: Associated Data to send to decryption subsystem
:param bytes iv: IV value with which to initialize decryption subsystem
Expand Down Expand Up @@ -126,7 +126,7 @@ def decrypt(algorithm, key, encrypted_data, associated_data):
"""Decrypts a frame body.

:param algorithm: Algorithm used to encrypt this body
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes key: Plaintext data key
:param encrypted_data: EncryptedData containing body data
:type encrypted_data: :class:`aws_encryption_sdk.internal.structures.EncryptedData`,
Expand Down
6 changes: 3 additions & 3 deletions src/aws_encryption_sdk/internal/crypto/iv.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def frame_iv(algorithm, sequence_number):
"""Builds the deterministic IV for a body frame.

:param algorithm: Algorithm for which to build IV
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param int sequence_number: Frame sequence number
:returns: Generated IV
:rtype: bytes
Expand All @@ -58,7 +58,7 @@ def non_framed_body_iv(algorithm):
"""Builds the deterministic IV for a non-framed body.

:param algorithm: Algorithm for which to build IV
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:returns: Generated IV
:rtype: bytes
"""
Expand All @@ -69,7 +69,7 @@ def header_auth_iv(algorithm):
"""Builds the deterministic IV for header authentication.

:param algorithm: Algorithm for which to build IV
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:returns: Generated IV
:rtype: bytes
"""
Expand Down
10 changes: 5 additions & 5 deletions src/aws_encryption_sdk/internal/formatting/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def _serialize_header_auth_v1(
"""Creates serialized header authentication data for messages in serialization version V1.

:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes header: Serialized message header
:param bytes data_encryption_key: Data key with which to encrypt message
:param signer: Cryptographic signer object (optional)
Expand Down Expand Up @@ -257,7 +257,7 @@ def _serialize_header_auth_v2(
"""Creates serialized header authentication data for messages in serialization version V2.

:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes header: Serialized message header
:param bytes data_encryption_key: Data key with which to encrypt message
:param signer: Cryptographic signer object (optional)
Expand Down Expand Up @@ -313,7 +313,7 @@ def serialize_header_auth(
:param version: The serialization version of the message
:type version: int
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes header: Serialized message header
:param bytes data_encryption_key: Data key with which to encrypt message
:param signer: Cryptographic signer object (optional)
Expand Down Expand Up @@ -342,7 +342,7 @@ def serialize_non_framed_open(algorithm, iv, plaintext_length, signer=None):
"""Serializes the opening block for a non-framed message body.

:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes iv: IV value used to encrypt body
:param int plaintext_length: Length of plaintext (and thus ciphertext) in body
:param signer: Cryptographic signer object (optional)
Expand Down Expand Up @@ -379,7 +379,7 @@ def serialize_frame(
the frame, and returns the encrypted frame and the remaining plaintext.

:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param bytes plaintext: Source plaintext to encrypt and serialize
:param bytes message_id: Message ID
:param bytes data_encryption_key: Data key with which to encrypt message
Expand Down
6 changes: 3 additions & 3 deletions src/aws_encryption_sdk/internal/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def validate_frame_length(frame_length, algorithm):

:param int frame_length: Frame size in bytes
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:raises SerializationError: if frame size is negative or not a multiple of the algorithm block size
:raises SerializationError: if frame size is larger than the maximum allowed frame size
"""
Expand Down Expand Up @@ -96,7 +96,7 @@ def prepare_data_keys(primary_master_key, master_keys, algorithm, encryption_con
:param master_keys: All master keys with which to encrypt data keys
:type master_keys: list of :class:`aws_encryption_sdk.key_providers.base.MasterKey`
:param algorithm: Algorithm to use for encryption
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:param dict encryption_context: Encryption context to use when generating data key
:rtype: tuple containing :class:`aws_encryption_sdk.structures.DataKey`
and set of :class:`aws_encryption_sdk.structures.EncryptedDataKey`
Expand Down Expand Up @@ -144,7 +144,7 @@ def source_data_key_length_check(source_data_key, algorithm):
:type source_data_key: :class:`aws_encryption_sdk.structures.RawDataKey`
or :class:`aws_encryption_sdk.structures.DataKey`
:param algorithm: Algorithm object which directs how this data key will be used
:type algorithm: aws_encryption_sdk.identifiers.Algorithm
:type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite
:raises InvalidDataKeyError: if data key length does not match required kdf input length
"""
if len(source_data_key.data_key) != algorithm.kdf_input_len:
Expand Down
Loading