diff options
-rw-r--r-- | CHANGES.txt | 6 | ||||
-rw-r--r-- | pyasn1_modules/rfc3565.py | 36 | ||||
-rw-r--r-- | pyasn1_modules/rfc5649.py | 3 | ||||
-rw-r--r-- | tests/__main__.py | 3 | ||||
-rw-r--r-- | tests/test_rfc3565.py | 57 |
5 files changed, 102 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 01b9a8b..3c6bdfc 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,7 +2,11 @@ Revision 0.2.6, released XX-04-2019 ----------------------------------- -No changes yet +- Added RFC3560 providing RSAES-OAEP Key Transport Algorithm + in CMS +- Added RFC6019 providing BinaryTime - an alternate format + for representing Date and Time +- RFC3565 superseded by RFC5649 Revision 0.2.5, released 24-04-2019 ----------------------------------- diff --git a/pyasn1_modules/rfc3565.py b/pyasn1_modules/rfc3565.py new file mode 100644 index 0000000..2cac273 --- /dev/null +++ b/pyasn1_modules/rfc3565.py @@ -0,0 +1,36 @@ +# Copyright (c) 2019, Vigil Security, LLC +# License: http://snmplabs.com/pyasn1/license.html +# +# Use of the Elliptic Curve Diffie-Hellman Key Agreement Algorithm +# with X25519 and X448 in the Cryptographic Message Syntax (CMS) +# +# ASN.1 source from: +# https://www.rfc-editor.org/rfc/rfc3565.txt + +from pyasn1.type import constraint +from pyasn1.type import univ + +from pyasn1_modules import rfc5280 + + +class AlgorithmIdentifier(rfc5280.AlgorithmIdentifier): + pass + + +class AES_IV(univ.OctetString): + pass + + +AES_IV.subtypeSpec = constraint.ValueSizeConstraint(16, 16) + +id_aes128_CBC = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.2') + +id_aes192_CBC = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.22') + +id_aes256_CBC = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.42') + +id_aes128_wrap = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.5') + +id_aes192_wrap = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.25') + +id_aes256_wrap = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.45') diff --git a/pyasn1_modules/rfc5649.py b/pyasn1_modules/rfc5649.py index 292bf1e..84809ee 100644 --- a/pyasn1_modules/rfc5649.py +++ b/pyasn1_modules/rfc5649.py @@ -10,8 +10,7 @@ # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc5649.txt - -from pyasn1.type import univ, constraint +from pyasn1.type import univ from pyasn1_modules import rfc5280 diff --git a/tests/__main__.py b/tests/__main__.py index 4515f83..6e0e183 100644 --- a/tests/__main__.py +++ b/tests/__main__.py @@ -18,6 +18,7 @@ suite = unittest.TestLoader().loadTestsFromNames( 'tests.test_rfc2511.suite', 'tests.test_rfc2560.suite', 'tests.test_rfc2986.suite', + 'tests.test_rfc3560.suite', 'tests.test_rfc3565.suite', 'tests.test_rfc3779.suite', 'tests.test_rfc4055.suite', @@ -27,8 +28,10 @@ suite = unittest.TestLoader().loadTestsFromNames( 'tests.test_rfc5084.suite', 'tests.test_rfc5208.suite', 'tests.test_rfc5280.suite', + 'tests.test_rfc5649.suite', 'tests.test_rfc5652.suite', 'tests.test_rfc5958.suite', + 'tests.test_rfc6019.suite', 'tests.test_rfc8103.suite', 'tests.test_rfc8226.suite', 'tests.test_rfc8410.suite', diff --git a/tests/test_rfc3565.py b/tests/test_rfc3565.py new file mode 100644 index 0000000..aa16134 --- /dev/null +++ b/tests/test_rfc3565.py @@ -0,0 +1,57 @@ +# +# This file is part of pyasn1-modules software. +# +# Created by Russ Housley +# Copyright (c) 2019, Vigil Security, LLC +# License: http://snmplabs.com/pyasn1/license.html +# + +import sys + +from pyasn1.codec.der import decoder as der_decoder +from pyasn1.codec.der import encoder as der_encoder + +from pyasn1_modules import pem +from pyasn1_modules import rfc3565 + +try: + import unittest2 as unittest +except ImportError: + import unittest + + +class AESKeyWrapTestCase(unittest.TestCase): + kw_alg_id_pem_text = "MAsGCWCGSAFlAwQBLQ==" + + def setUp(self): + self.asn1Spec = rfc3565.AlgorithmIdentifier() + + def testDerCodec(self): + substrate = pem.readBase64fromText(self.kw_alg_id_pem_text) + asn1Object, rest = der_decoder.decode(substrate, asn1Spec=self.asn1Spec) + assert not rest + assert asn1Object.prettyPrint() + assert asn1Object[0] == rfc3565.id_aes256_wrap + assert der_encoder.encode(asn1Object) == substrate + + +class AESCBCTestCase(unittest.TestCase): + aes_alg_id_pem_text = "MB0GCWCGSAFlAwQBKgQQEImWuoUOPwM5mTu1h4oONw==" + + def setUp(self): + self.asn1Spec = rfc3565.AlgorithmIdentifier() + + def testDerCodec(self): + substrate = pem.readBase64fromText(self.aes_alg_id_pem_text) + asn1Object, rest = der_decoder.decode(substrate, asn1Spec=self.asn1Spec) + assert not rest + assert asn1Object.prettyPrint() + assert asn1Object[0] == rfc3565.id_aes256_CBC + assert asn1Object[1].isValue + assert der_encoder.encode(asn1Object) == substrate + + +suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__]) + +if __name__ == '__main__': + unittest.TextTestRunner(verbosity=2).run(suite)
\ No newline at end of file |