SAE: Add support for additional ECC groups
[mech_eap.git] / src / common / sae.h
1 /*
2  * Simultaneous authentication of equals
3  * Copyright (c) 2012, 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 48
17 #define SAE_COMMIT_MAX_LEN (2 + 3 * SAE_MAX_PRIME_LEN)
18 #define SAE_CONFIRM_MAX_LEN (2 + SAE_MAX_PRIME_LEN)
19
20 struct sae_data {
21         enum { SAE_NOTHING, SAE_COMMITTED, SAE_CONFIRMED, SAE_ACCEPTED } state;
22         u16 send_confirm;
23         u8 kck[SAE_KCK_LEN];
24         u8 pmk[SAE_PMK_LEN];
25         u8 own_commit_scalar[SAE_MAX_PRIME_LEN];
26         u8 own_commit_element[2 * SAE_MAX_PRIME_LEN];
27         u8 peer_commit_scalar[SAE_MAX_PRIME_LEN];
28         u8 peer_commit_element[2 * SAE_MAX_PRIME_LEN];
29         u8 pwe[2 * SAE_MAX_PRIME_LEN];
30         u8 sae_rand[SAE_MAX_PRIME_LEN];
31         int group;
32         struct crypto_ec *ec;
33         int prime_len;
34 };
35
36 int sae_set_group(struct sae_data *sae, int group);
37 void sae_clear_data(struct sae_data *sae);
38
39 int sae_prepare_commit(const u8 *addr1, const u8 *addr2,
40                        const u8 *password, size_t password_len,
41                        struct sae_data *sae);
42 int sae_process_commit(struct sae_data *sae);
43 void sae_write_commit(struct sae_data *sae, struct wpabuf *buf,
44                       const struct wpabuf *token);
45 u16 sae_parse_commit(struct sae_data *sae, const u8 *data, size_t len,
46                      const u8 **token, size_t *token_len);
47 void sae_write_confirm(struct sae_data *sae, struct wpabuf *buf);
48 int sae_check_confirm(struct sae_data *sae, const u8 *data, size_t len);
49
50 #endif /* SAE_H */