rfc2986.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # coding: utf-8
  2. #
  3. # This file is part of pyasn1-modules software.
  4. #
  5. # Created by Joel Johnson with asn1ate tool.
  6. # Modified by Russ Housley to add support for opentypes by importing
  7. # definitions from rfc5280 so that the same maps are used.
  8. #
  9. # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
  10. # License: http://snmplabs.com/pyasn1/license.html
  11. #
  12. # PKCS #10: Certification Request Syntax Specification
  13. #
  14. # ASN.1 source from:
  15. # https://www.rfc-editor.org/rfc/rfc2986.txt
  16. #
  17. from pyasn1.type import namedtype
  18. from pyasn1.type import tag
  19. from pyasn1.type import univ
  20. from pyasn1_modules import rfc5280
  21. MAX = float('inf')
  22. AttributeType = rfc5280.AttributeType
  23. AttributeValue = rfc5280.AttributeValue
  24. AttributeTypeAndValue = rfc5280.AttributeTypeAndValue
  25. Attribute = rfc5280.Attribute
  26. RelativeDistinguishedName = rfc5280.RelativeDistinguishedName
  27. RDNSequence = rfc5280.RDNSequence
  28. Name = rfc5280.Name
  29. AlgorithmIdentifier = rfc5280.AlgorithmIdentifier
  30. SubjectPublicKeyInfo = rfc5280.SubjectPublicKeyInfo
  31. class Attributes(univ.SetOf):
  32. pass
  33. Attributes.componentType = Attribute()
  34. class CertificationRequestInfo(univ.Sequence):
  35. pass
  36. CertificationRequestInfo.componentType = namedtype.NamedTypes(
  37. namedtype.NamedType('version', univ.Integer()),
  38. namedtype.NamedType('subject', Name()),
  39. namedtype.NamedType('subjectPKInfo', SubjectPublicKeyInfo()),
  40. namedtype.NamedType('attributes',
  41. Attributes().subtype(implicitTag=tag.Tag(
  42. tag.tagClassContext, tag.tagFormatSimple, 0))
  43. )
  44. )
  45. class CertificationRequest(univ.Sequence):
  46. pass
  47. CertificationRequest.componentType = namedtype.NamedTypes(
  48. namedtype.NamedType('certificationRequestInfo', CertificationRequestInfo()),
  49. namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
  50. namedtype.NamedType('signature', univ.BitString())
  51. )