Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rfc2986.py 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # coding: utf-8
  2. #
  3. # This file is part of pyasn1-modules software.
  4. #
  5. # Created by Joel Johnson with asn1ate tool.
  6. # Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
  7. # License: http://snmplabs.com/pyasn1/license.html
  8. #
  9. # PKCS #10: Certification Request Syntax Specification
  10. #
  11. # ASN.1 source from:
  12. # http://www.ietf.org/rfc/rfc2986.txt
  13. #
  14. from pyasn1.type import univ
  15. from pyasn1.type import char
  16. from pyasn1.type import namedtype
  17. from pyasn1.type import namedval
  18. from pyasn1.type import opentype
  19. from pyasn1.type import tag
  20. from pyasn1.type import constraint
  21. from pyasn1.type import useful
  22. MAX = float('inf')
  23. class AttributeType(univ.ObjectIdentifier):
  24. pass
  25. class AttributeValue(univ.Any):
  26. pass
  27. certificateAttributesMap = {}
  28. class AttributeTypeAndValue(univ.Sequence):
  29. componentType = namedtype.NamedTypes(
  30. namedtype.NamedType('type', AttributeType()),
  31. namedtype.NamedType(
  32. 'value', AttributeValue(),
  33. openType=opentype.OpenType('type', certificateAttributesMap)
  34. )
  35. )
  36. class Attribute(univ.Sequence):
  37. componentType = namedtype.NamedTypes(
  38. namedtype.NamedType('type', AttributeType()),
  39. namedtype.NamedType('values',
  40. univ.SetOf(componentType=AttributeValue()),
  41. openType=opentype.OpenType('type', certificateAttributesMap))
  42. )
  43. class Attributes(univ.SetOf):
  44. pass
  45. Attributes.componentType = Attribute()
  46. class RelativeDistinguishedName(univ.SetOf):
  47. pass
  48. RelativeDistinguishedName.componentType = AttributeTypeAndValue()
  49. RelativeDistinguishedName.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  50. class RDNSequence(univ.SequenceOf):
  51. pass
  52. RDNSequence.componentType = RelativeDistinguishedName()
  53. class Name(univ.Choice):
  54. pass
  55. Name.componentType = namedtype.NamedTypes(
  56. namedtype.NamedType('rdnSequence', RDNSequence())
  57. )
  58. class AlgorithmIdentifier(univ.Sequence):
  59. componentType = namedtype.NamedTypes(
  60. namedtype.NamedType('algorithm', univ.ObjectIdentifier()),
  61. namedtype.OptionalNamedType('parameters', univ.Any())
  62. )
  63. class SubjectPublicKeyInfo(univ.Sequence):
  64. pass
  65. SubjectPublicKeyInfo.componentType = namedtype.NamedTypes(
  66. namedtype.NamedType('algorithm', AlgorithmIdentifier()),
  67. namedtype.NamedType('subjectPublicKey', univ.BitString())
  68. )
  69. class CertificationRequestInfo(univ.Sequence):
  70. pass
  71. CertificationRequestInfo.componentType = namedtype.NamedTypes(
  72. namedtype.NamedType('version', univ.Integer()),
  73. namedtype.NamedType('subject', Name()),
  74. namedtype.NamedType('subjectPKInfo', SubjectPublicKeyInfo()),
  75. namedtype.NamedType('attributes', Attributes().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
  76. )
  77. class CertificationRequest(univ.Sequence):
  78. pass
  79. CertificationRequest.componentType = namedtype.NamedTypes(
  80. namedtype.NamedType('certificationRequestInfo', CertificationRequestInfo()),
  81. namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
  82. namedtype.NamedType('signature', univ.BitString())
  83. )