summaryrefslogtreecommitdiff
path: root/common/lib/scammer/common.py
blob: 519fcf4e090043d03adde231ae8266440da96830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/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"
        }