Esempio n. 1
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!? XXX
    )
    to_python = generic.parse_directory_string
Esempio n. 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))),
    )
Esempio n. 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!?
    )
Esempio n. 4
0
File: rfc2459.py Progetto: 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)))
    )
Esempio n. 5
0
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()),
    )
Esempio n. 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())
    )
Esempio n. 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()),
    )
Esempio n. 8
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()),
        namedtype.NamedType('gString', univ.OctetString()))

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

    def __repr__(self):
        return self.__str__()
Esempio n. 9
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()),
        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)
Esempio n. 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
Esempio n. 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)
Esempio n. 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)
Esempio n. 14
0
class UniversalStringDecoder(OctetStringDecoder):
    protoComponent = char.UniversalString()
Esempio n. 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))
Esempio n. 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'
Esempio n. 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