X-Git-Url: http://www.git.cypherpunks.ru/?p=pyderasn.git;a=blobdiff_plain;f=tests%2Ftest_crts.py;h=8f8f1ec7b98c164a860a3087d2353573ea83685d;hp=93162e0b8ad5a6eac35f2551ae115802ae5f87b8;hb=b9b1e4187b0cd072dd1ccd1f34aa30232483d84d;hpb=664822cb0fc85360a5f77d93ed54714c42557c74 diff --git a/tests/test_crts.py b/tests/test_crts.py index 93162e0..8f8f1ec 100644 --- a/tests/test_crts.py +++ b/tests/test_crts.py @@ -1,6 +1,6 @@ # coding: utf-8 # PyDERASN -- Python ASN.1 DER codec with abstract structures -# Copyright (C) 2017 Sergey Matveev +# Copyright (C) 2017-2018 Sergey Matveev # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as @@ -37,6 +37,7 @@ from pyderasn import SequenceOf from pyderasn import SetOf from pyderasn import tag_ctxc from pyderasn import tag_ctxp +from pyderasn import TeletexString from pyderasn import UTCTime @@ -62,7 +63,6 @@ some_oids = { class Version(Integer): - __slots__ = () schema = ( ("v1", 0), ("v2", 1), @@ -71,12 +71,10 @@ class Version(Integer): class CertificateSerialNumber(Integer): - __slots__ = () pass class AlgorithmIdentifier(Sequence): - __slots__ = () schema = ( ("algorithm", ObjectIdentifier()), ("parameters", Any(optional=True)), @@ -84,43 +82,49 @@ class AlgorithmIdentifier(Sequence): class AttributeType(ObjectIdentifier): - __slots__ = () pass class AttributeValue(Any): - __slots__ = () pass +class OrganizationName(Choice): + schema = ( + ('printableString', PrintableString()), + ('teletexString', TeletexString()), + ) + + class AttributeTypeAndValue(Sequence): - __slots__ = () schema = ( - ("type", AttributeType()), + ("type", AttributeType(defines=("value", { + ObjectIdentifier("2.5.4.6"): PrintableString(), + ObjectIdentifier("2.5.4.8"): PrintableString(), + ObjectIdentifier("2.5.4.7"): PrintableString(), + ObjectIdentifier("2.5.4.10"): OrganizationName(), + ObjectIdentifier("2.5.4.3"): PrintableString(), + }))), ("value", AttributeValue()), ) class RelativeDistinguishedName(SetOf): - __slots__ = () schema = AttributeTypeAndValue() bounds = (1, float("+inf")) class RDNSequence(SequenceOf): - __slots__ = () schema = RelativeDistinguishedName() class Name(Choice): - __slots__ = () schema = ( ("rdnSequence", RDNSequence()), ) class Time(Choice): - __slots__ = () schema = ( ("utcTime", UTCTime()), ("generalTime", GeneralizedTime()), @@ -128,7 +132,6 @@ class Time(Choice): class Validity(Sequence): - __slots__ = () schema = ( ("notBefore", Time()), ("notAfter", Time()), @@ -136,7 +139,6 @@ class Validity(Sequence): class SubjectPublicKeyInfo(Sequence): - __slots__ = () schema = ( ("algorithm", AlgorithmIdentifier()), ("subjectPublicKey", BitString()), @@ -144,12 +146,10 @@ class SubjectPublicKeyInfo(Sequence): class UniqueIdentifier(BitString): - __slots__ = () pass class Extension(Sequence): - __slots__ = () schema = ( ("extnID", ObjectIdentifier()), ("critical", Boolean(default=False)), @@ -158,13 +158,11 @@ class Extension(Sequence): class Extensions(SequenceOf): - __slots__ = () schema = Extension() bounds = (1, float("+inf")) class TBSCertificate(Sequence): - __slots__ = () schema = ( ("version", Version(expl=tag_ctxc(0), default="v1")), ("serialNumber", CertificateSerialNumber()), @@ -180,7 +178,6 @@ class TBSCertificate(Sequence): class Certificate(Sequence): - __slots__ = () schema = ( ("tbsCertificate", TBSCertificate()), ("signatureAlgorithm", AlgorithmIdentifier()),