class BuiltInDomainDefinedAttribute(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('type', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))), namedtype.NamedType('value', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length))) )
def generate_user_controller_access_token(username, controller_endpoints, secret_key, controller_name): """" Implement in python what is currently done in GO https://github.com/juju/juju/blob/a5ab92ec9b7f5da3678d9ac603fe52d45af24412/cmd/juju/user/utils.go#L16 :param username: name of the user to register :param controller_endpoints: juju controller endpoints list in the format <ip>:<port> :param secret_key: base64 encoded string of the secret-key generated by juju :param controller_name: name of the controller to register to. """ # Secret key is returned as base64 encoded string in: # https://websockets.readthedocs.io/en/stable/_modules/websockets/protocol.html#WebSocketCommonProtocol.recv # Deconding it before marshalling into the ASN.1 message secret_key = base64.b64decode(secret_key) addr = Addrs() for endpoint in controller_endpoints: addr.append(endpoint) registration_string = RegistrationInfo() registration_string.setComponentByPosition(0, char.PrintableString(username)) registration_string.setComponentByPosition(1, addr) registration_string.setComponentByPosition(2, univ.OctetString(secret_key)) registration_string.setComponentByPosition( 3, char.PrintableString(controller_name)) registration_string = encode(registration_string) remainder = len(registration_string) % 3 registration_string += b"\0" * (3 - remainder) return base64.urlsafe_b64encode(registration_string)
class PersonalName(univ.Set): componentType = namedtype.NamedTypes( namedtype.NamedType( 'surname', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint( 1, ub_surname_length), explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.OptionalNamedType( 'given-name', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint( 1, ub_given_name_length), explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.OptionalNamedType( 'initials', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint( 1, ub_initials_length), explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))), namedtype.OptionalNamedType( 'generation-qualifier', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint( 1, ub_generation_qualifier_length), explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))))
def testOpenTypes(self): algorithmIdentifierMapUpdate = { univ.ObjectIdentifier('1.2.840.113549.1.1.1'): univ.Null(""), univ.ObjectIdentifier('1.2.840.113549.1.1.5'): univ.Null(""), univ.ObjectIdentifier('1.2.840.113549.1.1.11'): univ.Null(""), } rfc5280.algorithmIdentifierMap.update(algorithmIdentifierMapUpdate) substrate = pem.readBase64fromText(self.pem_text) asn1Object, rest = der_decoder.decode( substrate, asn1Spec=rfc2986.CertificationRequest(), decodeOpenTypes=True) assert not rest assert asn1Object.prettyPrint() assert der_encoder.encode(asn1Object) == substrate for rdn in asn1Object['certificationRequestInfo']['subject'][ 'rdnSequence']: for atv in rdn: if atv['type'] == rfc5280.id_at_countryName: assert atv['value'] == char.PrintableString('US') else: assert len(atv['value']['utf8String']) > 2 spki_alg = asn1Object['certificationRequestInfo']['subjectPKInfo'][ 'algorithm'] assert spki_alg['parameters'] == univ.Null("") sig_alg = asn1Object['signatureAlgorithm'] assert sig_alg['parameters'] == univ.Null("")
class PrivateDomainName(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('numeric', char.NumericString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length))), namedtype.NamedType('printable', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length))) )
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))), )
def testOpenTypes(self): openTypesMap = { univ.ObjectIdentifier('1.2.840.113549.1.1.1'): univ.Null(""), univ.ObjectIdentifier('1.2.840.113549.1.1.5'): univ.Null(""), univ.ObjectIdentifier('1.2.840.113549.1.1.11'): univ.Null(""), } substrate = pem.readBase64fromText(self.pem_text) asn1Object, rest = der_decoder(substrate, asn1Spec=rfc2986.CertificationRequest(), openTypes=openTypesMap, decodeOpenTypes=True) self.assertFalse(rest) self.assertTrue(asn1Object.prettyPrint()) self.assertEqual(substrate, der_encoder(asn1Object)) for rdn in asn1Object['certificationRequestInfo']['subject'][ 'rdnSequence']: for atv in rdn: if atv['type'] == rfc5280.id_at_countryName: self.assertEqual(char.PrintableString('US'), atv['value']) else: self.assertGreater(len(atv['value']['utf8String']), 2) spki_alg = asn1Object['certificationRequestInfo']['subjectPKInfo'][ 'algorithm'] self.assertEqual(univ.Null(""), spki_alg['parameters']) sig_alg = asn1Object['signatureAlgorithm'] self.assertEqual(univ.Null(""), sig_alg['parameters'])
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 DirectoryString(Choice): componentType = pyasn1.type.namedtype.NamedTypes( pyasn1.type.namedtype.NamedType( 'teletexString', pyasn1.type.char.TeletexString().subtype( subtypeSpec=pyasn1.type.constraint.ValueSizeConstraint(1, MAX))), pyasn1.type.namedtype.NamedType( 'printableString', char.PrintableString().subtype(subtypeSpec=pyasn1.type.constraint. ValueSizeConstraint(1, MAX))), pyasn1.type.namedtype.NamedType( 'universalString', pyasn1.type.char.UniversalString().subtype( subtypeSpec=pyasn1.type.constraint.ValueSizeConstraint(1, MAX))), pyasn1.type.namedtype.NamedType( 'utf8String', pyasn1.type.char.UTF8String().subtype( subtypeSpec=pyasn1.type.constraint.ValueSizeConstraint(1, MAX))), pyasn1.type.namedtype.NamedType( 'bmpString', pyasn1.type.char.BMPString().subtype( subtypeSpec=pyasn1.type.constraint.ValueSizeConstraint(1, MAX))), pyasn1.type.namedtype.NamedType( 'ia5String', pyasn1.type.char.IA5String().subtype( subtypeSpec=pyasn1.type.constraint.ValueSizeConstraint(1, MAX))))
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 PostalCode(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('numeric-code', char.NumericString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length))), namedtype.NamedType('printable-code', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length))) )
class PDSParameter(univ.Set): componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('printable-string', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length))), namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length))) )
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 AdministrationDomainName(univ.Choice): tagSet = univ.Choice.tagSet.tagExplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 2) ) componentType = namedtype.NamedTypes( namedtype.NamedType('numeric', char.NumericString().subtype(subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length))), namedtype.NamedType('printable', char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length))) )
class PhysicalDeliveryCountryName(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('x121-dcc-code', char.NumericString().subtype( subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))), namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length))) )
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 CountryName(univ.Choice): tagSet = univ.Choice.tagSet.tagExplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 1) ) componentType = namedtype.NamedTypes( namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))), namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length))) )
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 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 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)
class PrintableStringDecoder(OctetStringDecoder): protoComponent = char.PrintableString()
def generate(self, sCN, sEmail): logging.debug("generate") # Version version = Version(2) now = datetime.utcnow() - timedelta(days=1) strnow = now.strftime('%y%m%d%H%M%S') #Serial Number sn = int(strnow) self.SerialNumber = univ.Integer(sn) # Validity notBefore = now notAfter = notBefore + timedelta(days=365*30) strNotBefore = strnow + 'Z' strNotAfter = notAfter.strftime('%y%m%d%H%M%S') + 'Z' validity = Validity() t1 = Time() t1.setComponentByName('utcTime', strNotBefore) validity.setComponentByName('notBefore', t1) t2 = Time() t2.setComponentByName('utcTime', strNotAfter) validity.setComponentByName('notAfter', t2) # CommonName commonname = AttributeTypeAndValue() commonname.setComponentByName('type', AttributeType(univ.ObjectIdentifier('2.5.4.3'))) commonname.setComponentByPosition(1, char.PrintableString(sCN)) rdn = RelativeDistinguishedName() rdn.setComponentByPosition(0,commonname) rdnseq = RDNSequence() rdnseq.setComponentByPosition(0,rdn) self.SubjectSeq.setComponentByName('',rdnseq) # Email ## idmail = univ.ObjectIdentifier('1.2.840.113549.1.9.1') ## smail = char.PrintableString(sEmail) ## mail = univ.Sequence() ## mail.setComponentByPosition(0, idmail) ## mail.setComponentByPosition(1, smail) ## ## mailsetof = univ.Set() ## mailsetof.setComponentByPosition(0,mail) ## ## self.SubjectSeq.setComponentByPosition(1,mailsetof) # rsaEncryption identifier: idrsaencryption = univ.ObjectIdentifier('1.2.840.113549.1.1.1') # AlgorithmIdentifier for rsaEncryption rsaalgid = AlgorithmIdentifier() rsaalgid.setComponentByName('algorithm', idrsaencryption) rsaalgid.setComponentByName('parameters', univ.Null()) logging.debug("generate RSA") # Get a RSAPublicKey structure pkinfo = univ.Sequence() self.rsakey = generateRSAKey(1024,["python"]) pkinfo.setComponentByPosition(0, univ.Integer(self.rsakey.n)) pkinfo.setComponentByPosition(1, univ.Integer(self.rsakey.e)) # Encode the public key info as a bit string pklong = long(pyasn1.codec.der.encoder.encode(pkinfo).encode('hex'), 16) pkbitstring = univ.BitString("'00%s'B" % self.toBitString_(pklong)) #SubjectPublicKeyInfo structure publickeyinfo = SubjectPublicKeyInfo() publickeyinfo.setComponentByName('algorithm', rsaalgid) publickeyinfo.setComponentByName('subjectPublicKey', pkbitstring) # AlgorithmIdentifier for RSAEncryption #hashwithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.4') hashwithRSAEncryption = univ.ObjectIdentifier('1.2.840.113549.1.1.5') #algid = univ.Sequence() algid = AlgorithmIdentifier() algid.setComponentByName('algorithm',hashwithRSAEncryption) algid.setComponentByName('parameters', univ.Null()) # TBSCertificate tbsCertificate = TBSCertificate() tbsCertificate.setComponentByName('version', 2) tbsCertificate.setComponentByName('serialNumber', self.SerialNumber) tbsCertificate.setComponentByName('signature', algid) tbsCertificate.setComponentByName('issuer', self.SubjectSeq) tbsCertificate.setComponentByName('validity', validity) tbsCertificate.setComponentByName('subject', self.SubjectSeq) tbsCertificate.setComponentByName('subjectPublicKeyInfo', publickeyinfo) logging.debug("calc x509 hash") # Encode the tbsCertificate sequence into ASN.1 signature_bytes = self.rsakey.hashAndSign(pyasn1.codec.der.encoder.encode(tbsCertificate)) strsig = array.array.tostring(signature_bytes); sigbitstring = univ.BitString("'%s'B" % self.BytesToBin(strsig)) self.x509.setComponentByName('tbsCertificate', tbsCertificate) self.x509.setComponentByName('signatureAlgorithm', algid) self.x509.setComponentByName('signatureValue', sigbitstring) logging.debug("generate END")
# SingleAttribute is the same as Attribute in RFC 5652, except that the # 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)
ub_privacy_mark_length = univ.Integer(128) ub_security_categories = univ.Integer(64) ub_integer_options = univ.Integer(256) class ESSPrivacyMark(univ.Choice): pass ESSPrivacyMark.componentType = namedtype.NamedTypes( namedtype.NamedType( 'pString', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint( 1, ub_privacy_mark_length))), namedtype.NamedType( 'utf8String', char.UTF8String().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))) class SecurityClassification(univ.Integer): pass SecurityClassification.subtypeSpec = constraint.ValueRangeConstraint( 0, ub_integer_options) SecurityClassification.namedValues = namedval.NamedValues(
class AuthenticatedAttributes(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('target', char.PrintableString()), namedtype.NamedType('length', univ.Integer()))
physical_delivery_personal_name = univ.Integer(13) ub_unformatted_address_length = univ.Integer(180) ub_pds_parameter_length = univ.Integer(30) ub_pds_physical_address_lines = univ.Integer(6) class UnformattedPostalAddress(univ.Set): pass UnformattedPostalAddress.componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('printable-address', univ.SequenceOf(componentType=char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))), namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype( 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(
# 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)))) # PKCS9String is DirectoryString with an additional choice of IA5String, # and the SIZE is limited to 255
class UnformattedPostalAddress(univ.Set): componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('printable-address', univ.SequenceOf(componentType=char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)).subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_physical_address_lines)))), namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_unformatted_address_length))) )