class OrganizationName(Choice):
schema = (
- ('printableString', PrintableString()),
- ('teletexString', TeletexString()),
+ ("printableString", PrintableString()),
+ ("teletexString", TeletexString()),
)
class AttributeTypeAndValue(Sequence):
schema = (
- ("type", AttributeType(defines=("value", {
+ ("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()),
)
expect.encode(),
)
assert_raw_equals(tbs["serialNumber"], Integer(10143011886257155224))
- algo_id = AlgorithmIdentifier()
- algo_id["algorithm"] = ObjectIdentifier("1.2.840.113549.1.1.5")
- algo_id["parameters"] = Any(Null())
+ algo_id = AlgorithmIdentifier((
+ ("algorithm", ObjectIdentifier("1.2.840.113549.1.1.5")),
+ ("parameters", Any(Null())),
+ ))
self.assertEqual(tbs["signature"], algo_id)
assert_raw_equals(tbs["signature"], algo_id)
- issuer = Name()
rdnSeq = RDNSequence()
for oid, klass, text in (
("2.5.4.6", PrintableString, "XX"),
("2.5.4.3", PrintableString, "false.example.com"),
("1.2.840.113549.1.9.1", IA5String, "false@example.com"),
):
- attr = AttributeTypeAndValue()
- attr["type"] = AttributeType(oid)
- attr["value"] = AttributeValue(klass(text))
- rdn = RelativeDistinguishedName()
- rdn.append(attr)
- rdnSeq.append(rdn)
- issuer["rdnSequence"] = rdnSeq
+ rdnSeq.append(
+ RelativeDistinguishedName((
+ AttributeTypeAndValue((
+ ("type", AttributeType(oid)),
+ ("value", AttributeValue(klass(text))),
+ )),
+ ))
+ )
+ issuer = Name(("rdnSequence", rdnSeq))
self.assertEqual(tbs["issuer"], issuer)
assert_raw_equals(tbs["issuer"], issuer)
- validity = Validity()
- validity["notBefore"] = Time(
- ("utcTime", UTCTime(datetime(2009, 10, 8, 0, 25, 53)))
- )
- validity["notAfter"] = Time(
- ("utcTime", UTCTime(datetime(2010, 10, 8, 0, 25, 53)))
- )
+ validity = Validity((
+ ("notBefore", Time(
+ ("utcTime", UTCTime(datetime(2009, 10, 8, 0, 25, 53)))
+ )),
+ ("notAfter", Time(
+ ("utcTime", UTCTime(datetime(2010, 10, 8, 0, 25, 53)))
+ )),
+ ))
self.assertEqual(tbs["validity"], validity)
assert_raw_equals(tbs["validity"], validity)
self.assertEqual(tbs["subject"], issuer)
tbs = TBSCertificate()
tbs["serialNumber"] = CertificateSerialNumber(10143011886257155224)
- sign_algo_id = AlgorithmIdentifier()
- sign_algo_id["algorithm"] = ObjectIdentifier("1.2.840.113549.1.1.5")
- sign_algo_id["parameters"] = Any(Null())
+ sign_algo_id = AlgorithmIdentifier((
+ ("algorithm", ObjectIdentifier("1.2.840.113549.1.1.5")),
+ ("parameters", Any(Null())),
+ ))
tbs["signature"] = sign_algo_id
rdnSeq = RDNSequence()
("2.5.4.3", PrintableString, "false.example.com"),
("1.2.840.113549.1.9.1", IA5String, "false@example.com"),
):
- attr = AttributeTypeAndValue()
- attr["type"] = AttributeType(oid)
- attr["value"] = AttributeValue(klass(text))
- rdn = RelativeDistinguishedName()
- rdn.append(attr)
- rdnSeq.append(rdn)
+ rdnSeq.append(
+ RelativeDistinguishedName((
+ AttributeTypeAndValue((
+ ("type", AttributeType(oid)),
+ ("value", AttributeValue(klass(text))),
+ )),
+ ))
+ )
issuer = Name()
issuer["rdnSequence"] = rdnSeq
tbs["issuer"] = issuer
tbs["subject"] = issuer
- validity = Validity()
- validity["notBefore"] = Time(("utcTime", UTCTime(datetime(2009, 10, 8, 0, 25, 53))))
- validity["notAfter"] = Time(("utcTime", UTCTime(datetime(2010, 10, 8, 0, 25, 53))))
+ validity = Validity((
+ ("notBefore", Time(
+ ("utcTime", UTCTime(datetime(2009, 10, 8, 0, 25, 53)),),
+ )),
+ ("notAfter", Time(
+ ("utcTime", UTCTime(datetime(2010, 10, 8, 0, 25, 53)),),
+ )),
+ ))
tbs["validity"] = validity
spki = SubjectPublicKeyInfo()