rfc3447.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #
  2. # PKCS#1 syntax
  3. #
  4. # ASN.1 source from:
  5. # ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.asn
  6. #
  7. # Sample captures could be obtained with "openssl genrsa" command
  8. #
  9. from pyasn1_modules.rfc2437 import *
  10. class OtherPrimeInfo(univ.Sequence):
  11. componentType = namedtype.NamedTypes(
  12. namedtype.NamedType('prime', univ.Integer()),
  13. namedtype.NamedType('exponent', univ.Integer()),
  14. namedtype.NamedType('coefficient', univ.Integer())
  15. )
  16. class OtherPrimeInfos(univ.SequenceOf):
  17. componentType = OtherPrimeInfo()
  18. subtypeSpec = univ.SequenceOf.subtypeSpec + \
  19. constraint.ValueSizeConstraint(1, MAX)
  20. class RSAPrivateKey(univ.Sequence):
  21. componentType = namedtype.NamedTypes(
  22. namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues(('two-prime', 0), ('multi', 1)))),
  23. namedtype.NamedType('modulus', univ.Integer()),
  24. namedtype.NamedType('publicExponent', univ.Integer()),
  25. namedtype.NamedType('privateExponent', univ.Integer()),
  26. namedtype.NamedType('prime1', univ.Integer()),
  27. namedtype.NamedType('prime2', univ.Integer()),
  28. namedtype.NamedType('exponent1', univ.Integer()),
  29. namedtype.NamedType('exponent2', univ.Integer()),
  30. namedtype.NamedType('coefficient', univ.Integer()),
  31. namedtype.OptionalNamedType('otherPrimeInfos', OtherPrimeInfos())
  32. )