rfc6482.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 Route Origin Authorizations (ROAs)
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc6482.txt
  13. # https://www.rfc-editor.org/errata/eid5881
  14. #
  15. from pyasn1.type import constraint
  16. from pyasn1.type import namedtype
  17. from pyasn1.type import tag
  18. from pyasn1.type import univ
  19. from pyasn1_modules import rfc5652
  20. MAX = float('inf')
  21. id_ct_routeOriginAuthz = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.24')
  22. class ASID(univ.Integer):
  23. pass
  24. class IPAddress(univ.BitString):
  25. pass
  26. class ROAIPAddress(univ.Sequence):
  27. componentType = namedtype.NamedTypes(
  28. namedtype.NamedType('address', IPAddress()),
  29. namedtype.OptionalNamedType('maxLength', univ.Integer())
  30. )
  31. class ROAIPAddressFamily(univ.Sequence):
  32. componentType = namedtype.NamedTypes(
  33. namedtype.NamedType('addressFamily',
  34. univ.OctetString().subtype(
  35. subtypeSpec=constraint.ValueSizeConstraint(2, 3))),
  36. namedtype.NamedType('addresses',
  37. univ.SequenceOf(componentType=ROAIPAddress()).subtype(
  38. subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
  39. )
  40. class RouteOriginAttestation(univ.Sequence):
  41. componentType = namedtype.NamedTypes(
  42. namedtype.DefaultedNamedType('version',
  43. univ.Integer().subtype(explicitTag=tag.Tag(
  44. tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(value=0)),
  45. namedtype.NamedType('asID', ASID()),
  46. namedtype.NamedType('ipAddrBlocks',
  47. univ.SequenceOf(componentType=ROAIPAddressFamily()).subtype(
  48. subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
  49. )
  50. # Map of Content Type OIDs to Content Types added to the
  51. # ones that are in rfc5652.py
  52. _cmsContentTypesMapUpdate = {
  53. id_ct_routeOriginAuthz: RouteOriginAttestation(),
  54. }
  55. rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)