# coding: utf-8
# PyDERASN -- Python ASN.1 DER codec with abstract structures
-# Copyright (C) 2017 Sergey Matveev <stargrave@stargrave.org>
+# Copyright (C) 2017-2018 Sergey Matveev <stargrave@stargrave.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
from pyderasn import SetOf
from pyderasn import tag_ctxc
from pyderasn import tag_ctxp
+from pyderasn import TeletexString
from pyderasn import UTCTime
class Version(Integer):
- __slots__ = ()
schema = (
("v1", 0),
("v2", 1),
class CertificateSerialNumber(Integer):
- __slots__ = ()
pass
class AlgorithmIdentifier(Sequence):
- __slots__ = ()
schema = (
("algorithm", ObjectIdentifier()),
("parameters", Any(optional=True)),
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()),
class Validity(Sequence):
- __slots__ = ()
schema = (
("notBefore", Time()),
("notAfter", Time()),
class SubjectPublicKeyInfo(Sequence):
- __slots__ = ()
schema = (
("algorithm", AlgorithmIdentifier()),
("subjectPublicKey", BitString()),
class UniqueIdentifier(BitString):
- __slots__ = ()
pass
class Extension(Sequence):
- __slots__ = ()
schema = (
("extnID", ObjectIdentifier()),
("critical", Boolean(default=False)),
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()),
class Certificate(Sequence):
- __slots__ = ()
schema = (
("tbsCertificate", TBSCertificate()),
("signatureAlgorithm", AlgorithmIdentifier()),