3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 10:39:23 +01:00

crypto: Add crypto_cipher_key_len

This commit is contained in:
Denis Kenzior 2014-12-26 12:15:32 -06:00
parent 0693740731
commit 07c8876d9e
2 changed files with 29 additions and 0 deletions

View File

@ -34,6 +34,25 @@
#include "sha1.h" #include "sha1.h"
#include "crypto.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, int crypto_psk_from_passphrase(const char *passphrase,
const unsigned char *ssid, size_t ssid_len, const unsigned char *ssid, size_t ssid_len,
unsigned char *out_psk) unsigned char *out_psk)

View File

@ -23,6 +23,16 @@
#include <stddef.h> #include <stddef.h>
#include <stdbool.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, int crypto_psk_from_passphrase(const char *passphrase,
const unsigned char *ssid, size_t ssid_len, const unsigned char *ssid, size_t ssid_len,
unsigned char *out_psk); unsigned char *out_psk);