]> git.ipfire.org Git - thirdparty/hostap.git/blame - src/eap_common/eap_pwd_common.h
EAP-SIM/AKA: Use os_memcmp_const() for hash/password comparisons
[thirdparty/hostap.git] / src / eap_common / eap_pwd_common.h
CommitLineData
df684d82
DH
1/*
2 * EAP server/peer: EAP-pwd shared definitions
3 * Copyright (c) 2009, Dan Harkins <dharkins@lounge.org>
4 *
0dd1603c
JM
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
df684d82
DH
7 */
8
9#ifndef EAP_PWD_COMMON_H
10#define EAP_PWD_COMMON_H
11
12#include <openssl/bn.h>
df684d82
DH
13#include <openssl/ec.h>
14#include <openssl/evp.h>
df684d82
DH
15
16/*
17 * definition of a finite cyclic group
18 * TODO: support one based on a prime field
19 */
20typedef struct group_definition_ {
21 u16 group_num;
22 EC_GROUP *group;
23 EC_POINT *pwe;
24 BIGNUM *order;
25 BIGNUM *prime;
26} EAP_PWD_group;
27
28/*
29 * EAP-pwd header, included on all payloads
5419d6af 30 * L(1 bit) | M(1 bit) | exch(6 bits) | total_length(if L is set)
df684d82 31 */
5ea93947 32#define EAP_PWD_HDR_SIZE 1
df684d82
DH
33
34#define EAP_PWD_OPCODE_ID_EXCH 1
35#define EAP_PWD_OPCODE_COMMIT_EXCH 2
36#define EAP_PWD_OPCODE_CONFIRM_EXCH 3
5ea93947
DH
37#define EAP_PWD_GET_LENGTH_BIT(x) ((x) & 0x80)
38#define EAP_PWD_SET_LENGTH_BIT(x) ((x) |= 0x80)
39#define EAP_PWD_GET_MORE_BIT(x) ((x) & 0x40)
40#define EAP_PWD_SET_MORE_BIT(x) ((x) |= 0x40)
41#define EAP_PWD_GET_EXCHANGE(x) ((x) & 0x3f)
42#define EAP_PWD_SET_EXCHANGE(x,y) ((x) |= (y))
df684d82
DH
43
44/* EAP-pwd-ID payload */
45struct eap_pwd_id {
46 be16 group_num;
47 u8 random_function;
48#define EAP_PWD_DEFAULT_RAND_FUNC 1
49 u8 prf;
50#define EAP_PWD_DEFAULT_PRF 1
51 u8 token[4];
52 u8 prep;
53#define EAP_PWD_PREP_NONE 0
54#define EAP_PWD_PREP_MS 1
55 u8 identity[0]; /* length inferred from payload */
56} STRUCT_PACKED;
57
58/* common routines */
59int compute_password_element(EAP_PWD_group *, u16, u8 *, int, u8 *, int, u8 *,
60 int, u8 *);
e4d7b22a 61int compute_keys(EAP_PWD_group *, BN_CTX *, BIGNUM *, BIGNUM *, BIGNUM *,
13e2574f 62 u8 *, u8 *, u32 *, u8 *, u8 *, u8 *);
daf10baf
JM
63struct crypto_hash * eap_pwd_h_init(void);
64void eap_pwd_h_update(struct crypto_hash *hash, const u8 *data, size_t len);
65void eap_pwd_h_final(struct crypto_hash *hash, u8 *digest);
df684d82
DH
66
67#endif /* EAP_PWD_COMMON_H */