iwd/src/crypto.h

68 lines
2.3 KiB
C
Raw Normal View History

/*
*
* Wireless daemon for Linux
*
* Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
*
* 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-12-26 19:15:32 +01:00
enum crypto_cipher {
CRYPTO_CIPHER_WEP40,
CRYPTO_CIPHER_WEP104,
CRYPTO_CIPHER_TKIP,
CRYPTO_CIPHER_CCMP,
CRYPTO_CIPHER_BIP,
};
2014-12-26 21:14:02 +01:00
struct crypto_ptk {
uint8_t kck[16];
uint8_t kek[16];
uint8_t tk[0];
} __attribute__ ((packed));
2014-12-26 21:14:02 +01:00
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);
bool hmac_sha256(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);
bool aes_unwrap(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);
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
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
2014-12-26 21:11:43 +01:00
bool crypto_derive_ptk(const uint8_t *pmk, size_t pmk_len, const char *label,
const uint8_t *addr1, const uint8_t *addr2,
const uint8_t *nonce1, const uint8_t *nonce2,
2014-12-26 18:46:27 +01:00
uint8_t *out_ptk, size_t ptk_len);
2014-12-26 21:14:02 +01:00
bool crypto_derive_pairwise_ptk(const uint8_t *pmk,
const uint8_t *addr1, const uint8_t *addr2,
const uint8_t *nonce1, const uint8_t *nonce2,
struct crypto_ptk *out_ptk, size_t ptk_len);