diff options
Diffstat (limited to 'docs/hazmat')
-rw-r--r-- | docs/hazmat/backends/interfaces.rst | 40 | ||||
-rw-r--r-- | docs/hazmat/bindings/commoncrypto.rst | 2 | ||||
-rw-r--r-- | docs/hazmat/bindings/index.rst | 2 | ||||
-rw-r--r-- | docs/hazmat/bindings/openssl.rst | 2 | ||||
-rw-r--r-- | docs/hazmat/primitives/asymmetric/dsa.rst | 6 | ||||
-rw-r--r-- | docs/hazmat/primitives/asymmetric/ec.rst | 6 | ||||
-rw-r--r-- | docs/hazmat/primitives/asymmetric/rsa.rst | 16 | ||||
-rw-r--r-- | docs/hazmat/primitives/asymmetric/serialization.rst | 14 | ||||
-rw-r--r-- | docs/hazmat/primitives/cryptographic-hashes.rst | 52 | ||||
-rw-r--r-- | docs/hazmat/primitives/interfaces.rst | 58 | ||||
-rw-r--r-- | docs/hazmat/primitives/key-derivation-functions.rst | 6 | ||||
-rw-r--r-- | docs/hazmat/primitives/mac/hmac.rst | 6 | ||||
-rw-r--r-- | docs/hazmat/primitives/symmetric-encryption.rst | 5 |
13 files changed, 107 insertions, 108 deletions
diff --git a/docs/hazmat/backends/interfaces.rst b/docs/hazmat/backends/interfaces.rst index e3dc96c0..15d8b980 100644 --- a/docs/hazmat/backends/interfaces.rst +++ b/docs/hazmat/backends/interfaces.rst @@ -91,7 +91,7 @@ A specific ``backend`` may provide one or more of these interfaces. Check if the specified ``algorithm`` is supported by this backend. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :returns: ``True`` if the specified ``algorithm`` is supported by this @@ -101,15 +101,15 @@ A specific ``backend`` may provide one or more of these interfaces. .. method:: create_hash_ctx(algorithm) Create a - :class:`~cryptography.hazmat.primitives.interfaces.HashContext` that + :class:`~cryptography.hazmat.primitives.hashes.HashContext` that uses the specified ``algorithm`` to calculate a message digest. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :returns: - :class:`~cryptography.hazmat.primitives.interfaces.HashContext` + :class:`~cryptography.hazmat.primitives.hashes.HashContext` .. class:: HMACBackend @@ -127,7 +127,7 @@ A specific ``backend`` may provide one or more of these interfaces. Check if the specified ``algorithm`` is supported by this backend. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :returns: ``True`` if the specified ``algorithm`` is supported for HMAC @@ -136,16 +136,16 @@ A specific ``backend`` may provide one or more of these interfaces. .. method:: create_hmac_ctx(algorithm) Create a - :class:`~cryptography.hazmat.primitives.interfaces.HashContext` that + :class:`~cryptography.hazmat.primitives.hashes.HashContext` that uses the specified ``algorithm`` to calculate a hash-based message authentication code. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :returns: - :class:`~cryptography.hazmat.primitives.interfaces.HashContext` + :class:`~cryptography.hazmat.primitives.hashes.HashContext` .. class:: CMACBackend @@ -191,7 +191,7 @@ A specific ``backend`` may provide one or more of these interfaces. Check if the specified ``algorithm`` is supported by this backend. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :returns: ``True`` if the specified ``algorithm`` is supported for @@ -200,7 +200,7 @@ A specific ``backend`` may provide one or more of these interfaces. .. method:: derive_pbkdf2_hmac(self, algorithm, length, salt, iterations, key_material) :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :param int length: The desired length of the derived key. Maximum is @@ -334,7 +334,7 @@ A specific ``backend`` may provide one or more of these interfaces. restricted to only the 1024-bit keys specified in FIPS 186-2. :return: A new instance of a - :class:`~cryptography.hazmat.primitives.interfaces.DSAPrivateKey` + :class:`~cryptography.hazmat.primitives.asymmetric.dsa.DSAPrivateKey` provider. :raises ValueError: This is raised if the key size is not supported @@ -343,7 +343,7 @@ A specific ``backend`` may provide one or more of these interfaces. .. method:: dsa_hash_supported(algorithm) :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :returns: ``True`` if the specified ``algorithm`` is supported by this @@ -401,7 +401,7 @@ A specific ``backend`` may provide one or more of these interfaces. .. method:: elliptic_curve_supported(curve) :param curve: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve` + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve` provider. :returns: True if the elliptic curve is supported by this backend. @@ -409,11 +409,11 @@ A specific ``backend`` may provide one or more of these interfaces. .. method:: elliptic_curve_signature_algorithm_supported(signature_algorithm, curve) :param signature_algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurveSignatureAlgorithm` + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurveSignatureAlgorithm` provider. :param curve: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve` + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve` provider. :returns: True if the signature algorithm and curve are supported by this backend. @@ -421,27 +421,27 @@ A specific ``backend`` may provide one or more of these interfaces. .. method:: generate_elliptic_curve_private_key(curve) :param curve: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurve` + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurve` provider. .. method:: load_elliptic_curve_private_numbers(numbers) :param numbers: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePrivateNumbers` + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateNumbers` provider. :returns: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePrivateKey` + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey` provider. .. method:: load_elliptic_curve_public_numbers(numbers) :param numbers: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePublicNumbers` + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicNumbers` provider. :returns: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.EllipticCurvePublicKey` + :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey` provider. .. class:: PEMSerializationBackend diff --git a/docs/hazmat/bindings/commoncrypto.rst b/docs/hazmat/bindings/commoncrypto.rst index 9484cfa1..4f58a6d3 100644 --- a/docs/hazmat/bindings/commoncrypto.rst +++ b/docs/hazmat/bindings/commoncrypto.rst @@ -17,7 +17,7 @@ available on Mac OS X versions 10.8 and above. .. attribute:: ffi - This is a :class:`cffi.FFI` instance. It can be used to allocate and + This is a ``cffi.FFI`` instance. It can be used to allocate and otherwise manipulate CommonCrypto structures. .. attribute:: lib diff --git a/docs/hazmat/bindings/index.rst b/docs/hazmat/bindings/index.rst index ccd36e3e..8075be14 100644 --- a/docs/hazmat/bindings/index.rst +++ b/docs/hazmat/bindings/index.rst @@ -3,7 +3,7 @@ Bindings ======== -.. currentmodule:: cryptography.hazmat.bindings +.. module:: cryptography.hazmat.bindings ``cryptography`` aims to provide low-level CFFI based bindings to multiple native C libraries. These provide no automatic initialization of the library diff --git a/docs/hazmat/bindings/openssl.rst b/docs/hazmat/bindings/openssl.rst index 36255b52..446c450c 100644 --- a/docs/hazmat/bindings/openssl.rst +++ b/docs/hazmat/bindings/openssl.rst @@ -16,7 +16,7 @@ versions may work but are **not tested or supported**. .. attribute:: ffi - This is a :class:`cffi.FFI` instance. It can be used to allocate and + This is a ``cffi.FFI`` instance. It can be used to allocate and otherwise manipulate OpenSSL structures. .. attribute:: lib diff --git a/docs/hazmat/primitives/asymmetric/dsa.rst b/docs/hazmat/primitives/asymmetric/dsa.rst index ff934a6a..36bc801f 100644 --- a/docs/hazmat/primitives/asymmetric/dsa.rst +++ b/docs/hazmat/primitives/asymmetric/dsa.rst @@ -3,7 +3,7 @@ DSA === -.. currentmodule:: cryptography.hazmat.primitives.asymmetric.dsa +.. module:: cryptography.hazmat.primitives.asymmetric.dsa `DSA`_ is a `public-key`_ algorithm for signing messages. @@ -267,7 +267,7 @@ Key interfaces :rfc:`6979`. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :param backend: A @@ -330,7 +330,7 @@ Key interfaces specified in :rfc:`6979`. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :param backend: A diff --git a/docs/hazmat/primitives/asymmetric/ec.rst b/docs/hazmat/primitives/asymmetric/ec.rst index 4b8177ea..5b114710 100644 --- a/docs/hazmat/primitives/asymmetric/ec.rst +++ b/docs/hazmat/primitives/asymmetric/ec.rst @@ -3,7 +3,7 @@ Elliptic curve cryptography =========================== -.. currentmodule:: cryptography.hazmat.primitives.asymmetric.ec +.. module:: cryptography.hazmat.primitives.asymmetric.ec .. function:: generate_private_key(curve, backend) @@ -32,7 +32,7 @@ Elliptic Curve Signature Algorithms `FIPS 186-3`_, and later in `FIPS 186-4`_. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. .. doctest:: @@ -282,7 +282,7 @@ Key Interfaces .. attribute:: algorithm - :type: :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :type: :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` The digest algorithm to be used with the signature scheme. diff --git a/docs/hazmat/primitives/asymmetric/rsa.rst b/docs/hazmat/primitives/asymmetric/rsa.rst index c37961eb..4855a45c 100644 --- a/docs/hazmat/primitives/asymmetric/rsa.rst +++ b/docs/hazmat/primitives/asymmetric/rsa.rst @@ -3,7 +3,7 @@ RSA === -.. currentmodule:: cryptography.hazmat.primitives.asymmetric.rsa +.. module:: cryptography.hazmat.primitives.asymmetric.rsa `RSA`_ is a `public-key`_ algorithm for encrypting and signing messages. @@ -252,7 +252,7 @@ Mask generation functions in :class:`PSS` padding. It takes a hash algorithm and a salt length. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. Numbers @@ -307,7 +307,7 @@ is unavailable. .. attribute:: public_numbers - :type: :class:`~cryptography.hazmat.primitives.rsa.RSAPublicNumbers` + :type: :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicNumbers` The :class:`RSAPublicNumbers` which makes up the RSA public key associated with this RSA private key. @@ -316,19 +316,19 @@ is unavailable. :type: int - ``p``, one of the two primes composing the :attr:`modulus`. + ``p``, one of the two primes composing ``n``. .. attribute:: q :type: int - ``q``, one of the two primes composing the :attr:`modulus`. + ``q``, one of the two primes composing ``n``. .. attribute:: d :type: int - The private exponent. Alias for :attr:`private_exponent`. + The private exponent. .. attribute:: dmp1 @@ -429,7 +429,7 @@ Key interfaces provider. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :returns: @@ -499,7 +499,7 @@ Key interfaces provider. :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :returns: diff --git a/docs/hazmat/primitives/asymmetric/serialization.rst b/docs/hazmat/primitives/asymmetric/serialization.rst index 7ff4ce30..8155e6f4 100644 --- a/docs/hazmat/primitives/asymmetric/serialization.rst +++ b/docs/hazmat/primitives/asymmetric/serialization.rst @@ -104,9 +104,9 @@ all begin with ``-----BEGIN {format}-----`` and end with ``-----END not encrypted. Or if the key was encrypted but no password was supplied. - :raises UnsupportedAlgorithm: If the serialized key is of a type that - is not supported by the backend or if the key is encrypted with a - symmetric cipher that is not supported by the backend. + :raises cryptography.exceptions.UnsupportedAlgorithm: If the serialized key + is of a type that is not supported by the backend or if the key is + encrypted with a symmetric cipher that is not supported by the backend. .. function:: load_pem_public_key(data, backend) @@ -133,8 +133,8 @@ all begin with ``-----BEGIN {format}-----`` and end with ``-----END :raises ValueError: If the PEM data's structure could not be decoded successfully. - :raises UnsupportedAlgorithm: If the serialized key is of a type that - is not supported by the backend. + :raises cryptography.exceptions.UnsupportedAlgorithm: If the serialized key + is of a type that is not supported by the backend. OpenSSH Public Key @@ -181,5 +181,5 @@ DSA keys look almost identical but begin with ``ssh-dss`` rather than :raises ValueError: If the OpenSSH data could not be properly decoded or if the key is not in the proper format. - :raises UnsupportedAlgorithm: If the serialized key is of a type that is - not supported. + :raises cryptography.exceptions.UnsupportedAlgorithm: If the serialized + key is of a type that is not supported. diff --git a/docs/hazmat/primitives/cryptographic-hashes.rst b/docs/hazmat/primitives/cryptographic-hashes.rst index 7e5295c4..49288326 100644 --- a/docs/hazmat/primitives/cryptographic-hashes.rst +++ b/docs/hazmat/primitives/cryptographic-hashes.rst @@ -3,7 +3,7 @@ Message digests =============== -.. currentmodule:: cryptography.hazmat.primitives.hashes +.. module:: cryptography.hazmat.primitives.hashes .. class:: Hash(algorithm, backend) @@ -12,9 +12,9 @@ Message digests results (with a high probability) in different digests. This is an implementation of - :class:`~cryptography.hazmat.primitives.interfaces.HashContext` meant to + :class:`~cryptography.hazmat.primitives.hashes.HashContext` meant to be used with - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` implementations to provide an incremental interface to calculating various message digests. @@ -39,7 +39,7 @@ Message digests `Lifetimes of cryptographic hash functions`_. :param algorithm: A - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider such as those described in :ref:`below <cryptographic-hash-algorithms>`. :param backend: A @@ -146,4 +146,48 @@ MD5 message digest and has practical known collision attacks. +Interfaces +~~~~~~~~~~ + +.. class:: HashAlgorithm + + .. attribute:: name + + :type: str + + The standard name for the hash algorithm, for example: ``"sha256"`` or + ``"whirlpool"``. + + .. attribute:: digest_size + + :type: int + + The size of the resulting digest in bytes. + + .. attribute:: block_size + + :type: int + + The internal block size of the hash algorithm in bytes. + + +.. class:: HashContext + + .. attribute:: algorithm + + A :class:`HashAlgorithm` that will be used by this context. + + .. method:: update(data) + + :param bytes data: The data you want to hash. + + .. method:: finalize() + + :return: The final digest as bytes. + + .. method:: copy() + + :return: A :class:`HashContext` that is a copy of the current context. + + .. _`Lifetimes of cryptographic hash functions`: http://valerieaurora.org/hash.html diff --git a/docs/hazmat/primitives/interfaces.rst b/docs/hazmat/primitives/interfaces.rst index 0995489f..86a3a7e4 100644 --- a/docs/hazmat/primitives/interfaces.rst +++ b/docs/hazmat/primitives/interfaces.rst @@ -1,5 +1,7 @@ .. hazmat:: +.. module:: cryptography.hazmat.primitives.interfaces + Interfaces ========== @@ -15,9 +17,6 @@ to document argument and return types. Symmetric ciphers ----------------- -.. currentmodule:: cryptography.hazmat.primitives.interfaces - - .. class:: CipherAlgorithm A named symmetric encryption algorithm. @@ -75,9 +74,10 @@ Interfaces used by the symmetric cipher modes described in meets any necessary invariants. This should raise an exception if they are not met. - For example, the :class:`~cryptography.hazmat.primitives.modes.CBC` - mode uses this method to check that the provided initialization - vector's length matches the block size of the algorithm. + For example, the + :class:`~cryptography.hazmat.primitives.ciphers.modes.CBC` mode uses + this method to check that the provided initialization vector's length + matches the block size of the algorithm. .. class:: ModeWithInitializationVector @@ -160,52 +160,6 @@ In 0.8 the EC key interfaces were moved to the :mod:`cryptography.hazmat.primitives.asymmetric.ec` module. -Hash algorithms ---------------- - -.. class:: HashAlgorithm - - .. attribute:: name - - :type: str - - The standard name for the hash algorithm, for example: ``"sha256"`` or - ``"whirlpool"``. - - .. attribute:: digest_size - - :type: int - - The size of the resulting digest in bytes. - - .. attribute:: block_size - - :type: int - - The internal block size of the hash algorithm in bytes. - - -.. class:: HashContext - - .. attribute:: algorithm - - A :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` that - will be used by this context. - - .. method:: update(data) - - :param bytes data: The data you want to hash. - - .. method:: finalize() - - :return: The final digest as bytes. - - .. method:: copy() - - :return: A :class:`~cryptography.hazmat.primitives.interfaces.HashContext` - that is a copy of the current context. - - Key derivation functions ------------------------ diff --git a/docs/hazmat/primitives/key-derivation-functions.rst b/docs/hazmat/primitives/key-derivation-functions.rst index 60096870..4a47159f 100644 --- a/docs/hazmat/primitives/key-derivation-functions.rst +++ b/docs/hazmat/primitives/key-derivation-functions.rst @@ -69,7 +69,7 @@ Different KDFs are suitable for different tasks such as: >>> kdf.verify(b"my great password", key) :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :param int length: The desired length of the derived key. Maximum is (2\ :sup:`32` - 1) * ``algorithm.digest_size``. @@ -169,7 +169,7 @@ Different KDFs are suitable for different tasks such as: >>> hkdf.verify(b"input key", key) :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :param int length: The desired length of the derived key. Maximum is @@ -270,7 +270,7 @@ Different KDFs are suitable for different tasks such as: >>> hkdf.verify(key_material, key) :param algorithm: An instance of a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. :param int length: The desired length of the derived key. Maximum is diff --git a/docs/hazmat/primitives/mac/hmac.rst b/docs/hazmat/primitives/mac/hmac.rst index ce566c5c..2515ac91 100644 --- a/docs/hazmat/primitives/mac/hmac.rst +++ b/docs/hazmat/primitives/mac/hmac.rst @@ -18,7 +18,7 @@ of a message. .. class:: HMAC(key, algorithm, backend) HMAC objects take a ``key`` and a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` provider. + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider. The ``key`` should be :doc:`randomly generated bytes </random-numbers>` and is recommended to be equal in length to the ``digest_size`` of the hash function chosen. You must keep the ``key`` secret. @@ -39,7 +39,7 @@ of a message. raised. If ``algorithm`` isn't a - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` provider + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider then ``TypeError`` will be raised. To check that a given signature is correct use the :meth:`verify` method. @@ -56,7 +56,7 @@ of a message. :param bytes key: Secret key as ``bytes``. :param algorithm: An - :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm` + :class:`~cryptography.hazmat.primitives.hashes.HashAlgorithm` provider such as those described in :ref:`Cryptographic Hashes <cryptographic-hash-algorithms>`. :param backend: An diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst index d532ad1b..b2ce376b 100644 --- a/docs/hazmat/primitives/symmetric-encryption.rst +++ b/docs/hazmat/primitives/symmetric-encryption.rst @@ -422,6 +422,7 @@ Insecure modes Interfaces ---------- +.. currentmodule:: cryptography.hazmat.primitives.interfaces .. class:: CipherContext @@ -438,8 +439,8 @@ Interfaces recommended padding is :class:`~cryptography.hazmat.primitives.padding.PKCS7`. If you are using a stream cipher mode (such as - :class:`~cryptography.hazmat.primitives.modes.CTR`) you don't have to worry - about this. + :class:`~cryptography.hazmat.primitives.ciphers.modes.CTR`) you don't have + to worry about this. .. method:: update(data) |