2 * EAP server/peer: EAP-pwd shared definitions
3 * Copyright (c) 2009, Dan Harkins <dharkins@lounge.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the BSD license.
8 * Alternatively, this software may be distributed under the terms of the
9 * GNU General Public License version 2 as published by the Free Software
12 * See README and COPYING for more details.
15 #ifndef EAP_PWD_COMMON_H
16 #define EAP_PWD_COMMON_H
18 #include <openssl/bn.h>
19 #include <openssl/sha.h>
20 #include <openssl/ec.h>
21 #include <openssl/evp.h>
22 #include <openssl/hmac.h>
29 * definition of a finite cyclic group
30 * TODO: support one based on a prime field
32 typedef struct group_definition_ {
41 * EAP-pwd header, included on all payloads
47 u8 total_length[0]; /* included when l_bit is set */
50 #define EAP_PWD_OPCODE_ID_EXCH 1
51 #define EAP_PWD_OPCODE_COMMIT_EXCH 2
52 #define EAP_PWD_OPCODE_CONFIRM_EXCH 3
53 #define EAP_PWD_GET_LENGTH_BIT(x) ((x)->lm_exch & 0x80)
54 #define EAP_PWD_SET_LENGTH_BIT(x) ((x)->lm_exch |= 0x80)
55 #define EAP_PWD_GET_MORE_BIT(x) ((x)->lm_exch & 0x40)
56 #define EAP_PWD_SET_MORE_BIT(x) ((x)->lm_exch |= 0x40)
57 #define EAP_PWD_GET_EXCHANGE(x) ((x)->lm_exch & 0x3f)
58 #define EAP_PWD_SET_EXCHANGE(x,y) ((x)->lm_exch |= (y))
60 /* EAP-pwd-ID payload */
64 #define EAP_PWD_DEFAULT_RAND_FUNC 1
66 #define EAP_PWD_DEFAULT_PRF 1
69 #define EAP_PWD_PREP_NONE 0
70 #define EAP_PWD_PREP_MS 1
71 u8 identity[0]; /* length inferred from payload */
75 int compute_password_element(EAP_PWD_group *, u16, u8 *, int, u8 *, int, u8 *,
77 int compute_keys(EAP_PWD_group *, BN_CTX *, BIGNUM *, EC_POINT *, EC_POINT *,
78 BIGNUM *, BIGNUM *, u32 *, u8 *, u8 *);
79 void H_Init(HMAC_CTX *);
80 void H_Update(HMAC_CTX *, const u8 *, int);
81 void H_Final(HMAC_CTX *, u8 *);
87 #endif /* EAP_PWD_COMMON_H */