Merge pull request #1246 from Ayrx/add-binding
Add GENERAL_NAMES_free binding
diff --git a/cryptography/hazmat/primitives/asymmetric/rsa.py b/cryptography/hazmat/primitives/asymmetric/rsa.py
index 15ec52a..398b376 100644
--- a/cryptography/hazmat/primitives/asymmetric/rsa.py
+++ b/cryptography/hazmat/primitives/asymmetric/rsa.py
@@ -402,3 +402,6 @@
def public_key(self, backend):
return backend.load_rsa_public_numbers(self)
+
+ def __repr__(self):
+ return "<RSAPublicNumbers(e={0}, n={1})>".format(self._e, self._n)
diff --git a/docs/hazmat/primitives/asymmetric/dsa.rst b/docs/hazmat/primitives/asymmetric/dsa.rst
index 55f36b5..e411931 100644
--- a/docs/hazmat/primitives/asymmetric/dsa.rst
+++ b/docs/hazmat/primitives/asymmetric/dsa.rst
@@ -119,6 +119,16 @@
The generator.
+ .. method:: parameters(backend)
+
+ :param backend: A
+ :class:`~cryptography.hazmat.backends.interfaces.DSABackend`
+ provider.
+
+ :returns: A new instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.DSAParameters`
+ provider.
+
.. class:: DSAPublicNumbers(y, parameter_numbers)
.. versionadded:: 0.5
@@ -138,6 +148,16 @@
The :class:`~cryptography.hazmat.primitives.dsa.DSAParameterNumbers`
associated with the public key.
+ .. method:: public_key(backend)
+
+ :param backend: A
+ :class:`~cryptography.hazmat.backends.interfaces.DSABackend`
+ provider.
+
+ :returns: A new instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.DSAPublicKey`
+ provider.
+
.. class:: DSAPrivateNumbers(x, public_numbers)
.. versionadded:: 0.5
@@ -162,6 +182,16 @@
The :class:`~cryptography.hazmat.primitives.dsa.DSAPublicNumbers`
associated with the private key.
+ .. method:: private_key(backend)
+
+ :param backend: A
+ :class:`~cryptography.hazmat.backends.interfaces.DSABackend`
+ provider.
+
+ :returns: A new instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.DSAPrivateKey`
+ provider.
+
Deprecated Concrete Classes
~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/hazmat/primitives/asymmetric/rsa.rst b/docs/hazmat/primitives/asymmetric/rsa.rst
index 7250066..a963752 100644
--- a/docs/hazmat/primitives/asymmetric/rsa.rst
+++ b/docs/hazmat/primitives/asymmetric/rsa.rst
@@ -153,6 +153,15 @@
The public exponent.
+ .. method:: public_key(backend)
+
+ :param backend: A
+ :class:`~cryptography.hazmat.backends.interfaces.RSABackend`
+ provider.
+
+ :returns: A new instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.RSAPublicKey`
+ provider.
.. class:: RSAPrivateNumbers(p, q, d, dmp1, dmq1, iqmp, public_numbers)
@@ -213,6 +222,16 @@
A `Chinese remainder theorem`_ coefficient used to speed up RSA
operations. Calculated as: q\ :sup:`-1` mod p
+ .. method:: private_key(backend)
+
+ :param backend: A new instance of a
+ :class:`~cryptography.hazmat.backends.interfaces.RSABackend`
+ provider.
+
+ :returns: A
+ :class:`~cryptography.hazmat.primitives.interfaces.RSAPrivateKey`
+ provider.
+
Handling partial RSA private keys
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/hazmat/primitives/asymmetric/serialization.rst b/docs/hazmat/primitives/asymmetric/serialization.rst
index 874fce8..0525ed7 100644
--- a/docs/hazmat/primitives/asymmetric/serialization.rst
+++ b/docs/hazmat/primitives/asymmetric/serialization.rst
@@ -98,41 +98,3 @@
: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.
-
-
-RSA Numbers
-~~~~~~~~~~~
-
-.. function:: load_rsa_private_numbers(numbers, backend)
-
- .. versionadded:: 0.5
-
- Create a private key instance using the given backend and numbers.
-
- :param numbers: An instance of
- :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateNumbers`.
-
- :param backend: A
- :class:`~cryptography.hazmat.backends.interfaces.RSABackend` provider.
-
- :returns: A new instance of a private key.
-
- :raises UnsupportedAlgorithm: If the given backend does not support loading
- numbers.
-
-.. function:: load_rsa_public_numbers(numbers, backend)
-
- .. versionadded:: 0.5
-
- Create a public key instance using the given backend and numbers.
-
- :param numbers: An instance of
- :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicNumbers`.
-
- :param backend: A
- :class:`~cryptography.hazmat.backends.interfaces.RSABackend` provider.
-
- :returns: A new instance of a public key.
-
- :raises UnsupportedAlgorithm: If the given backend does not support loading
- numbers.
diff --git a/tasks.py b/tasks.py
index 65e33ae..c9fdfa9 100644
--- a/tasks.py
+++ b/tasks.py
@@ -81,7 +81,7 @@
"""
``version`` should be a string like '0.4' or '1.0'.
"""
- invoke.run("git tag -s {0}".format(version))
+ invoke.run("git tag -s {0} -m '{0} release'".format(version))
invoke.run("git push --tags")
invoke.run("python setup.py sdist")
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py
index 8e85073..e53ff06 100644
--- a/tests/hazmat/primitives/test_rsa.py
+++ b/tests/hazmat/primitives/test_rsa.py
@@ -27,6 +27,7 @@
)
from cryptography.hazmat.primitives import hashes, interfaces
from cryptography.hazmat.primitives.asymmetric import padding, rsa
+from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicNumbers
from .fixtures_rsa import (
RSA_KEY_1024, RSA_KEY_1025, RSA_KEY_1026, RSA_KEY_1027, RSA_KEY_1028,
@@ -1973,3 +1974,7 @@
n=33
)
).private_key(backend)
+
+ def test_public_number_repr(self):
+ num = RSAPublicNumbers(1, 1)
+ assert repr(num) == "<RSAPublicNumbers(e=1, n=1)>"