Skip to content

Commit

Permalink
Correct tagging in cms.AttCertIssuer
Browse files Browse the repository at this point in the history
V2Form needs to be tagged implicitly, not explicitly.
  • Loading branch information
MatthiasValvekens committed Dec 22, 2021
1 parent 9ae350f commit f8214f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion asn1crypto/cms.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class V2Form(Sequence):
class AttCertIssuer(Choice):
_alternatives = [
('v1_form', GeneralNames),
('v2_form', V2Form, {'explicit': 0}),
('v2_form', V2Form, {'implicit': 0}),
]


Expand Down
Binary file added tests/fixtures/example-attr-cert.der
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/test_cms.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,3 +901,15 @@ def test_bad_teletex_inside_pkcs7(self):
]),
content['certificates'][0].chosen['tbs_certificate']['subject'].native
)

def test_parse_attribute_cert(self):
# regression test for tagging issue in AttCertIssuer

with open(os.path.join(fixtures_dir, 'example-attr-cert.der'), 'rb') as f:
ac_bytes = f.read()
ac_parsed = cms.AttributeCertificateV2.load(ac_bytes)
self.assertEqual(ac_bytes, ac_parsed.dump(force=True))

ac_info = ac_parsed['ac_info']
self.assertIsInstance(ac_info['issuer'].chosen, cms.V2Form)
self.assertEqual(1, len(ac_info['issuer'].chosen['issuer_name']))

0 comments on commit f8214f9

Please sign in to comment.