mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-29 22:19:23 +01:00
crypto: Add crypto_cipher_key_len
This commit is contained in:
parent
0693740731
commit
07c8876d9e
19
src/crypto.c
19
src/crypto.c
@ -34,6 +34,25 @@
|
||||
#include "sha1.h"
|
||||
#include "crypto.h"
|
||||
|
||||
/* 802.11, Section 11.6.2, Table 11-4 */
|
||||
int crypto_cipher_key_len(enum crypto_cipher cipher)
|
||||
{
|
||||
switch (cipher) {
|
||||
case CRYPTO_CIPHER_WEP40:
|
||||
return 5;
|
||||
case CRYPTO_CIPHER_WEP104:
|
||||
return 13;
|
||||
case CRYPTO_CIPHER_TKIP:
|
||||
return 32;
|
||||
case CRYPTO_CIPHER_CCMP:
|
||||
return 16;
|
||||
case CRYPTO_CIPHER_BIP:
|
||||
return 16;
|
||||
};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int crypto_psk_from_passphrase(const char *passphrase,
|
||||
const unsigned char *ssid, size_t ssid_len,
|
||||
unsigned char *out_psk)
|
||||
|
10
src/crypto.h
10
src/crypto.h
@ -23,6 +23,16 @@
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
enum crypto_cipher {
|
||||
CRYPTO_CIPHER_WEP40,
|
||||
CRYPTO_CIPHER_WEP104,
|
||||
CRYPTO_CIPHER_TKIP,
|
||||
CRYPTO_CIPHER_CCMP,
|
||||
CRYPTO_CIPHER_BIP,
|
||||
};
|
||||
|
||||
int crypto_cipher_key_len(enum crypto_cipher cipher);
|
||||
|
||||
int crypto_psk_from_passphrase(const char *passphrase,
|
||||
const unsigned char *ssid, size_t ssid_len,
|
||||
unsigned char *out_psk);
|
||||
|
Loading…
Reference in New Issue
Block a user