class HashContent(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('userPassword', char.UTF8String()), namedtype.NamedType('authorityRandom', univ.OctetString()), namedtype.NamedType('identifierType', univ.ObjectIdentifier()), namedtype.NamedType('identifier', char.UTF8String()) )
class RelaxedDisplayText(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType("ia5String", char.IA5String()), namedtype.NamedType("visibleString", char.VisibleString()), namedtype.NamedType("bmpString", char.BMPString()), namedtype.NamedType("utf8String", char.UTF8String()), )
class _FirstKey(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType("algorithm_id", univ.OctetString()), namedtype.NamedType("str_key_id", char.UTF8String()), namedtype.NamedType("public_key", _PublicKey()), namedtype.NamedType("parameters", _Parameters()), namedtype.NamedType("ciphertext", _Ciphertext()))
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
class JWTClaimValues(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('claim', JWTClaimName()), namedtype.NamedType( 'values', univ.SequenceOf(componentType=char.UTF8String()).subtype( sizeSpec=constraint.ValueSizeConstraint(1, MAX))))
class ResponseStatus(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.DefaultedNamedType('statusCode', CVStatusCode().subtype(value='okay')), namedtype.OptionalNamedType('errorMessage', char.UTF8String()) )
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!? )
class CVRequest(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.DefaultedNamedType('cvRequestVersion', univ.Integer().subtype(value=1)), namedtype.NamedType('query', Query()), namedtype.OptionalNamedType('requestorRef', GeneralNames().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.OptionalNamedType('requestNonce', univ.OctetString().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.OptionalNamedType('requestorName', GeneralName().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 2))), namedtype.OptionalNamedType('responderName', GeneralName().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 3))), namedtype.OptionalNamedType('requestExtensions', Extensions().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 4))), namedtype.OptionalNamedType('signatureAlg', AlgorithmIdentifier().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 5))), namedtype.OptionalNamedType('hashAlg', univ.ObjectIdentifier().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 6))), namedtype.OptionalNamedType('requestorText', char.UTF8String().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, 256)).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))) )
class PKIFreeText(univ.SequenceOf): """ PKIFreeText ::= SEQUENCE SIZE (1..MAX) OF UTF8String """ componentType = char.UTF8String() sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint( 1, MAX)
class DisplayText(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('visibleString', char.VisibleString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))), namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))), namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))) )
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))), )
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()), )
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))) )
class FrogTip(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('number', univ.Integer()), namedtype.NamedType('tip', char.UTF8String()), ) @staticmethod def from_tip(tip): return FrogTip().setComponents(tip['number'], tip['tip'])
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()) )
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()), )
class IetfAttrSyntax(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('policyAuthority', GeneralNames().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType('values', univ.SequenceOf( componentType=univ.Choice(componentType=namedtype.NamedTypes( namedtype.NamedType('octets', univ.OctetString()), namedtype.NamedType('oid', univ.ObjectIdentifier()), namedtype.NamedType('string', char.UTF8String()) )) )) )
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__()
class CVResponse(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('cvResponseVersion', univ.Integer()), namedtype.NamedType('serverConfigurationID', univ.Integer()), namedtype.NamedType('producedAt', useful.GeneralizedTime()), namedtype.NamedType('responseStatus', ResponseStatus()), namedtype.OptionalNamedType( 'respValidationPolicy', RespValidationPolicy().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 0))), namedtype.OptionalNamedType( 'requestRef', RequestReference().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 1))), namedtype.OptionalNamedType( 'requestorRef', GeneralNames().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 2))), namedtype.OptionalNamedType( 'requestorName', GeneralNames().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 3))), namedtype.OptionalNamedType( 'replyObjects', ReplyObjects().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 4))), namedtype.OptionalNamedType( 'respNonce', univ.OctetString().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 5))), namedtype.OptionalNamedType( 'serverContextInfo', univ.OctetString().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 6))), namedtype.OptionalNamedType( 'cvResponseExtensions', Extensions().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))), namedtype.OptionalNamedType( 'requestorText', char.UTF8String().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, 256)).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8))))
class DisplayText(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType( 'ia5String', char.IA5String().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 0x0))), namedtype.NamedType( 'visibleString', char.VisibleString().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 0x1))), namedtype.NamedType( 'bmpString', char.BMPString().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 0x2))), namedtype.NamedType( 'utf8String', char.UTF8String().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatConstructed, 0x3))), )
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)
def set_q_defaults(params, insert_zeroes=False): if insert_zeroes: attrs = params.get('Attributes', [])[:] defaults = { '1.2.643.100.1': '0' * 13, '1.2.643.100.3': '0' * 11, '1.2.643.3.131.1.1': '0' * 12, } for oid in defaults: if not _deep_find(attrs, oid): attrs.append((oid, defaults[oid])) params['Attributes'] = attrs raw = params.get('RawExtensions', [])[:] if not any(oid == '1.2.643.100.111' for (oid, _, _) in raw): extstr = encoder.encode( char.UTF8String('"КриптоПро CSP" (версия 4.0)'.encode('utf-8'))) raw.append(('1.2.643.100.111', extstr, False)) params['RawExtensions'] = raw
def __init__(self, type_id, value): super(UPN, self).__init__(type_id, value) self.name = unicode( decoder.decode(value, asn1Spec=char.UTF8String())[0])
TrustAnchorInfo.componentType = namedtype.NamedTypes( namedtype.DefaultedNamedType('version', TrustAnchorInfoVersion().subtype(value='v1')), namedtype.NamedType('pubKey', SubjectPublicKeyInfo()), namedtype.NamedType('keyId', KeyIdentifier()), namedtype.OptionalNamedType('taTitle', TrustAnchorTitle()), namedtype.OptionalNamedType('certPath', CertPathControls()), namedtype.OptionalNamedType( 'exts', Extensions().subtype( explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.OptionalNamedType( 'taTitleLangTag', char.UTF8String().subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))) class TrustAnchorChoice(univ.Choice): pass TrustAnchorChoice.componentType = namedtype.NamedTypes( namedtype.NamedType('certificate', Certificate()), namedtype.NamedType( 'tbsCert', TBSCertificate().subtype( explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.NamedType( 'taInfo', TrustAnchorInfo().subtype(explicitTag=tag.Tag(
class SuppLangTagsValue(univ.SequenceOf): """ SuppLangTagsValue ::= SEQUENCE OF UTF8String """ componentType = char.UTF8String()
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 PKCS9String.componentType = namedtype.NamedTypes( namedtype.NamedType(
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)
class SvceAuthInfo(univ.Sequence): pass SvceAuthInfo.componentType = namedtype.NamedTypes( namedtype.NamedType('service', rfc3280.GeneralName()), namedtype.NamedType('ident', rfc3280.GeneralName()), namedtype.OptionalNamedType('authInfo', univ.OctetString())) class IetfAttrSyntax(univ.Sequence): pass IetfAttrSyntax.componentType = namedtype.NamedTypes( namedtype.OptionalNamedType( 'policyAuthority', rfc3280.GeneralNames().subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType( 'values', univ.SequenceOf(componentType=univ.Choice( componentType=namedtype.NamedTypes( namedtype.NamedType('octets', univ.OctetString()), namedtype.NamedType('oid', univ.ObjectIdentifier()), namedtype.NamedType('string', char.UTF8String())))))) id_aca_encAttrs = _buildOid(id_aca, 6)
class FrogTip(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('number', univ.Integer()), namedtype.NamedType('tip', char.UTF8String()), )