示例#1
0
文件: x509.py 项目: shuxin/tlsspy
class DirectoryString(univ.Choice):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType(
            'teletexString',
            char.TeletexString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            'printableString',
            char.PrintableString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            'universalString',
            char.UniversalString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            'utf8String',
            char.UTF8String().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            'bmpString',
            char.BMPString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            'ia5String',
            char.IA5String().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(
                    1, MAX)))  # hm, this should not be here!? XXX
    )
    to_python = generic.parse_directory_string
示例#2
0
class DirectoryString(univ.Choice):
    """ASN.1 Directory string class"""
    componentType = namedtype.NamedTypes(
        namedtype.NamedType(
            'teletexString',
            char.TeletexString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            'printableString',
            char.PrintableString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            'universalString',
            char.UniversalString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            'utf8String',
            char.UTF8String().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            'bmpString',
            char.BMPString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            'ia5String',
            char.IA5String().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
    )
示例#3
0
class DirectoryString(univ.Choice):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType(
            "teletexString",
            char.TeletexString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            "printableString",
            char.PrintableString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            "universalString",
            char.UniversalString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            "utf8String",
            char.UTF8String().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType(
            "bmpString",
            char.BMPString().subtype(
                subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
        namedtype.NamedType("ia5String",
                            char.IA5String().subtype(
                                subtypeSpec=constraint.ValueSizeConstraint(
                                    1, MAX)))  # hm, this should not be here!?
    )
示例#4
0
文件: rfc2459.py 项目: DT021/wau
class X520name(univ.Choice):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('teletexString', char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
        namedtype.NamedType('printableString', char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
        namedtype.NamedType('universalString', char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
        namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
        namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name)))
    )
示例#5
0
文件: Types.py 项目: kalloc/pyRFC5280
class DirectoryName(univ.Choice):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('teletexString', char.TeletexString()),
        namedtype.NamedType('printableString', char.PrintableString()),
        namedtype.NamedType('universalString', char.UniversalString()),
        namedtype.NamedType('utf8String', char.UTF8String()),
        namedtype.NamedType('bmpString', char.BMPString()),
    )
示例#6
0
class DirectoryString(univ.Choice):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType("teletexString", char.TeletexString()),
        namedtype.NamedType("printableString", char.PrintableString()),
        namedtype.NamedType("universalString", char.UniversalString()),
        namedtype.NamedType("utf8String", char.UTF8String()),
        namedtype.NamedType("bmpString", char.BMPString())
        #		namedtype.NamedType("ia5String", char.IA5String())
    )
示例#7
0
class DirectoryString(univ.Choice):
    """ASN.1 Directory string class"""
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('teletexString', char.TeletexString()),
        namedtype.NamedType('printableString', char.PrintableString()),
        namedtype.NamedType('universalString', char.UniversalString()),
        namedtype.NamedType('utf8String', char.UTF8String()),
        namedtype.NamedType('bmpString', char.BMPString()),
        namedtype.NamedType('ia5String', char.IA5String()),
    )
示例#8
0
文件: Types.py 项目: kalloc/pyRFC5280
class DirectoryString(univ.Choice):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('teletexString', char.TeletexString()),
        namedtype.NamedType('printableString', char.PrintableString()),
        namedtype.NamedType('universalString', char.UniversalString()),
        namedtype.NamedType('utf8String', char.UTF8String()),
        namedtype.NamedType('bmpString', char.BMPString()),
        namedtype.NamedType('ia5String', char.IA5String()),
        namedtype.NamedType('gString', univ.OctetString()))

    def __str__(self):
        return str(self.getComponentByPosition(self._currentIdx)).decode(
            'utf-8', 'ignore')

    def __repr__(self):
        return self.__str__()
示例#9
0
文件: Types.py 项目: kalloc/pyRFC5280
class DirectoryString(univ.Choice):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('teletexString', char.TeletexString()),
        namedtype.NamedType('printableString', char.PrintableString()),
        namedtype.NamedType('universalString', char.UniversalString()),
        namedtype.NamedType('utf8String', char.UTF8String()),
        namedtype.NamedType('bmpString', char.BMPString()),
        namedtype.NamedType('ia5String', char.IA5String()),
        namedtype.NamedType('gString', univ.OctetString()))

    def __repr__(self):
        try:
            c = self.getComponent()
            return c.__str__()
        except:
            return "Choice type not chosen"

    def __str__(self):
        return repr(self)
