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