rfc7914.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #The scrypt Password-Based Key Derivation Function
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc8520.txt
  13. # https://www.rfc-editor.org/errata/eid5871
  14. #
  15. from pyasn1.type import constraint
  16. from pyasn1.type import namedtype
  17. from pyasn1.type import univ
  18. from pyasn1_modules import rfc5280
  19. MAX = float('inf')
  20. id_scrypt = univ.ObjectIdentifier('1.3.6.1.4.1.11591.4.11')
  21. class Scrypt_params(univ.Sequence):
  22. componentType = namedtype.NamedTypes(
  23. namedtype.NamedType('salt',
  24. univ.OctetString()),
  25. namedtype.NamedType('costParameter',
  26. univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, MAX))),
  27. namedtype.NamedType('blockSize',
  28. univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, MAX))),
  29. namedtype.NamedType('parallelizationParameter',
  30. univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, MAX))),
  31. namedtype.OptionalNamedType('keyLength',
  32. univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, MAX)))
  33. )
  34. # Update the Algorithm Identifier map in rfc5280.py
  35. _algorithmIdentifierMapUpdate = {
  36. id_scrypt: Scrypt_params(),
  37. }
  38. rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)