Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

# SECUREAUTH LABS. Copyright 2018 SecureAuth Corporation. All rights reserved. 

# 

# This software is provided under under a slightly modified version 

# of the Apache Software License. See the accompanying LICENSE file 

# for more information. 

# 

# Description: 

# IEEE 802.11 Network packet codecs. 

# 

# Author: 

# Gustavo Moreira 

 

from array import array 

class KeyManager: 

def __init__(self): 

self.keys = {} 

 

def __get_bssid_hasheable_type(self, bssid): 

# List is an unhashable type 

20 ↛ 21line 20 didn't jump to line 21, because the condition on line 20 was never true if not isinstance(bssid, (list,tuple,array)): 

raise Exception('BSSID datatype must be a tuple, list or array') 

return tuple(bssid) 

 

def add_key(self, bssid, key): 

bssid=self.__get_bssid_hasheable_type(bssid) 

26 ↛ 30line 26 didn't jump to line 30, because the condition on line 26 was never false if bssid not in self.keys: 

self.keys[bssid] = key 

return True 

else: 

return False 

 

def replace_key(self, bssid, key): 

bssid=self.__get_bssid_hasheable_type(bssid) 

self.keys[bssid] = key 

 

return True 

 

def get_key(self, bssid): 

bssid=self.__get_bssid_hasheable_type(bssid) 

40 ↛ 43line 40 didn't jump to line 43, because the condition on line 40 was never false if bssid in self.keys: 

return self.keys[bssid] 

else: 

return False 

 

def delete_key(self, bssid): 

bssid=self.__get_bssid_hasheable_type(bssid) 

if not isinstance(bssid, list): 

raise Exception('BSSID datatype must be a list') 

 

if bssid in self.keys: 

del self.keys[bssid] 

return True 

 

return False