class DirectoryString(univ.Choice):    
    componentType = namedtype.NamedTypes(
        namedtype.NamedType('teletexString', char.TeletexString()),
        namedtype.NamedType('printableString', char.PrintableString()),
        namedtype.NamedType('universalString', char.UniversalString()),
        namedtype.NamedType('utf8String', char.UTF8String()),
        namedtype.NamedType('bmpString', char.BMPString()),
        namedtype.NamedType('ia5String', char.IA5String()), #for legacy pkcs9-email
        #namedtype.NamedType('gString', univ.OctetString()),
        namedtype.NamedType('bitString', univ.BitString()), #needed for X500 Unique Identifier, RFC 4519
        )
    def __repr__(self):
        try:
          c = self.getComponent()
          return c.__str__()
        except:
          return "Choice type not chosen"
    def __str__(self):
        return repr(self)
示例#11
0
class DirectoryString(univ.Choice):
    pass


DirectoryString.componentType = namedtype.NamedTypes(
    namedtype.NamedType(
        'teletexString',
        char.TeletexString().subtype(
            subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType(
        'printableString',
        char.PrintableString().subtype(
            subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType(
        'universalString',
        char.UniversalString().subtype(
            subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType(
        'utf8String',
        char.UTF8String().subtype(
            subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType(
        'bmpString',
        char.BMPString().subtype(
            subtypeSpec=constraint.ValueSizeConstraint(1, 255))))

# PKCS9String is DirectoryString with an additional choice of IA5String,
# and the SIZE is limited to 255


class PKCS9String(univ.Choice):
    pass
示例#12
0
        subtypeSpec=constraint.ValueSizeConstraint(1, ub_unformatted_address_length)))
)

ub_organization_name = univ.Integer(64)


class X520OrganizationName(univ.Choice):
    pass


X520OrganizationName.componentType = namedtype.NamedTypes(
    namedtype.NamedType('teletexString', char.TeletexString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
    namedtype.NamedType('printableString', char.PrintableString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
    namedtype.NamedType('universalString', char.UniversalString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
    namedtype.NamedType('utf8String',
                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
    namedtype.NamedType('bmpString',
                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name)))
)

ub_x121_address_length = univ.Integer(16)

pds_name = univ.Integer(7)

id_pkix = _buildOid(1, 3, 6, 1, 5, 5, 7)

id_kp = _buildOid(id_pkix, 3)

ub_postal_code_length = univ.Integer(16)
示例#13
0
 def testDecoder(self):
     assert decoder.decode(
         ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0,
                    99))) == (char.UniversalString(
                        sys.version_info[0] == 3 and 'abc'
                        or unicode('abc')), null)
示例#14
0
class UniversalStringDecoder(OctetStringDecoder):
    protoComponent = char.UniversalString()
示例#15
0
print(dump(bytes))

print("ENUMERATED 5")
bytes = ber_encode(univ.Enumerated(5))
print(dump(bytes))

print("ENUMERATED 90000")
bytes = ber_encode(univ.Enumerated(90000))
print(dump(bytes))

print("BMPString 'HENLO BORTHERS'")
bytes = ber_encode(char.BMPString("HENLO BORTHERS"))
print(dump(bytes))

print("UniversalString 'HENLO BORTHERS'")
bytes = ber_encode(char.UniversalString("HENLO BORTHERS"))
print(dump(bytes))

print("\n")

# CER

print("*** CANONICAL ENCODING RULES ***")

print("BOOLEAN True")
bytes = cer_encode(univ.Boolean(True))
print(dump(bytes))

print("BOOLEAN False")
bytes = cer_encode(univ.Boolean(False))
print(dump(bytes))
示例#16
0
 def testEncoding(self):
     assert encoder.encode(
         char.UniversalString(version_info[0] == 3 and 'abc'
                              or unicode('abc'))) == ints2octs(
                                  (28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0,
                                   0, 0, 99)), 'Incorrect encoding'
示例#17
0
# attrValues SET must have one and only one member

Attribute = rfc7191.SingleAttribute


# DirectoryString is the same as RFC 5280, except the length is limited to 255

class DirectoryString(univ.Choice):
    pass

DirectoryString.componentType = namedtype.NamedTypes(
    namedtype.NamedType('teletexString', char.TeletexString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType('printableString', char.PrintableString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType('universalString', char.UniversalString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType('utf8String', char.UTF8String().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
    namedtype.NamedType('bmpString', char.BMPString().subtype(
        subtypeSpec=constraint.ValueSizeConstraint(1, 255)))
)


# OTP Challenge Attribute

id_aa_otpChallenge = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.56')

ub_aa_otpChallenge = univ.Integer(255)

otpChallenge = Attribute()
otpChallenge['attrType'] = id_aa_otpChallenge