diff --git a/decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/counting.py b/decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/counting.py index cc2b5377f..d9f3f31a2 100644 --- a/decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/counting.py +++ b/decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/counting.py @@ -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 @@ -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 """ @@ -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 diff --git a/decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/null.py b/decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/null.py index 2a90bc6e5..fae31833c 100644 --- a/decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/null.py +++ b/decrypt_oracle/src/aws_encryption_sdk_decrypt_oracle/key_providers/null.py @@ -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 """ @@ -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 """ @@ -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 """ @@ -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 diff --git a/examples/test/legacy/v3_default_cmm.py b/examples/test/legacy/v3_default_cmm.py index f077e26c9..262d1ecc1 100644 --- a/examples/test/legacy/v3_default_cmm.py +++ b/examples/test/legacy/v3_default_cmm.py @@ -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 @@ -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 diff --git a/src/aws_encryption_sdk/__init__.py b/src/aws_encryption_sdk/__init__.py index 326dacc13..ef1ed2e3b 100644 --- a/src/aws_encryption_sdk/__init__.py +++ b/src/aws_encryption_sdk/__init__.py @@ -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` diff --git a/src/aws_encryption_sdk/identifiers.py b/src/aws_encryption_sdk/identifiers.py index 4a801b02f..7a7c9ed78 100644 --- a/src/aws_encryption_sdk/identifiers.py +++ b/src/aws_encryption_sdk/identifiers.py @@ -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] @@ -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 diff --git a/src/aws_encryption_sdk/internal/crypto/authentication.py b/src/aws_encryption_sdk/internal/crypto/authentication.py index f769d4a39..cd3458833 100644 --- a/src/aws_encryption_sdk/internal/crypto/authentication.py +++ b/src/aws_encryption_sdk/internal/crypto/authentication.py @@ -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 """ @@ -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 """ @@ -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 """ @@ -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 """ @@ -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 @@ -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 diff --git a/src/aws_encryption_sdk/internal/crypto/data_keys.py b/src/aws_encryption_sdk/internal/crypto/data_keys.py index 518b239a1..f5bd165b2 100644 --- a/src/aws_encryption_sdk/internal/crypto/data_keys.py +++ b/src/aws_encryption_sdk/internal/crypto/data_keys.py @@ -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 @@ -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 diff --git a/src/aws_encryption_sdk/internal/crypto/elliptic_curve.py b/src/aws_encryption_sdk/internal/crypto/elliptic_curve.py index ce1e72224..fe3c53426 100644 --- a/src/aws_encryption_sdk/internal/crypto/elliptic_curve.py +++ b/src/aws_encryption_sdk/internal/crypto/elliptic_curve.py @@ -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 @@ -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 """ diff --git a/src/aws_encryption_sdk/internal/crypto/encryption.py b/src/aws_encryption_sdk/internal/crypto/encryption.py index 4766e22e8..a59818836 100644 --- a/src/aws_encryption_sdk/internal/crypto/encryption.py +++ b/src/aws_encryption_sdk/internal/crypto/encryption.py @@ -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 @@ -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 @@ -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 @@ -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`, diff --git a/src/aws_encryption_sdk/internal/crypto/iv.py b/src/aws_encryption_sdk/internal/crypto/iv.py index e0c7f975e..b3deed243 100644 --- a/src/aws_encryption_sdk/internal/crypto/iv.py +++ b/src/aws_encryption_sdk/internal/crypto/iv.py @@ -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 @@ -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 """ @@ -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 """ diff --git a/src/aws_encryption_sdk/internal/formatting/serialize.py b/src/aws_encryption_sdk/internal/formatting/serialize.py index 27e98c399..a015e2ad3 100644 --- a/src/aws_encryption_sdk/internal/formatting/serialize.py +++ b/src/aws_encryption_sdk/internal/formatting/serialize.py @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 diff --git a/src/aws_encryption_sdk/internal/utils/__init__.py b/src/aws_encryption_sdk/internal/utils/__init__.py index 7ce1dcdb2..dbb7d3f9b 100644 --- a/src/aws_encryption_sdk/internal/utils/__init__.py +++ b/src/aws_encryption_sdk/internal/utils/__init__.py @@ -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 """ @@ -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` @@ -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: diff --git a/src/aws_encryption_sdk/key_providers/base.py b/src/aws_encryption_sdk/key_providers/base.py index 5fa99cc1c..43fb6d82b 100644 --- a/src/aws_encryption_sdk/key_providers/base.py +++ b/src/aws_encryption_sdk/key_providers/base.py @@ -210,7 +210,7 @@ def decrypt_data_key(self, encrypted_data_key, algorithm, encryption_context): :param encrypted_data_key: Encrypted data key to decrypt :type encrypted_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 encryption :returns: Decrypted data key :rtype: aws_encryption_sdk.structures.DataKey @@ -294,7 +294,7 @@ def decrypt_data_key_from_list(self, encrypted_data_keys, algorithm, encryption_ :param encrypted_data_keys: List of encrypted data keys :type encrypted_data_keys: list of :class:`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 encryption :returns: Decrypted data key :rtype: aws_encryption_sdk.structures.DataKey @@ -439,7 +439,7 @@ def generate_data_key(self, algorithm, encryption_context): """Generates and returns data key for use encrypting message. :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 @@ -463,7 +463,7 @@ def _generate_data_key(self, algorithm, encryption_context): Must be implemented by specific MasterKey implementations. :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 @@ -476,7 +476,7 @@ def encrypt_data_key(self, data_key, algorithm, encryption_context): :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 :returns: Data key containing encrypted data key :rtype: aws_encryption_sdk.structures.EncryptedDataKey @@ -496,7 +496,7 @@ def _encrypt_data_key(self, data_key, algorithm, encryption_context): :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 :returns: Decrypted data key :rtype: aws_encryption_sdk.structures.EncryptedDataKey @@ -509,7 +509,7 @@ def decrypt_data_key(self, encrypted_data_key, algorithm, encryption_context): :param encrypted_data_key: Encrypted data key :type encrypted_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: Decrypted data key :rtype: aws_encryption_sdk.structures.DataKey @@ -535,7 +535,7 @@ def _decrypt_data_key(self, encrypted_data_key, algorithm, encryption_context): :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 diff --git a/src/aws_encryption_sdk/key_providers/kms.py b/src/aws_encryption_sdk/key_providers/kms.py index b34e0b8fc..78e7260ab 100644 --- a/src/aws_encryption_sdk/key_providers/kms.py +++ b/src/aws_encryption_sdk/key_providers/kms.py @@ -182,7 +182,7 @@ def _generate_data_key(self, algorithm, encryption_context=None): """Generates data key and returns plaintext and ciphertext of 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 pass to KMS :returns: Generated data key :rtype: aws_encryption_sdk.structures.DataKey @@ -267,7 +267,7 @@ def _decrypt_data_key(self, encrypted_data_key, algorithm, encryption_context=No :param data_key: Encrypted data key :type data_key: aws_encryption_sdk.structures.EncryptedDataKey - :type algorithm: `aws_encryption_sdk.identifiers.Algorithm` (not used for KMS) + :type algorithm: `aws_encryption_sdk.identifiers.AlgorithmSuite` (not used for KMS) :param dict encryption_context: Encryption context to use in decryption :returns: Decrypted data key :rtype: aws_encryption_sdk.structures.DataKey diff --git a/src/aws_encryption_sdk/key_providers/raw.py b/src/aws_encryption_sdk/key_providers/raw.py index f3d8ec478..94a029c52 100644 --- a/src/aws_encryption_sdk/key_providers/raw.py +++ b/src/aws_encryption_sdk/key_providers/raw.py @@ -106,7 +106,7 @@ def _generate_data_key(self, algorithm, encryption_context): """Generates data key and returns :class:`aws_encryption_sdk.structures.DataKey`. :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 @@ -130,7 +130,7 @@ def _encrypt_data_key(self, data_key, algorithm, encryption_context): :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 :returns: Decrypted data key :rtype: aws_encryption_sdk.structures.EncryptedDataKey @@ -154,7 +154,7 @@ def _decrypt_data_key(self, encrypted_data_key, algorithm, encryption_context): :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 diff --git a/src/aws_encryption_sdk/materials_managers/__init__.py b/src/aws_encryption_sdk/materials_managers/__init__.py index 3d03e1f30..cbebe6c1d 100644 --- a/src/aws_encryption_sdk/materials_managers/__init__.py +++ b/src/aws_encryption_sdk/materials_managers/__init__.py @@ -26,7 +26,7 @@ class EncryptionMaterialsRequest(object): :param plaintext_rostream: Source plaintext read-only stream (optional) :type plaintext_rostream: aws_encryption_sdk.internal.utils.streams.ROStream :param algorithm: Algorithm passed to underlying master key provider and master keys (optional) - :type algorithm: aws_encryption_sdk.identifiers.Algorithm + :type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite :param int plaintext_length: Length of source plaintext (optional) """ @@ -52,7 +52,7 @@ class EncryptionMaterials(object): .. versionadded:: 1.3.0 :param algorithm: Algorithm to use for encrypting message - :type algorithm: aws_encryption_sdk.identifiers.Algorithm + :type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite :param data_encryption_key: Plaintext data key to use for encrypting message :type data_encryption_key: aws_encryption_sdk.structures.DataKey :param encrypted_data_keys: List of encrypted data keys @@ -75,7 +75,7 @@ class DecryptionMaterialsRequest(object): .. versionadded:: 1.3.0 :param algorithm: Algorithm to provide to master keys for underlying decrypt requests - :type algorithm: aws_encryption_sdk.identifiers.Algorithm + :type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite :param encrypted_data_keys: Set of encrypted data keys :type encrypted_data_keys: set of `aws_encryption_sdk.structures.EncryptedDataKey` :param dict encryption_context: Encryption context to provide to master keys for underlying decrypt requests diff --git a/src/aws_encryption_sdk/materials_managers/default.py b/src/aws_encryption_sdk/materials_managers/default.py index 4a7119792..1b85ab007 100644 --- a/src/aws_encryption_sdk/materials_managers/default.py +++ b/src/aws_encryption_sdk/materials_managers/default.py @@ -36,7 +36,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 @@ -107,7 +107,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 diff --git a/src/aws_encryption_sdk/streaming_client.py b/src/aws_encryption_sdk/streaming_client.py index c2411a716..3fb3c9efd 100644 --- a/src/aws_encryption_sdk/streaming_client.py +++ b/src/aws_encryption_sdk/streaming_client.py @@ -444,7 +444,7 @@ class EncryptorConfig(_ClientConfig): :param dict encryption_context: Dictionary defining encryption context :param algorithm: Algorithm to use for encryption (optional) - :type algorithm: aws_encryption_sdk.identifiers.Algorithm + :type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite :param int frame_length: Frame length in bytes (optional) """ @@ -499,7 +499,7 @@ class StreamEncryptor(_EncryptionStream): # pylint: disable=too-many-instance-a :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 """ diff --git a/src/aws_encryption_sdk/structures.py b/src/aws_encryption_sdk/structures.py index a09391d5b..bcbc65de8 100644 --- a/src/aws_encryption_sdk/structures.py +++ b/src/aws_encryption_sdk/structures.py @@ -18,7 +18,7 @@ class MessageHeader(object): :param type: Message content type, per spec :type type: aws_encryption_sdk.identifiers.ObjectType :param algorithm: Algorithm to use for encryption - :type algorithm: aws_encryption_sdk.identifiers.Algorithm + :type algorithm: aws_encryption_sdk.identifiers.AlgorithmSuite :param bytes message_id: Message ID :param dict encryption_context: Dictionary defining encryption context :param encrypted_data_keys: Encrypted data keys diff --git a/test/unit/test_docstring_algorithm_alias.py b/test/unit/test_docstring_algorithm_alias.py new file mode 100644 index 000000000..97c84be65 --- /dev/null +++ b/test/unit/test_docstring_algorithm_alias.py @@ -0,0 +1,31 @@ +# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 +"""Docstring type references must name AlgorithmSuite, not its alias Algorithm. + +Sphinx does not follow the ``Algorithm = AlgorithmSuite`` alias when it resolves +``:type:`` and ``:rtype:`` references, so documented parameters of that type render +without a link. +""" +import os +import re + +import pytest + +pytestmark = [pytest.mark.unit, pytest.mark.local] + +SRC_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "src")) +ALIAS_TYPE_REFERENCE = re.compile(r"^\s*:(?:type|rtype)[^:]*:.*identifiers\.Algorithm\b(?!Suite)") + + +def test_docstrings_do_not_reference_algorithm_alias(): + offenders = [] + for root, _dirs, files in os.walk(SRC_DIR): + for name in files: + if not name.endswith(".py"): + continue + path = os.path.join(root, name) + with open(path, encoding="utf-8") as source: + for line_number, line in enumerate(source, start=1): + if ALIAS_TYPE_REFERENCE.match(line): + offenders.append("{}:{}".format(os.path.relpath(path, SRC_DIR), line_number)) + assert not offenders, "Use AlgorithmSuite in :type:/:rtype: references: " + ", ".join(offenders)