1 # 2 # This file is part of pyasn1-modules software. 3 # 4 # Copyright (c) 2005-2017, Ilya Etingof <etingof (at] gmail.com> 5 # License: http://pyasn1.sf.net/license.html 6 # 7 # PKCS#1 syntax 8 # 9 # ASN.1 source from: 10 # ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.asn 11 # 12 # Sample captures could be obtained with "openssl genrsa" command 13 # 14 from pyasn1.type import constraint 15 from pyasn1.type import namedval 16 17 from pyasn1_modules.rfc2437 import * 18 19 20 class OtherPrimeInfo(univ.Sequence): 21 componentType = namedtype.NamedTypes( 22 namedtype.NamedType('prime', univ.Integer()), 23 namedtype.NamedType('exponent', univ.Integer()), 24 namedtype.NamedType('coefficient', univ.Integer()) 25 ) 26 27 28 class OtherPrimeInfos(univ.SequenceOf): 29 componentType = OtherPrimeInfo() 30 subtypeSpec = univ.SequenceOf.subtypeSpec + constraint.ValueSizeConstraint(1, MAX) 31 32 33 class RSAPrivateKey(univ.Sequence): 34 componentType = namedtype.NamedTypes( 35 namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues(('two-prime', 0), ('multi', 1)))), 36 namedtype.NamedType('modulus', univ.Integer()), 37 namedtype.NamedType('publicExponent', univ.Integer()), 38 namedtype.NamedType('privateExponent', univ.Integer()), 39 namedtype.NamedType('prime1', univ.Integer()), 40 namedtype.NamedType('prime2', univ.Integer()), 41 namedtype.NamedType('exponent1', univ.Integer()), 42 namedtype.NamedType('exponent2', univ.Integer()), 43 namedtype.NamedType('coefficient', univ.Integer()), 44 namedtype.OptionalNamedType('otherPrimeInfos', OtherPrimeInfos()) 45 ) 46