00001 """ROA (Route Origin Authorization). 00002 00003 At the moment this is just the ASN.1 encoder. 00004 00005 This corresponds to draft-ietf-sidr-roa-format, which is a work in 00006 progress, so this may need updating later. 00007 00008 $Id: roa.py 1975 2008-07-07 14:49:00Z sra $ 00009 00010 Copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN") 00011 00012 Permission to use, copy, modify, and distribute this software for any 00013 purpose with or without fee is hereby granted, provided that the above 00014 copyright notice and this permission notice appear in all copies. 00015 00016 THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH 00017 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 00018 AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT, 00019 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00020 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 00021 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00022 PERFORMANCE OF THIS SOFTWARE. 00023 00024 draft-ietf-sidr-roa-format-03 2.1.3.2 specifies: 00025 00026 RouteOriginAttestation ::= SEQUENCE { 00027 version [0] INTEGER DEFAULT 0, 00028 asID ASID, 00029 ipAddrBlocks SEQUENCE OF ROAIPAddressFamily } 00030 00031 ASID ::= INTEGER 00032 00033 ROAIPAddressFamily ::= SEQUENCE { 00034 addressFamily OCTET STRING (SIZE (2..3)), 00035 addresses SEQUENCE OF ROAIPAddress } 00036 00037 ROAIPAddress ::= SEQUENCE { 00038 address IPAddress, 00039 maxLength INTEGER OPTIONAL } 00040 00041 IPAddress ::= BIT STRING 00042 """ 00043 00044 from POW._der import * 00045 00046 class ROAIPAddress(Sequence): 00047 def __init__(self, optional=0, default=''): 00048 self.address = BitString() 00049 self.maxLength = Integer(1) 00050 contents = [ self.address, self.maxLength ] 00051 Sequence.__init__(self, contents, optional, default) 00052 00053 class ROAIPAddresses(SequenceOf): 00054 def __init__(self, optional=0, default=''): 00055 SequenceOf.__init__(self, ROAIPAddress, optional, default) 00056 00057 class ROAIPAddressFamily(Sequence): 00058 def __init__(self, optional=0, default=''): 00059 self.addressFamily = OctetString() 00060 self.addresses = ROAIPAddresses() 00061 contents = [ self.addressFamily, self.addresses ] 00062 Sequence.__init__(self, contents, optional, default) 00063 00064 class ROAIPAddressFamilies(SequenceOf): 00065 def __init__(self, optional=0, default=''): 00066 SequenceOf.__init__(self, ROAIPAddressFamily, optional, default) 00067 00068 class RouteOriginAttestation(Sequence): 00069 def __init__(self, optional=0, default=''): 00070 self.version = Integer() 00071 self.explicitVersion = Explicit(CLASS_CONTEXT, FORM_CONSTRUCTED, 0, self.version, 0, 'oAMCAQA=') 00072 self.asID = Integer() 00073 self.ipAddrBlocks = ROAIPAddressFamilies() 00074 contents = [ self.explicitVersion, self.asID, self.ipAddrBlocks ] 00075 Sequence.__init__(self, contents, optional, default)