#!/usr/bin/python ############################################################################# # Copyright (C) 2011 Spidcom ############################################################################# from scapy.all import ETHER_TYPES import os import re import sys def find_base (): """Find the base of the project.""" base = os.path.abspath (__file__) m = re.match (r'(.*/)common/lib.*', base) return m.group (1) # Add HPAV Ethernet type to the ETHER_TYPES of scapy. ETHER_TYPES['HPAV'] = 0x88e1 # Add the CCo Level/Capability HPAV_CCO_LEVEL = {0:'CCo Level 0', 1:'CCo Level 1', 2:'CCo Level 2'} # SPC OUI SPC_OUI = 0x0013d7 # Get the MME Types. base = find_base () sys.path.append ("%s/cesar/maximus/python/lib/cesar/" % base) from defineparser import define_parser HPAV_MMTYPES_TEMP = define_parser ("%s/cesar/cp/mme.h" % base) HPAV_MMTYPES = {} types = ["_REQ", "_CNF", "_IND", "_RSP"] for i in HPAV_MMTYPES_TEMP: if not i.startswith ('CP_MME_') and not i.endswith ('_MIN') \ and not i.endswith ('_MAX'): for j in range (len (types)): HPAV_MMTYPES["%s%s" % (i, types[j])] = \ HPAV_MMTYPES_TEMP[i] + j elif i.endswith ('_MIN') or i.endswith ('_MAX'): HPAV_MMTYPES[i] = HPAV_MMTYPES_TEMP[i] del base del types del HPAV_MMTYPES_TEMP # Dict with the keywords base on the hexadecimal value. HPAV_MMTYPES_REVERSE = {} for i in HPAV_MMTYPES: HPAV_MMTYPES_REVERSE[HPAV_MMTYPES[i]] = i HPAV_RESULT = {'success':0, 'failure': 1} HPAV_PEKS = {0: "DAK", 1: "NMK"} for i in range (2, 0xf): HPAV_PEKS[i] = "TEK" HPAV_PEKS[0xf] = "None" HPAV_PID = { 0: "AUTHENTICATION_REQUEST", 1: "PROVISIONING_AUTH_STA_NEK_BY_CCO", 2: "PROVISIONING_STA_WITH_NMK_USING_DAK", 3: "PROVISIONING_STA_WITH_NMK_USING_UKE", 4: "HLE", } HPAV_KEY_TYPE = { 0: "DAK", 1: "NMK", 2: "NEK", 3: "TEK", 4: "HASH_KEY", 5: "NONCE_ONLY" }