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 16from pyasn1.type import constraint 17from pyasn1.type import namedtype 18from pyasn1.type import tag 19from pyasn1.type import univ 20 21from pyasn1_modules import rfc5652 22 23MAX = float('inf') 24 25 26id_ct_routeOriginAuthz = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.24') 27 28 29class ASID(univ.Integer): 30 pass 31 32 33class IPAddress(univ.BitString): 34 pass 35 36 37class ROAIPAddress(univ.Sequence): 38 componentType = namedtype.NamedTypes( 39 namedtype.NamedType('address', IPAddress()), 40 namedtype.OptionalNamedType('maxLength', univ.Integer()) 41 ) 42 43 44class ROAIPAddressFamily(univ.Sequence): 45 componentType = namedtype.NamedTypes( 46 namedtype.NamedType('addressFamily', 47 univ.OctetString().subtype( 48 subtypeSpec=constraint.ValueSizeConstraint(2, 3))), 49 namedtype.NamedType('addresses', 50 univ.SequenceOf(componentType=ROAIPAddress()).subtype( 51 subtypeSpec=constraint.ValueSizeConstraint(1, MAX))) 52 ) 53 54 55class RouteOriginAttestation(univ.Sequence): 56 componentType = namedtype.NamedTypes( 57 namedtype.DefaultedNamedType('version', 58 univ.Integer().subtype(explicitTag=tag.Tag( 59 tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(value=0)), 60 namedtype.NamedType('asID', ASID()), 61 namedtype.NamedType('ipAddrBlocks', 62 univ.SequenceOf(componentType=ROAIPAddressFamily()).subtype( 63 subtypeSpec=constraint.ValueSizeConstraint(1, MAX))) 64 ) 65 66 67# Map of Content Type OIDs to Content Types added to the 68# ones that are in rfc5652.py 69 70_cmsContentTypesMapUpdate = { 71 id_ct_routeOriginAuthz: RouteOriginAttestation(), 72} 73 74rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate) 75