Disconnect hostapd from building in base
[dragonfly.git] / contrib / hostapd / src / common / sae.h
CommitLineData
4781064b
JM
1/*
2 * Simultaneous authentication of equals
3 * Copyright (c) 2012-2013, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9#ifndef SAE_H
10#define SAE_H
11
12#define SAE_KCK_LEN 32
13#define SAE_PMK_LEN 32
14#define SAE_PMKID_LEN 16
15#define SAE_KEYSEED_KEY_LEN 32
16#define SAE_MAX_PRIME_LEN 512
17#define SAE_MAX_ECC_PRIME_LEN 66
18#define SAE_COMMIT_MAX_LEN (2 + 3 * SAE_MAX_PRIME_LEN)
19#define SAE_CONFIRM_MAX_LEN (2 + SAE_MAX_PRIME_LEN)
20
21struct sae_temporary_data {
22 u8 kck[SAE_KCK_LEN];
23 struct crypto_bignum *own_commit_scalar;
24 struct crypto_bignum *own_commit_element_ffc;
25 struct crypto_ec_point *own_commit_element_ecc;
26 struct crypto_bignum *peer_commit_element_ffc;
27 struct crypto_ec_point *peer_commit_element_ecc;
28 struct crypto_ec_point *pwe_ecc;
29 struct crypto_bignum *pwe_ffc;
30 struct crypto_bignum *sae_rand;
31 struct crypto_ec *ec;
32 int prime_len;
33 const struct dh_group *dh;
34 const struct crypto_bignum *prime;
35 const struct crypto_bignum *order;
36 struct crypto_bignum *prime_buf;
37 struct crypto_bignum *order_buf;
38};
39
40struct sae_data {
41 enum { SAE_NOTHING, SAE_COMMITTED, SAE_CONFIRMED, SAE_ACCEPTED } state;
42 u16 send_confirm;
43 u8 pmk[SAE_PMK_LEN];
44 struct crypto_bignum *peer_commit_scalar;
45 int group;
46 struct sae_temporary_data *tmp;
47};
48
49int sae_set_group(struct sae_data *sae, int group);
50void sae_clear_temp_data(struct sae_data *sae);
51void sae_clear_data(struct sae_data *sae);
52
53int sae_prepare_commit(const u8 *addr1, const u8 *addr2,
54 const u8 *password, size_t password_len,
55 struct sae_data *sae);
56int sae_process_commit(struct sae_data *sae);
57void sae_write_commit(struct sae_data *sae, struct wpabuf *buf,
58 const struct wpabuf *token);
59u16 sae_parse_commit(struct sae_data *sae, const u8 *data, size_t len,
60 const u8 **token, size_t *token_len, int *allowed_groups);
61void sae_write_confirm(struct sae_data *sae, struct wpabuf *buf);
62int sae_check_confirm(struct sae_data *sae, const u8 *data, size_t len);
63
64#endif /* SAE_H */