rfc6486.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. # RPKI Manifests
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc6486.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 tag
  18. from pyasn1.type import useful
  19. from pyasn1.type import univ
  20. from pyasn1_modules import rfc5652
  21. MAX = float('inf')
  22. id_smime = univ.ObjectIdentifier('1.2.840.113549.1.9.16')
  23. id_ct = id_smime + (1, )
  24. id_ct_rpkiManifest = id_ct + (26, )
  25. class FileAndHash(univ.Sequence):
  26. componentType = namedtype.NamedTypes(
  27. namedtype.NamedType('file', char.IA5String()),
  28. namedtype.NamedType('hash', univ.BitString())
  29. )
  30. class Manifest(univ.Sequence):
  31. componentType = namedtype.NamedTypes(
  32. namedtype.DefaultedNamedType('version',
  33. univ.Integer().subtype(explicitTag=tag.Tag(
  34. tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(value=0)),
  35. namedtype.NamedType('manifestNumber',
  36. univ.Integer().subtype(
  37. subtypeSpec=constraint.ValueRangeConstraint(0, MAX))),
  38. namedtype.NamedType('thisUpdate',
  39. useful.GeneralizedTime()),
  40. namedtype.NamedType('nextUpdate',
  41. useful.GeneralizedTime()),
  42. namedtype.NamedType('fileHashAlg',
  43. univ.ObjectIdentifier()),
  44. namedtype.NamedType('fileList',
  45. univ.SequenceOf(componentType=FileAndHash()).subtype(
  46. subtypeSpec=constraint.ValueSizeConstraint(0, MAX)))
  47. )
  48. # Map of Content Type OIDs to Content Types added to the
  49. # ones that are in rfc5652.py
  50. _cmsContentTypesMapUpdate = {
  51. id_ct_rpkiManifest: Manifest(),
  52. }
  53. rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)