aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2015-02-23 22:03:09 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2015-02-25 07:50:25 -0600
commit8aad028501ef434071d3969bce41c4e6375b4c61 (patch)
treea06d8e93e8ff50d2e419f6524a8495a644e5f4a6
parent4d236049529bc1ab1b301756a6c9be7a30ce8f8a (diff)
downloadcryptography-8aad028501ef434071d3969bce41c4e6375b4c61.tar.gz
cryptography-8aad028501ef434071d3969bce41c4e6375b4c61.tar.bz2
cryptography-8aad028501ef434071d3969bce41c4e6375b4c61.zip
rename dump to as_bytes
-rw-r--r--CHANGELOG.rst2
-rw-r--r--docs/hazmat/primitives/asymmetric/rsa.rst10
-rw-r--r--docs/hazmat/primitives/asymmetric/serialization.rst2
-rw-r--r--src/cryptography/hazmat/backends/openssl/rsa.py2
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/rsa.py4
-rw-r--r--tests/hazmat/backends/test_openssl.py4
-rw-r--r--tests/hazmat/primitives/test_rsa.py24
7 files changed, 24 insertions, 24 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 66a308a5..8f40d287 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -83,7 +83,7 @@ Changelog
and deprecated
:class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithNumbers`.
* Added
- :meth:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithSerialization.dump`
+ :meth:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithSerialization.as_bytes`
to
:class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithSerialization`.
diff --git a/docs/hazmat/primitives/asymmetric/rsa.rst b/docs/hazmat/primitives/asymmetric/rsa.rst
index ac58b9d2..80d48497 100644
--- a/docs/hazmat/primitives/asymmetric/rsa.rst
+++ b/docs/hazmat/primitives/asymmetric/rsa.rst
@@ -86,13 +86,13 @@ Key serialization
If you have a previously loaded or generated key that has the
:class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithSerialization`
interface you can use
-:meth:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithSerialization.dump`
+:meth:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithSerialization.as_bytes`
to serialize the key.
.. doctest::
>>> from cryptography.hazmat.primitives import serialization
- >>> pem = private_key.dump(
+ >>> pem = private_key.as_bytes(
... encoding=serialization.Encoding.PEM,
... fmt=serialization.Format.PKCS8,
... encryption_algorithm=serialization.BestAvailableEncryption(b'mypassword')
@@ -105,7 +105,7 @@ It is also possible to serialize without encryption using
.. doctest::
- >>> pem = private_key.dump(
+ >>> pem = private_key.as_bytes(
... encoding=serialization.Encoding.PEM,
... fmt=serialization.Format.TraditionalOpenSSL,
... encryption_algorithm=serialization.NoEncryption()
@@ -534,9 +534,9 @@ Key interfaces
:class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateNumbers`
instance.
- .. method:: dump(encoding, fmt, encryption_algorithm)
+ .. method:: as_bytes(encoding, fmt, encryption_algorithm)
- Dump the key to PEM encoded bytes using the serializer provided.
+ Serialize the key to bytes.
:param encoding: A value from the
:class:`~cryptography.hazmat.primitives.serialization.Encoding` enum.
diff --git a/docs/hazmat/primitives/asymmetric/serialization.rst b/docs/hazmat/primitives/asymmetric/serialization.rst
index b429766d..abf036ac 100644
--- a/docs/hazmat/primitives/asymmetric/serialization.rst
+++ b/docs/hazmat/primitives/asymmetric/serialization.rst
@@ -323,7 +323,7 @@ Serialization Encryption Types
Objects with this interface are usable as encryption types with methods
like
- :meth:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithSerialization.dump`.
+ :meth:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKeyWithSerialization.as_bytes`.
All other classes in this section represent the available choices for
encryption and have this interface.
diff --git a/src/cryptography/hazmat/backends/openssl/rsa.py b/src/cryptography/hazmat/backends/openssl/rsa.py
index efc1a577..0a1f106f 100644
--- a/src/cryptography/hazmat/backends/openssl/rsa.py
+++ b/src/cryptography/hazmat/backends/openssl/rsa.py
@@ -565,7 +565,7 @@ class _RSAPrivateKey(object):
)
)
- def dump(self, encoding, fmt, encryption_algorithm):
+ def as_bytes(self, encoding, fmt, encryption_algorithm):
if not isinstance(encoding, Encoding):
raise TypeError("encoding must be an item from the Encoding enum")
diff --git a/src/cryptography/hazmat/primitives/asymmetric/rsa.py b/src/cryptography/hazmat/primitives/asymmetric/rsa.py
index 918717f3..160ac6aa 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/rsa.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/rsa.py
@@ -50,9 +50,9 @@ class RSAPrivateKeyWithSerialization(RSAPrivateKey):
"""
@abc.abstractmethod
- def dump(self, encoding, fmt, encryption_algorithm):
+ def as_bytes(self, encoding, fmt, encryption_algorithm):
"""
- Returns the dumped key.
+ Returns the key serialized as bytes.
"""
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py
index b5de702d..8cf14b98 100644
--- a/tests/hazmat/backends/test_openssl.py
+++ b/tests/hazmat/backends/test_openssl.py
@@ -502,7 +502,7 @@ class TestRSAPEMSerialization(object):
password = b"x" * 1024
key = RSA_KEY_2048.private_key(backend)
with pytest.raises(ValueError):
- key.dump(
+ key.as_bytes(
serialization.Encoding.PEM,
serialization.Format.PKCS8,
serialization.BestAvailableEncryption(password)
@@ -511,7 +511,7 @@ class TestRSAPEMSerialization(object):
def test_unsupported_key_encoding(self):
key = RSA_KEY_2048.private_key(backend)
with pytest.raises(ValueError):
- key.dump(
+ key.as_bytes(
serialization.Encoding.DER,
serialization.Format.PKCS8,
serialization.NoEncryption()
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py
index a0df2f26..17a2a414 100644
--- a/tests/hazmat/primitives/test_rsa.py
+++ b/tests/hazmat/primitives/test_rsa.py
@@ -1764,10 +1764,10 @@ class TestRSAPEMWriter(object):
]
)
)
- def test_dump_encrypted_pem(self, backend, fmt, password):
+ def test_as_bytes_encrypted_pem(self, backend, fmt, password):
key = RSA_KEY_2048.private_key(backend)
_skip_if_no_serialization(key, backend)
- serialized = key.dump(
+ serialized = key.as_bytes(
serialization.Encoding.PEM,
fmt,
serialization.BestAvailableEncryption(password)
@@ -1783,10 +1783,10 @@ class TestRSAPEMWriter(object):
"fmt",
(serialization.Format.TraditionalOpenSSL, serialization.Format.PKCS8),
)
- def test_dump_unencrypted_pem(self, backend, fmt):
+ def test_as_bytes_unencrypted_pem(self, backend, fmt):
key = RSA_KEY_2048.private_key(backend)
_skip_if_no_serialization(key, backend)
- serialized = key.dump(
+ serialized = key.as_bytes(
serialization.Encoding.PEM,
fmt,
serialization.NoEncryption()
@@ -1798,41 +1798,41 @@ class TestRSAPEMWriter(object):
priv_num = key.private_numbers()
assert loaded_priv_num == priv_num
- def test_dump_invalid_encoding(self, backend):
+ def test_as_bytes_invalid_encoding(self, backend):
key = RSA_KEY_2048.private_key(backend)
_skip_if_no_serialization(key, backend)
with pytest.raises(TypeError):
- key.dump(
+ key.as_bytes(
"notencoding",
serialization.Format.PKCS8,
serialization.NoEncryption()
)
- def test_dump_invalid_format(self, backend):
+ def test_as_bytes_invalid_format(self, backend):
key = RSA_KEY_2048.private_key(backend)
_skip_if_no_serialization(key, backend)
with pytest.raises(TypeError):
- key.dump(
+ key.as_bytes(
serialization.Encoding.PEM,
"invalidformat",
serialization.NoEncryption()
)
- def test_dump_invalid_encryption_algorithm(self, backend):
+ def test_as_bytes_invalid_encryption_algorithm(self, backend):
key = RSA_KEY_2048.private_key(backend)
_skip_if_no_serialization(key, backend)
with pytest.raises(TypeError):
- key.dump(
+ key.as_bytes(
serialization.Encoding.PEM,
serialization.Format.TraditionalOpenSSL,
"notanencalg"
)
- def test_dump_unsupported_encryption_type(self, backend):
+ def test_as_bytes_unsupported_encryption_type(self, backend):
key = RSA_KEY_2048.private_key(backend)
_skip_if_no_serialization(key, backend)
with pytest.raises(ValueError):
- key.dump(
+ key.as_bytes(
serialization.Encoding.PEM,
serialization.Format.TraditionalOpenSSL,
DummyKeyEncryption()