Move cipher suite selection into common helper functions
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
9aadb8774e
commit
edbd2a191e
6 changed files with 59 additions and 68 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* WPA/RSN - Shared functions for supplicant and authenticator
|
||||
* Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
|
||||
* Copyright (c) 2002-2013, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
|
@ -1214,3 +1214,33 @@ int wpa_cipher_put_suites(u8 *pos, int ciphers)
|
|||
|
||||
return num_suites;
|
||||
}
|
||||
|
||||
|
||||
int wpa_pick_pairwise_cipher(int ciphers, int none_allowed)
|
||||
{
|
||||
if (ciphers & WPA_CIPHER_CCMP)
|
||||
return WPA_CIPHER_CCMP;
|
||||
if (ciphers & WPA_CIPHER_GCMP)
|
||||
return WPA_CIPHER_GCMP;
|
||||
if (ciphers & WPA_CIPHER_TKIP)
|
||||
return WPA_CIPHER_TKIP;
|
||||
if (none_allowed && (ciphers & WPA_CIPHER_NONE))
|
||||
return WPA_CIPHER_NONE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int wpa_pick_group_cipher(int ciphers)
|
||||
{
|
||||
if (ciphers & WPA_CIPHER_CCMP)
|
||||
return WPA_CIPHER_CCMP;
|
||||
if (ciphers & WPA_CIPHER_GCMP)
|
||||
return WPA_CIPHER_GCMP;
|
||||
if (ciphers & WPA_CIPHER_TKIP)
|
||||
return WPA_CIPHER_TKIP;
|
||||
if (ciphers & WPA_CIPHER_WEP104)
|
||||
return WPA_CIPHER_WEP104;
|
||||
if (ciphers & WPA_CIPHER_WEP40)
|
||||
return WPA_CIPHER_WEP40;
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* WPA definitions shared between hostapd and wpa_supplicant
|
||||
* Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
|
||||
* Copyright (c) 2002-2013, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This software may be distributed under the terms of the BSD license.
|
||||
* See README for more details.
|
||||
|
@ -390,5 +390,7 @@ int wpa_cipher_valid_pairwise(int cipher);
|
|||
u32 wpa_cipher_to_suite(int proto, int cipher);
|
||||
int rsn_cipher_put_suites(u8 *pos, int ciphers);
|
||||
int wpa_cipher_put_suites(u8 *pos, int ciphers);
|
||||
int wpa_pick_pairwise_cipher(int ciphers, int none_allowed);
|
||||
int wpa_pick_group_cipher(int ciphers);
|
||||
|
||||
#endif /* WPA_COMMON_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue