• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# This file is part of pyasn1-modules software.
3#
4# Created by Russ Housley
5# Copyright (c) 2019, Vigil Security, LLC
6# License: http://snmplabs.com/pyasn1/license.html
7#
8
9import sys
10
11from pyasn1.codec.der import decoder as der_decoder
12from pyasn1.codec.der import encoder as der_encoder
13
14from pyasn1_modules import pem
15from pyasn1_modules import rfc5280
16from pyasn1_modules import rfc8418
17
18try:
19    import unittest2 as unittest
20except ImportError:
21    import unittest
22
23
24class KeyAgreeAlgTestCase(unittest.TestCase):
25    key_agree_alg_id_pem_text = "MBoGCyqGSIb3DQEJEAMUMAsGCWCGSAFlAwQBLQ=="
26
27    def setUp(self):
28        self.asn1Spec = rfc5280.AlgorithmIdentifier()
29
30    def testDerCodec(self):
31        substrate = pem.readBase64fromText(self.key_agree_alg_id_pem_text)
32        asn1Object, rest = der_decoder.decode(substrate, asn1Spec=self.asn1Spec)
33        assert not rest
34        assert asn1Object.prettyPrint()
35        assert asn1Object['algorithm'] == rfc8418.dhSinglePass_stdDH_hkdf_sha384_scheme
36        assert asn1Object['parameters'].isValue
37        assert der_encoder.encode(asn1Object) == substrate
38
39
40suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
41
42if __name__ == '__main__':
43    import sys
44
45    result = unittest.TextTestRunner(verbosity=2).run(suite)
46    sys.exit(not result.wasSuccessful())
47