rfc7894.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #
  2. # This file is part of pyasn1-modules software.
  3. #
  4. # Created by Russ Housley.
  5. #
  6. # Copyright (c) 2019, Vigil Security, LLC
  7. # License: http://snmplabs.com/pyasn1/license.html
  8. #
  9. # Alternative Challenge Password Attributes for EST
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc7894.txt
  13. #
  14. from pyasn1.type import char
  15. from pyasn1.type import constraint
  16. from pyasn1.type import namedtype
  17. from pyasn1.type import univ
  18. from pyasn1_modules import rfc5652
  19. from pyasn1_modules import rfc6402
  20. from pyasn1_modules import rfc7191
  21. # SingleAttribute is the same as Attribute in RFC 5652, except that the
  22. # attrValues SET must have one and only one member
  23. Attribute = rfc7191.SingleAttribute
  24. # DirectoryString is the same as RFC 5280, except the length is limited to 255
  25. class DirectoryString(univ.Choice):
  26. pass
  27. DirectoryString.componentType = namedtype.NamedTypes(
  28. namedtype.NamedType('teletexString', char.TeletexString().subtype(
  29. subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
  30. namedtype.NamedType('printableString', char.PrintableString().subtype(
  31. subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
  32. namedtype.NamedType('universalString', char.UniversalString().subtype(
  33. subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
  34. namedtype.NamedType('utf8String', char.UTF8String().subtype(
  35. subtypeSpec=constraint.ValueSizeConstraint(1, 255))),
  36. namedtype.NamedType('bmpString', char.BMPString().subtype(
  37. subtypeSpec=constraint.ValueSizeConstraint(1, 255)))
  38. )
  39. # OTP Challenge Attribute
  40. id_aa_otpChallenge = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.56')
  41. ub_aa_otpChallenge = univ.Integer(255)
  42. otpChallenge = Attribute()
  43. otpChallenge['attrType'] = id_aa_otpChallenge
  44. otpChallenge['attrValues'][0] = DirectoryString()
  45. # Revocation Challenge Attribute
  46. id_aa_revocationChallenge = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.57')
  47. ub_aa_revocationChallenge = univ.Integer(255)
  48. revocationChallenge = Attribute()
  49. revocationChallenge['attrType'] = id_aa_revocationChallenge
  50. revocationChallenge['attrValues'][0] = DirectoryString()
  51. # EST Identity Linking Attribute
  52. id_aa_estIdentityLinking = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.58')
  53. ub_aa_est_identity_linking = univ.Integer(255)
  54. estIdentityLinking = Attribute()
  55. estIdentityLinking['attrType'] = id_aa_estIdentityLinking
  56. estIdentityLinking['attrValues'][0] = DirectoryString()
  57. # Map of Attribute Type OIDs to Attributes added to the
  58. # ones that are in rfc6402.py
  59. _cmcControlAttributesMapUpdate = {
  60. id_aa_otpChallenge: DirectoryString(),
  61. id_aa_revocationChallenge: DirectoryString(),
  62. id_aa_estIdentityLinking: DirectoryString(),
  63. }
  64. rfc6402.cmcControlAttributesMap.update(_cmcControlAttributesMapUpdate)