diff options
author | Ofek Lev <ofekmeister@gmail.com> | 2017-02-08 00:09:41 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2017-02-08 13:09:41 +0800 |
commit | 0e6a129724b707ebf79149376251e85fad550414 (patch) | |
tree | 4dde35c726fa6e611d46ef84823c77050b9cb83c /tests | |
parent | 1c7bd66eef4075888a5a2c2d80ec9a67f62fec08 (diff) | |
download | cryptography-0e6a129724b707ebf79149376251e85fad550414.tar.gz cryptography-0e6a129724b707ebf79149376251e85fad550414.tar.bz2 cryptography-0e6a129724b707ebf79149376251e85fad550414.zip |
replace pyasn1 with asn1crypto (#3361)
* replace pyasn1 with asn1crypto
* allow trailing bytes
* fix x509 test
* update CHANGELOG.rst
* fix assert
* make asn1crypto code more idiomatic
* find tag
* final clean-up
* leave trailing byte logic unchanged
* document dependency change
* spelling
* fix spelling
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hazmat/primitives/test_asym_utils.py | 3 | ||||
-rw-r--r-- | tests/test_x509.py | 21 |
2 files changed, 8 insertions, 16 deletions
diff --git a/tests/hazmat/primitives/test_asym_utils.py b/tests/hazmat/primitives/test_asym_utils.py index bd1fa35e..4835f091 100644 --- a/tests/hazmat/primitives/test_asym_utils.py +++ b/tests/hazmat/primitives/test_asym_utils.py @@ -73,8 +73,7 @@ def test_decode_dss_invalid_asn1(): decode_dss_signature(b"0\x07\x02\x01\x01\x02\x02\x01") with pytest.raises(ValueError): - # This is the BER "end-of-contents octets," which older versions of - # pyasn1 are wrongly willing to return from top-level DER decoding. + # This is the BER "end-of-contents octets". decode_dss_signature(b"\x00\x00") diff --git a/tests/test_x509.py b/tests/test_x509.py index 1ecf6b6a..db26f563 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -11,9 +11,7 @@ import os import sys import warnings -from pyasn1.codec.der import decoder - -from pyasn1_modules import rfc2459 +from asn1crypto.x509 import Certificate import pytest @@ -1458,17 +1456,12 @@ class TestRSACertificateRequest(object): cert = builder.sign(issuer_private_key, hashes.SHA256(), backend) - parsed, _ = decoder.decode( - cert.public_bytes(serialization.Encoding.DER), - asn1Spec=rfc2459.Certificate() - ) - tbs_cert = parsed.getComponentByName('tbsCertificate') - subject = tbs_cert.getComponentByName('subject') - issuer = tbs_cert.getComponentByName('issuer') - # \x13 is printable string. The first byte of the value of the - # node corresponds to the ASN.1 string type. - assert subject[0][0][0][1][0] == b"\x13"[0] - assert issuer[0][0][0][1][0] == b"\x13"[0] + parsed = Certificate.load( + cert.public_bytes(serialization.Encoding.DER)) + + # Check that each value was encoded as an ASN.1 PRINTABLESTRING. + assert parsed.subject.chosen[0][0]['value'].chosen.tag == 19 + assert parsed.issuer.chosen[0][0]['value'].chosen.tag == 19 class TestCertificateBuilder(object): |