Beispiel #1
0
class X509_ExtPrivateKeyUsagePeriod(ASN1_Packet):
    ASN1_codec = ASN1_Codecs.BER
    ASN1_root = ASN1F_SEQUENCE(
        ASN1F_optional(
            ASN1F_GENERALIZED_TIME("notBefore",
                                   str(GeneralizedTime(-600)),
                                   implicit_tag=0x80)),
        ASN1F_optional(
            ASN1F_GENERALIZED_TIME("notAfter",
                                   str(GeneralizedTime(+86400)),
                                   implicit_tag=0x81)))
Beispiel #2
0
class OCSP_ResponseData(ASN1_Packet):
    ASN1_codec = ASN1_Codecs.BER
    ASN1_root = ASN1F_SEQUENCE(
        ASN1F_optional(
            ASN1F_enum_INTEGER("version", 0, {0: "v1"}, explicit_tag=0x80)),
        ASN1F_PACKET("responderID", OCSP_ResponderID(), OCSP_ResponderID),
        ASN1F_GENERALIZED_TIME("producedAt", str(GeneralizedTime())),
        ASN1F_SEQUENCE_OF("responses", [], OCSP_SingleResponse),
        ASN1F_optional(
            ASN1F_SEQUENCE_OF("responseExtensions",
                              None,
                              X509_Extension,
                              explicit_tag=0xa1)))
Beispiel #3
0
 def _fix(self, n=0):
     o = random.choice(self.objlist)
     if issubclass(o, ASN1_INTEGER):
         return o(int(random.gauss(0, 1000)))
     elif issubclass(o, ASN1_IPADDRESS):
         z = RandIP()._fix()
         return o(z)
     elif issubclass(o, ASN1_GENERALIZED_TIME) or issubclass(o, ASN1_UTC_TIME):  # noqa: E501
         z = GeneralizedTime()._fix()
         return o(z)
     elif issubclass(o, ASN1_STRING):
         z = int(random.expovariate(0.05) + 1)
         return o("".join(random.choice(self.chars) for _ in range(z)))
     elif issubclass(o, ASN1_SEQUENCE) and (n < 10):
         z = int(random.expovariate(0.08) + 1)
         return o([self.__class__(objlist=self.objlist)._fix(n + 1)
                   for _ in range(z)])
     return ASN1_INTEGER(int(random.gauss(0, 1000)))
Beispiel #4
0
 def randval(self):
     return GeneralizedTime()
Beispiel #5
0
 def randval(self):
     # type: () -> GeneralizedTime
     return GeneralizedTime()