rfc8419.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # This file is being contributed to pyasn1-modules software.
  2. #
  3. # Created by Russ Housley.
  4. #
  5. # Copyright (c) 2019, Vigil Security, LLC
  6. # License: http://snmplabs.com/pyasn1/license.html
  7. #
  8. # Edwards-Curve Digital Signature Algorithm (EdDSA) Signatures in the CMS
  9. #
  10. # ASN.1 source from:
  11. # https://www.rfc-editor.org/rfc/rfc8419.txt
  12. # https://www.rfc-editor.org/errata/eid5869
  13. from pyasn1.type import univ
  14. from pyasn1_modules import rfc5280
  15. class ShakeOutputLen(univ.Integer):
  16. pass
  17. id_Ed25519 = univ.ObjectIdentifier('1.3.101.112')
  18. sigAlg_Ed25519 = rfc5280.AlgorithmIdentifier()
  19. sigAlg_Ed25519['algorithm'] = id_Ed25519
  20. # sigAlg_Ed25519['parameters'] is absent
  21. id_Ed448 = univ.ObjectIdentifier('1.3.101.113')
  22. sigAlg_Ed448 = rfc5280.AlgorithmIdentifier()
  23. sigAlg_Ed448['algorithm'] = id_Ed448
  24. # sigAlg_Ed448['parameters'] is absent
  25. hashAlgs = univ.ObjectIdentifier('2.16.840.1.101.3.4.2')
  26. id_sha512 = hashAlgs + (3, )
  27. hashAlg_SHA_512 = rfc5280.AlgorithmIdentifier()
  28. hashAlg_SHA_512['algorithm'] = id_sha512
  29. # hashAlg_SHA_512['parameters'] is absent
  30. id_shake256 = hashAlgs + (12, )
  31. hashAlg_SHAKE256 = rfc5280.AlgorithmIdentifier()
  32. hashAlg_SHAKE256['algorithm'] = id_shake256
  33. # hashAlg_SHAKE256['parameters']is absent
  34. id_shake256_len = hashAlgs + (18, )
  35. hashAlg_SHAKE256_LEN = rfc5280.AlgorithmIdentifier()
  36. hashAlg_SHAKE256_LEN['algorithm'] = id_shake256_len
  37. hashAlg_SHAKE256_LEN['parameters'] = ShakeOutputLen()
  38. # Map of Algorithm Identifier OIDs to Parameters added to the
  39. # ones in rfc5280.py. Do not add OIDs with absent paramaters.
  40. _algorithmIdentifierMapUpdate = {
  41. id_shake256_len: ShakeOutputLen(),
  42. }
  43. rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)