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# SECUREAUTH LABS. Copyright 2018 SecureAuth Corporation. All rights reserved. 

2# 

3# This software is provided under under a slightly modified version 

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

5# for more information. 

6# 

7# Description: 

8# IEEE 802.11 Network packet codecs. 

9# 

10# Author: 

11# Gustavo Moreira 

12 

13from array import array 

14class KeyManager: 

15 def __init__(self): 

16 self.keys = {} 

17 

18 def __get_bssid_hasheable_type(self, bssid): 

19 # List is an unhashable type 

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

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

22 return tuple(bssid) 

23 

24 def add_key(self, bssid, key): 

25 bssid=self.__get_bssid_hasheable_type(bssid) 

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

27 self.keys[bssid] = key 

28 return True 

29 else: 

30 return False 

31 

32 def replace_key(self, bssid, key): 

33 bssid=self.__get_bssid_hasheable_type(bssid) 

34 self.keys[bssid] = key 

35 

36 return True 

37 

38 def get_key(self, bssid): 

39 bssid=self.__get_bssid_hasheable_type(bssid) 

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

41 return self.keys[bssid] 

42 else: 

43 return False 

44 

45 def delete_key(self, bssid): 

46 bssid=self.__get_bssid_hasheable_type(bssid) 

47 if not isinstance(bssid, list): 

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

49 

50 if bssid in self.keys: 

51 del self.keys[bssid] 

52 return True 

53 

54 return False