|
wpa_supplicant / hostapd 2.0
|
00001 00010 #ifndef EAP_PWD_COMMON_H 00011 #define EAP_PWD_COMMON_H 00012 00013 #include <openssl/bn.h> 00014 #include <openssl/sha.h> 00015 #include <openssl/ec.h> 00016 #include <openssl/evp.h> 00017 #include <openssl/hmac.h> 00018 00019 /* 00020 * definition of a finite cyclic group 00021 * TODO: support one based on a prime field 00022 */ 00023 typedef struct group_definition_ { 00024 u16 group_num; 00025 EC_GROUP *group; 00026 EC_POINT *pwe; 00027 BIGNUM *order; 00028 BIGNUM *prime; 00029 } EAP_PWD_group; 00030 00031 /* 00032 * EAP-pwd header, included on all payloads 00033 * L(1 bit) | M(1 bit) | exch(6 bits) | total_length(if L is set) 00034 */ 00035 #define EAP_PWD_HDR_SIZE 1 00036 00037 #define EAP_PWD_OPCODE_ID_EXCH 1 00038 #define EAP_PWD_OPCODE_COMMIT_EXCH 2 00039 #define EAP_PWD_OPCODE_CONFIRM_EXCH 3 00040 #define EAP_PWD_GET_LENGTH_BIT(x) ((x) & 0x80) 00041 #define EAP_PWD_SET_LENGTH_BIT(x) ((x) |= 0x80) 00042 #define EAP_PWD_GET_MORE_BIT(x) ((x) & 0x40) 00043 #define EAP_PWD_SET_MORE_BIT(x) ((x) |= 0x40) 00044 #define EAP_PWD_GET_EXCHANGE(x) ((x) & 0x3f) 00045 #define EAP_PWD_SET_EXCHANGE(x,y) ((x) |= (y)) 00046 00047 /* EAP-pwd-ID payload */ 00048 struct eap_pwd_id { 00049 be16 group_num; 00050 u8 random_function; 00051 #define EAP_PWD_DEFAULT_RAND_FUNC 1 00052 u8 prf; 00053 #define EAP_PWD_DEFAULT_PRF 1 00054 u8 token[4]; 00055 u8 prep; 00056 #define EAP_PWD_PREP_NONE 0 00057 #define EAP_PWD_PREP_MS 1 00058 u8 identity[0]; /* length inferred from payload */ 00059 } STRUCT_PACKED; 00060 00061 /* common routines */ 00062 int compute_password_element(EAP_PWD_group *, u16, u8 *, int, u8 *, int, u8 *, 00063 int, u8 *); 00064 int compute_keys(EAP_PWD_group *, BN_CTX *, BIGNUM *, BIGNUM *, BIGNUM *, 00065 u8 *, u8 *, u32 *, u8 *, u8 *); 00066 void H_Init(HMAC_CTX *); 00067 void H_Update(HMAC_CTX *, const u8 *, int); 00068 void H_Final(HMAC_CTX *, u8 *); 00069 00070 #endif /* EAP_PWD_COMMON_H */ 00071
1.7.3