2014-11-14 18:37:01 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Wireless daemon for Linux
|
|
|
|
*
|
2019-10-25 00:43:08 +02:00
|
|
|
* Copyright (C) 2013-2019 Intel Corporation. All rights reserved.
|
2014-11-14 18:37:01 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2014-12-26 18:46:27 +01:00
|
|
|
#include <stdbool.h>
|
2014-11-14 18:37:01 +01:00
|
|
|
|
2021-07-07 19:36:10 +02:00
|
|
|
struct l_ecc_point;
|
|
|
|
|
2014-12-26 19:15:32 +01:00
|
|
|
enum crypto_cipher {
|
2015-03-26 04:33:07 +01:00
|
|
|
CRYPTO_CIPHER_WEP40 = 0x000fac01,
|
|
|
|
CRYPTO_CIPHER_WEP104 = 0x000fac05,
|
|
|
|
CRYPTO_CIPHER_TKIP = 0x000fac02,
|
|
|
|
CRYPTO_CIPHER_CCMP = 0x000fac04,
|
2022-10-19 23:21:34 +02:00
|
|
|
CRYPTO_CIPHER_BIP_CMAC = 0x000fac06,
|
2022-10-20 17:59:36 +02:00
|
|
|
CRYPTO_CIPHER_GCMP = 0x000fac08,
|
|
|
|
CRYPTO_CIPHER_GCMP_256 = 0x000fac09,
|
|
|
|
CRYPTO_CIPHER_CCMP_256 = 0x000fac0a,
|
|
|
|
CRYPTO_CIPHER_BIP_GMAC = 0x000fac0b,
|
|
|
|
CRYPTO_CIPHER_BIP_GMAC_256 = 0x000fac0c,
|
|
|
|
CRYPTO_CIPHER_BIP_CMAC_256 = 0x000fac0d,
|
2014-12-26 19:15:32 +01:00
|
|
|
};
|
|
|
|
|
2016-11-15 20:15:26 +01:00
|
|
|
enum crypto_akm {
|
|
|
|
CRYPTO_AKM_8021X = 0x000fac01,
|
|
|
|
CRYPTO_AKM_PSK = 0x000fac02,
|
|
|
|
CRYPTO_AKM_FT_OVER_8021X = 0x000fac03,
|
|
|
|
CRYPTO_AKM_FT_USING_PSK = 0x000fac04,
|
|
|
|
CRYPTO_AKM_8021X_SHA256 = 0x000fac05,
|
|
|
|
CRYPTO_AKM_PSK_SHA256 = 0x000fac06,
|
|
|
|
CRYPTO_AKM_TDLS = 0x000fac07,
|
|
|
|
CRYPTO_AKM_SAE_SHA256 = 0x000fac08,
|
|
|
|
CRYPTO_AKM_FT_OVER_SAE_SHA256 = 0x000fac09,
|
2018-07-19 17:57:43 +02:00
|
|
|
CRYPTO_AKM_AP_PEER_KEY_SHA256 = 0x000fac0a,
|
|
|
|
CRYPTO_AKM_8021X_SUITE_B_SHA256 = 0x000fac0b,
|
|
|
|
CRYPTO_AKM_8021X_SUITE_B_SHA384 = 0x000fac0c,
|
|
|
|
CRYPTO_AKM_FT_OVER_8021X_SHA384 = 0x000fac0d,
|
2019-04-04 22:43:13 +02:00
|
|
|
CRYPTO_AKM_FILS_SHA256 = 0x000fac0e,
|
|
|
|
CRYPTO_AKM_FILS_SHA384 = 0x000fac0f,
|
|
|
|
CRYPTO_AKM_FT_OVER_FILS_SHA256 = 0x000fac10,
|
|
|
|
CRYPTO_AKM_FT_OVER_FILS_SHA384 = 0x000fac11,
|
2018-11-16 23:22:44 +01:00
|
|
|
CRYPTO_AKM_OWE = 0x000fac12,
|
2019-06-07 21:16:59 +02:00
|
|
|
CRYPTO_AKM_OSEN = 0x506f9a01,
|
2016-11-15 20:15:26 +01:00
|
|
|
};
|
|
|
|
|
2017-10-19 21:40:15 +02:00
|
|
|
/* Min & Max reported by crypto_cipher_key_len when ignoring WEP */
|
|
|
|
#define CRYPTO_MIN_GTK_LEN 16
|
|
|
|
#define CRYPTO_MAX_GTK_LEN 32
|
|
|
|
#define CRYPTO_MIN_IGTK_LEN 16
|
|
|
|
#define CRYPTO_MAX_IGTK_LEN 32
|
|
|
|
|
2016-08-13 00:34:00 +02:00
|
|
|
extern const unsigned char crypto_dh5_prime[];
|
|
|
|
extern size_t crypto_dh5_prime_size;
|
|
|
|
extern const unsigned char crypto_dh5_generator[];
|
|
|
|
extern size_t crypto_dh5_generator_size;
|
|
|
|
|
2015-02-19 03:51:54 +01:00
|
|
|
bool hmac_md5(const void *key, size_t key_len,
|
|
|
|
const void *data, size_t data_len, void *output, size_t size);
|
2016-02-10 21:12:46 +01:00
|
|
|
bool hmac_sha1(const void *key, size_t key_len,
|
|
|
|
const void *data, size_t data_len, void *output, size_t size);
|
2015-02-19 03:45:52 +01:00
|
|
|
bool hmac_sha256(const void *key, size_t key_len,
|
|
|
|
const void *data, size_t data_len, void *output, size_t size);
|
2019-01-14 21:54:26 +01:00
|
|
|
bool hmac_sha384(const void *key, size_t key_len,
|
|
|
|
const void *data, size_t data_len, void *output, size_t size);
|
2015-02-19 04:02:09 +01:00
|
|
|
bool cmac_aes(const void *key, size_t key_len,
|
|
|
|
const void *data, size_t data_len, void *output, size_t size);
|
|
|
|
|
2019-01-17 21:25:30 +01:00
|
|
|
bool aes_unwrap(const uint8_t *kek, size_t kek_len, const uint8_t *in, size_t len,
|
2015-02-19 04:02:09 +01:00
|
|
|
uint8_t *out);
|
2017-08-31 04:04:47 +02:00
|
|
|
bool aes_wrap(const uint8_t *kek, const uint8_t *in, size_t len, uint8_t *out);
|
2015-02-19 04:11:37 +01:00
|
|
|
bool arc4_skip(const uint8_t *key, size_t key_len, size_t skip,
|
|
|
|
const uint8_t *in, size_t len, uint8_t *out);
|
2015-02-19 03:45:52 +01:00
|
|
|
|
2021-11-22 21:44:22 +01:00
|
|
|
bool aes_siv_encrypt(const void *key, size_t key_len, const void *in,
|
2019-04-17 20:21:29 +02:00
|
|
|
size_t in_len, struct iovec *ad, size_t num_ad,
|
2021-11-22 21:44:22 +01:00
|
|
|
void *out);
|
|
|
|
bool aes_siv_decrypt(const void *key, size_t key_len, const void *in,
|
2019-04-17 20:21:29 +02:00
|
|
|
size_t in_len, struct iovec *ad, size_t num_ad,
|
2021-11-22 21:44:22 +01:00
|
|
|
void *out);
|
2019-04-17 20:21:29 +02:00
|
|
|
|
2014-12-26 19:15:32 +01:00
|
|
|
int crypto_cipher_key_len(enum crypto_cipher cipher);
|
2014-12-26 19:15:46 +01:00
|
|
|
int crypto_cipher_tk_bits(enum crypto_cipher cipher);
|
2014-12-26 19:15:32 +01:00
|
|
|
|
2019-09-18 18:02:57 +02:00
|
|
|
bool crypto_passphrase_is_valid(const char *passphrase);
|
|
|
|
|
2014-11-14 18:37:01 +01:00
|
|
|
int crypto_psk_from_passphrase(const char *passphrase,
|
|
|
|
const unsigned char *ssid, size_t ssid_len,
|
|
|
|
unsigned char *out_psk);
|
2014-12-26 18:46:27 +01:00
|
|
|
|
2021-07-12 05:09:33 +02:00
|
|
|
bool crypto_kdf(enum l_checksum_type type, const void *key, size_t key_len,
|
|
|
|
const void *prefix, size_t prefix_len,
|
|
|
|
const void *data, size_t data_len, void *output, size_t size);
|
2016-02-10 23:30:22 +01:00
|
|
|
bool kdf_sha256(const void *key, size_t key_len,
|
|
|
|
const void *prefix, size_t prefix_len,
|
|
|
|
const void *data, size_t data_len, void *output, size_t size);
|
2019-04-06 00:47:30 +02:00
|
|
|
bool kdf_sha384(const void *key, size_t key_len,
|
|
|
|
const void *prefix, size_t prefix_len,
|
|
|
|
const void *data, size_t data_len, void *output, size_t size);
|
2016-02-10 21:16:32 +01:00
|
|
|
bool prf_sha1(const void *key, size_t key_len,
|
|
|
|
const void *prefix, size_t prefix_len,
|
|
|
|
const void *data, size_t data_len, void *output, size_t size);
|
2019-12-05 22:13:53 +01:00
|
|
|
bool prf_plus_sha1(const void *key, size_t key_len,
|
|
|
|
const void *prefix, size_t prefix_len,
|
|
|
|
const void *data, size_t data_len, void *output, size_t size);
|
2021-06-29 21:51:05 +02:00
|
|
|
|
|
|
|
bool prf_plus(enum l_checksum_type type, const void *key, size_t key_len,
|
|
|
|
const char *label, void *out, size_t out_len,
|
|
|
|
size_t n_extra, ...);
|
|
|
|
|
2021-06-29 18:11:24 +02:00
|
|
|
bool hkdf_extract(enum l_checksum_type type, const void *key, size_t key_len,
|
|
|
|
uint8_t num_args, void *out, ...);
|
2016-02-10 21:16:32 +01:00
|
|
|
|
2021-11-22 21:44:23 +01:00
|
|
|
bool hkdf_expand(enum l_checksum_type type, const void *key, size_t key_len,
|
2021-06-29 21:51:05 +02:00
|
|
|
const char *info, void *out, size_t out_len);
|
2018-11-16 23:22:51 +01:00
|
|
|
|
2019-01-17 21:25:31 +01:00
|
|
|
bool crypto_derive_pairwise_ptk(const uint8_t *pmk, size_t pmk_len,
|
2014-12-26 21:14:02 +01:00
|
|
|
const uint8_t *addr1, const uint8_t *addr2,
|
|
|
|
const uint8_t *nonce1, const uint8_t *nonce2,
|
2019-01-17 21:25:30 +01:00
|
|
|
uint8_t *out_ptk, size_t ptk_len,
|
2019-04-25 21:52:48 +02:00
|
|
|
enum l_checksum_type type);
|
2016-09-06 23:43:39 +02:00
|
|
|
|
2019-05-10 22:19:25 +02:00
|
|
|
bool crypto_derive_pmk_r0(const uint8_t *xxkey, size_t xxkey_len,
|
2016-09-06 23:43:39 +02:00
|
|
|
const uint8_t *ssid, size_t ssid_len,
|
|
|
|
uint16_t mdid,
|
|
|
|
const uint8_t *r0khid, size_t r0kh_len,
|
2019-05-10 22:19:28 +02:00
|
|
|
const uint8_t *s0khid, bool sha384,
|
|
|
|
uint8_t *out_pmk_r0, uint8_t *out_pmk_r0_name);
|
2016-09-06 23:43:40 +02:00
|
|
|
bool crypto_derive_pmk_r1(const uint8_t *pmk_r0,
|
|
|
|
const uint8_t *r1khid, const uint8_t *s1khid,
|
2019-05-10 22:19:28 +02:00
|
|
|
const uint8_t *pmk_r0_name, bool sha384,
|
2016-09-06 23:43:40 +02:00
|
|
|
uint8_t *out_pmk_r1,
|
|
|
|
uint8_t *out_pmk_r1_name);
|
2016-09-06 23:43:41 +02:00
|
|
|
bool crypto_derive_ft_ptk(const uint8_t *pmk_r1, const uint8_t *pmk_r1_name,
|
|
|
|
const uint8_t *addr1, const uint8_t *addr2,
|
|
|
|
const uint8_t *nonce1, const uint8_t *nonce2,
|
2019-05-10 22:19:28 +02:00
|
|
|
bool sha384, uint8_t *out_ptk, size_t ptk_len,
|
2016-09-06 23:43:41 +02:00
|
|
|
uint8_t *out_ptk_name);
|
2017-04-15 13:58:44 +02:00
|
|
|
|
|
|
|
bool crypto_derive_pmkid(const uint8_t *pmk,
|
|
|
|
const uint8_t *addr1, const uint8_t *addr2,
|
|
|
|
uint8_t *out_pmkid, bool use_sha256);
|
2021-07-07 19:36:10 +02:00
|
|
|
|
2021-07-12 03:33:51 +02:00
|
|
|
enum crypto_sae {
|
|
|
|
CRYPTO_SAE_LOOPING,
|
|
|
|
CRYPTO_SAE_HASH_TO_ELEMENT,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum l_checksum_type crypto_sae_hash_from_ecc_prime_len(enum crypto_sae type,
|
|
|
|
size_t prime_len);
|
2021-07-07 19:36:10 +02:00
|
|
|
struct l_ecc_point *crypto_derive_sae_pt_ecc(unsigned int group,
|
|
|
|
const char *ssid,
|
|
|
|
const char *password,
|
|
|
|
const char *identifier);
|
2021-07-09 17:07:28 +02:00
|
|
|
struct l_ecc_point *crypto_derive_sae_pwe_from_pt_ecc(const uint8_t *mac1,
|
|
|
|
const uint8_t *mac2,
|
|
|
|
const struct l_ecc_point *pt);
|