diff options
-rw-r--r-- | CHANGELOG.rst | 2 | ||||
-rw-r--r-- | docs/hazmat/primitives/asymmetric/dh.rst | 24 | ||||
-rw-r--r-- | src/cryptography/hazmat/primitives/asymmetric/dh.py | 14 |
3 files changed, 20 insertions, 20 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 81aca4e5..c212bb55 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -88,7 +88,7 @@ Changelog * Support for OpenSSL 1.0.0 has been removed. Users on older version of OpenSSL will need to upgrade. * Added support for Diffie-Hellman key exchange using - :meth:`~cryptography.hazmat.primitives.asymmetric.dh.DHPrivateKeyWithSerialization.exchange` + :meth:`~cryptography.hazmat.primitives.asymmetric.dh.DHPrivateKey.exchange`. * The OS random engine for OpenSSL has been rewritten to improve compatibility with embedded Python and other edge cases. More information about this change can be found in the diff --git a/docs/hazmat/primitives/asymmetric/dh.rst b/docs/hazmat/primitives/asymmetric/dh.rst index 759b265b..58ff663d 100644 --- a/docs/hazmat/primitives/asymmetric/dh.rst +++ b/docs/hazmat/primitives/asymmetric/dh.rst @@ -29,8 +29,7 @@ derivation function. DHE (or EDH), the ephemeral form of this exchange, is **strongly preferred** over simple DH and provides `forward secrecy`_ when used. You must generate a new private key using :func:`~DHParameters.generate_private_key` for -each :meth:`~DHPrivateKeyWithSerialization.exchange` when performing an DHE key -exchange. +each :meth:`~DHPrivateKey.exchange` when performing an DHE key exchange. To assemble a :class:`~DHParameters` and a :class:`~DHPublicKey` from primitive integers, you must first create the @@ -123,12 +122,22 @@ Key interfaces :return: A :class:`~cryptography.hazmat.primitives.asymmetric.dh.DHParameters`. + .. method:: exchange(peer_public_key) + + .. versionadded:: 1.7 + + :param DHPublicKeyWithSerialization peer_public_key: The public key for + the peer. + + :return bytes: The agreed key. The bytes are ordered in 'big' endian. + .. class:: DHPrivateKeyWithSerialization .. versionadded:: 0.9 - Inherits from :class:`~cryptography.hazmat.primitives.asymmetric.dh.DHPrivateKey`. + Inherits from + :class:`~cryptography.hazmat.primitives.asymmetric.dh.DHPrivateKey`. .. method:: private_numbers() @@ -136,15 +145,6 @@ Key interfaces :return: A :class:`~cryptography.hazmat.primitives.asymmetric.dh.DHPrivateNumbers`. - .. method:: exchange(peer_public_key) - - .. versionadded:: 1.7 - - :param DHPublicKeyWithSerialization peer_public_key: The public key for the - peer. - - :return bytes: The agreed key. The bytes are ordered in 'big' endian. - .. method:: private_bytes(encoding, format, encryption_algorithm) .. versionadded:: 1.8 diff --git a/src/cryptography/hazmat/primitives/asymmetric/dh.py b/src/cryptography/hazmat/primitives/asymmetric/dh.py index aa60a2d8..d5e82606 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/dh.py +++ b/src/cryptography/hazmat/primitives/asymmetric/dh.py @@ -153,6 +153,13 @@ class DHPrivateKey(object): The DHParameters object associated with this private key. """ + @abc.abstractmethod + def exchange(self, peer_public_key): + """ + Given peer's DHPublicKey, carry out the key exchange and + return shared key as bytes. + """ + @six.add_metaclass(abc.ABCMeta) class DHPrivateKeyWithSerialization(DHPrivateKey): @@ -162,13 +169,6 @@ class DHPrivateKeyWithSerialization(DHPrivateKey): Returns a DHPrivateNumbers. """ - @abc.abstractmethod - def exchange(self, peer_public_key): - """ - Given peer's DHPublicKey, carry out the key exchange and - return shared key as bytes. - """ - @six.add_metaclass(abc.ABCMeta) class DHPublicKey(object): |