rfc4683.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #
  2. # This file is part of pyasn1-modules software.
  3. #
  4. # Created by Russ Housley with assistance from asn1ate v.0.6.0.
  5. #
  6. # Copyright (c) 2019, Vigil Security, LLC
  7. # License: http://snmplabs.com/pyasn1/license.html
  8. #
  9. # Subject Identification Method (SIM)
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc4683.txt
  13. # https://www.rfc-editor.org/errata/eid1047
  14. #
  15. from pyasn1.type import char
  16. from pyasn1.type import namedtype
  17. from pyasn1.type import univ
  18. from pyasn1_modules import rfc5280
  19. # Used to compute the PEPSI value
  20. class HashContent(univ.Sequence):
  21. componentType = namedtype.NamedTypes(
  22. namedtype.NamedType('userPassword', char.UTF8String()),
  23. namedtype.NamedType('authorityRandom', univ.OctetString()),
  24. namedtype.NamedType('identifierType', univ.ObjectIdentifier()),
  25. namedtype.NamedType('identifier', char.UTF8String())
  26. )
  27. # Used to encode the PEPSI value as the SIM Other Name
  28. id_pkix = rfc5280.id_pkix
  29. id_on = id_pkix + (8,)
  30. id_on_SIM = id_on + (6,)
  31. class SIM(univ.Sequence):
  32. componentType = namedtype.NamedTypes(
  33. namedtype.NamedType('hashAlg', rfc5280.AlgorithmIdentifier()),
  34. namedtype.NamedType('authorityRandom', univ.OctetString()),
  35. namedtype.NamedType('pEPSI', univ.OctetString())
  36. )
  37. # Used to encrypt the PEPSI value during certificate request
  38. id_pkip = id_pkix + (5,)
  39. id_regEPEPSI = id_pkip + (3,)
  40. class EncryptedPEPSI(univ.Sequence):
  41. componentType = namedtype.NamedTypes(
  42. namedtype.NamedType('identifierType', univ.ObjectIdentifier()),
  43. namedtype.NamedType('identifier', char.UTF8String()),
  44. namedtype.NamedType('sIM', SIM())
  45. )
  46. # Update the map of Other Name OIDs to Other Names in rfc5280.py
  47. _anotherNameMapUpdate = {
  48. id_on_SIM: SIM(),
  49. }
  50. rfc5280.anotherNameMap.update(_anotherNameMapUpdate)