diff options
-rw-r--r-- | docs/conf.py | 4 | ||||
-rw-r--r-- | docs/development/test-vectors.rst | 3 | ||||
-rw-r--r-- | docs/hazmat/primitives/constant-time.rst | 2 | ||||
-rw-r--r-- | docs/hazmat/primitives/symmetric-encryption.rst | 3 | ||||
-rw-r--r-- | docs/x509/tutorial.rst | 4 | ||||
-rw-r--r-- | setup.py | 4 | ||||
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/rsa.py | 4 | ||||
-rw-r--r-- | src/cryptography/utils.py | 1 | ||||
-rw-r--r-- | src/cryptography/x509/__init__.py | 10 | ||||
-rw-r--r-- | tests/hazmat/backends/test_openssl.py | 5 | ||||
-rw-r--r-- | tests/hypothesis/__init__.py | 4 | ||||
-rw-r--r-- | vectors/cryptography_vectors/x509/department-of-state-root.pem | 40 |
12 files changed, 74 insertions, 10 deletions
diff --git a/docs/conf.py b/docs/conf.py index dcc9c626..643eddba 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -273,3 +273,7 @@ texinfo_documents = [ intersphinx_mapping = {'https://docs.python.org/3': None} epub_theme = 'epub' + +# Retry requests in the linkcheck builder so that we're resillient against +# transient network errors. +linkcheck_retries = 2 diff --git a/docs/development/test-vectors.rst b/docs/development/test-vectors.rst index ad945f2f..d62fb93a 100644 --- a/docs/development/test-vectors.rst +++ b/docs/development/test-vectors.rst @@ -110,6 +110,9 @@ X.509 containing a SAN extension with an ``ediPartyName`` general name. * ``san_x400address.der`` - A DSA certificate from a `Mozilla bug`_ containing a SAN extension with an ``x400Address`` general name. +* ``department-of-state-root.pem`` - The intermediary CA for the Department of + State, issued by the United States Federal Government's Common Policy CA. + Notably has a ``critical`` policy constraints extensions. Custom X.509 Vectors ~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/hazmat/primitives/constant-time.rst b/docs/hazmat/primitives/constant-time.rst index 1394b6b3..1c1d544f 100644 --- a/docs/hazmat/primitives/constant-time.rst +++ b/docs/hazmat/primitives/constant-time.rst @@ -40,4 +40,4 @@ about the timing attacks on KeyCzar and Java's ``MessageDigest.isEqual()``. ``bytes``. -.. _`Coda Hale's blog post`: http://codahale.com/a-lesson-in-timing-attacks/ +.. _`Coda Hale's blog post`: https://codahale.com/a-lesson-in-timing-attacks/ diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst index 309c6fd0..d5884897 100644 --- a/docs/hazmat/primitives/symmetric-encryption.rst +++ b/docs/hazmat/primitives/symmetric-encryption.rst @@ -334,6 +334,9 @@ Modes :raises ValueError: This is raised if ``len(tag) < min_tag_length``. + An example of securely encrypting and decrypting data with ``AES`` in the + ``GCM`` mode looks like: + .. testcode:: import os diff --git a/docs/x509/tutorial.rst b/docs/x509/tutorial.rst index 0fa061a2..7252e43a 100644 --- a/docs/x509/tutorial.rst +++ b/docs/x509/tutorial.rst @@ -1,8 +1,8 @@ Tutorial ======== -X.509 certificates are used to authenticate clients on servers. The most common -use case is for web servers using HTTPS. +X.509 certificates are used to authenticate clients and servers. The most +common use case is for web servers using HTTPS. Creating a Certificate Signing Request (CSR) -------------------------------------------- @@ -61,9 +61,11 @@ test_requirements = [ "pytest", "pretend", "iso8601", - "hypothesis>=1.11.4", "pyasn1_modules", ] +if sys.version_info[:2] > (2, 6): + test_requirements.append("hypothesis>=1.11.4") + # If there's no vectors locally that probably means we are in a tarball and # need to go and get the matching vectors package from PyPi diff --git a/src/cryptography/hazmat/backends/openssl/rsa.py b/src/cryptography/hazmat/backends/openssl/rsa.py index 033cd3b1..a48b167d 100644 --- a/src/cryptography/hazmat/backends/openssl/rsa.py +++ b/src/cryptography/hazmat/backends/openssl/rsa.py @@ -534,11 +534,9 @@ class _RSAPrivateKey(object): return _enc_dec_rsa(self._backend, self, ciphertext, padding) def public_key(self): - ctx = self._backend._lib.RSA_new() + ctx = self._backend._lib.RSAPublicKey_dup(self._rsa_cdata) self._backend.openssl_assert(ctx != self._backend._ffi.NULL) ctx = self._backend._ffi.gc(ctx, self._backend._lib.RSA_free) - ctx.e = self._backend._lib.BN_dup(self._rsa_cdata.e) - ctx.n = self._backend._lib.BN_dup(self._rsa_cdata.n) res = self._backend._lib.RSA_blinding_on(ctx, self._backend._ffi.NULL) self._backend.openssl_assert(res == 1) evp_pkey = self._backend._rsa_cdata_to_evp_pkey(ctx) diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index 22edd94f..53795732 100644 --- a/src/cryptography/utils.py +++ b/src/cryptography/utils.py @@ -45,6 +45,7 @@ else: while len(data) > 0: digit, = struct.unpack('>I', data[:4]) result = (result << 32) + digit + # TODO: this is quadratic in the length of data data = data[4:] return result diff --git a/src/cryptography/x509/__init__.py b/src/cryptography/x509/__init__.py index 3f0ac14d..8d7bad27 100644 --- a/src/cryptography/x509/__init__.py +++ b/src/cryptography/x509/__init__.py @@ -4,6 +4,7 @@ from __future__ import absolute_import, division, print_function +from cryptography import utils from cryptography.x509.base import ( Certificate, CertificateBuilder, CertificateRevocationList, CertificateRevocationListBuilder, @@ -31,12 +32,19 @@ from cryptography.x509.general_name import ( ) from cryptography.x509.name import Name, NameAttribute from cryptography.x509.oid import ( - AuthorityInformationAccessOID, CRLEntryExtensionOID, CRLExtensionOID, + AuthorityInformationAccessOID, CRLEntryExtensionOID, CertificatePoliciesOID, ExtendedKeyUsageOID, ExtensionOID, NameOID, ObjectIdentifier, SignatureAlgorithmOID, _SIG_OIDS_TO_HASH ) +CRLExtensionOID = utils.deprecated( + CRLEntryExtensionOID, + __name__, + "CRLExtensionOID has been renamed to CRLEntryExtensionOID", + utils.DeprecatedIn12 +) + OID_AUTHORITY_INFORMATION_ACCESS = ExtensionOID.AUTHORITY_INFORMATION_ACCESS OID_AUTHORITY_KEY_IDENTIFIER = ExtensionOID.AUTHORITY_KEY_IDENTIFIER OID_BASIC_CONSTRAINTS = ExtensionOID.BASIC_CONSTRAINTS diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index e0555686..0b55a485 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -611,10 +611,11 @@ class TestOpenSSLSerializationWithOpenSSL(object): def test_pem_password_cb(self): password = b'abcdefg' + buf_size = len(password) + 1 ffi_cb, userdata = backend._pem_password_cb(password) handle = backend._ffi.new_handle(userdata) - buf = backend._ffi.new('char *') - assert ffi_cb(buf, len(password) + 1, False, handle) == len(password) + buf = backend._ffi.new('char[]', buf_size) + assert ffi_cb(buf, buf_size, False, handle) == len(password) assert userdata.called == 1 assert backend._ffi.string(buf, len(password)) == password diff --git a/tests/hypothesis/__init__.py b/tests/hypothesis/__init__.py index 4b540884..0b344066 100644 --- a/tests/hypothesis/__init__.py +++ b/tests/hypothesis/__init__.py @@ -3,3 +3,7 @@ # for complete details. from __future__ import absolute_import, division, print_function + +import pytest +# hypothesis no longer supports Python 2.6 so we simply skip it there +pytest.importorskip("hypothesis") diff --git a/vectors/cryptography_vectors/x509/department-of-state-root.pem b/vectors/cryptography_vectors/x509/department-of-state-root.pem new file mode 100644 index 00000000..6b6885c1 --- /dev/null +++ b/vectors/cryptography_vectors/x509/department-of-state-root.pem @@ -0,0 +1,40 @@ +-----BEGIN CERTIFICATE----- +MIIG+DCCBeCgAwIBAgICITgwDQYJKoZIhvcNAQELBQAwWTELMAkGA1UEBhMCVVMx +GDAWBgNVBAoTD1UuUy4gR292ZXJubWVudDENMAsGA1UECxMERlBLSTEhMB8GA1UE +AxMYRmVkZXJhbCBDb21tb24gUG9saWN5IENBMB4XDTE0MDgxMTE0MjUwMloXDTE3 +MDgxMTE0MjM1OVowgbExEzARBgoJkiaJk/IsZAEZFgNzYnUxFTATBgoJkiaJk/Is +ZAEZFgVzdGF0ZTEWMBQGA1UEAxMNQ29uZmlndXJhdGlvbjERMA8GA1UEAxMIU2Vy +dmljZXMxHDAaBgNVBAMTE1B1YmxpYyBLZXkgU2VydmljZXMxDDAKBgNVBAMTA0FJ +QTEsMCoGA1UEAxMjVS5TLiBEZXBhcnRtZW50IG9mIFN0YXRlIEF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