26RCSIDH(eap_psk_crypto_h,
"$Id: 9b05bf9aac315a6593bdb0fdde778ea4442f119d $")
28#include <freeradius-devel/eap/base.h>
34#define EAP_PSK_RAND_LEN 16
35#define EAP_PSK_MAC_LEN 16
36#define EAP_PSK_PSK_LEN 16
37#define EAP_PSK_AK_LEN 16
38#define EAP_PSK_KDK_LEN 16
39#define EAP_PSK_TEK_LEN 16
40#define EAP_PSK_MSK_LEN 64
41#define EAP_PSK_EMSK_LEN 64
42#define EAP_PSK_NONCE_LEN 4
43#define EAP_PSK_TAG_LEN 16
49#define EAP_PSK_T_MASK 0xc0
50#define EAP_PSK_FLAGS_FIRST 0x00
51#define EAP_PSK_FLAGS_SECOND 0x40
52#define EAP_PSK_FLAGS_THIRD 0x80
53#define EAP_PSK_FLAGS_FOURTH 0xc0
60#define EAP_PSK_R_CONT 1
61#define EAP_PSK_R_DONE_SUCCESS 2
62#define EAP_PSK_R_DONE_FAILURE 3
64#define EAP_PSK_R(_b) (((_b) >> 6) & 0x03)
65#define EAP_PSK_PAYLOAD(_r) (uint8_t)(((_r) & 0x03) << 6)
71#define EAP_PSK_PCHANNEL_LEN (EAP_PSK_NONCE_LEN + EAP_PSK_TAG_LEN + 1)
78#define EAP_PSK_HEADER_LEN (4 + 1 + 1 + EAP_PSK_RAND_LEN)
83#define EAP_PSK_MAX_ID_P_LEN 966
134 uint8_t const *id_p,
size_t id_p_len,
135 uint8_t const *id_s,
size_t id_s_len,
141 uint8_t const *id_s,
size_t id_s_len,
153 uint8_t const *header,
size_t header_len,
154 uint8_t const *plain,
size_t plain_len);
158 uint8_t const *header,
size_t header_len,
159 uint8_t const *cipher,
size_t cipher_len,
int eap_psk_derive_keys(uint8_t tek[static EAP_PSK_TEK_LEN], uint8_t msk[static EAP_PSK_MSK_LEN], uint8_t emsk[static EAP_PSK_EMSK_LEN], uint8_t const kdk[static EAP_PSK_KDK_LEN], uint8_t const rand_p[static EAP_PSK_RAND_LEN])
Session-key derivation: expand RAND_P under KDK into nine output blocks.
int eap_psk_mac_s(uint8_t mac_s[static EAP_PSK_MAC_LEN], uint8_t const ak[static EAP_PSK_AK_LEN], uint8_t const *id_s, size_t id_s_len, uint8_t const rand_p[static EAP_PSK_RAND_LEN])
Compute MAC_S = CMAC-AES-128(AK, ID_S || RAND_P)
@ EAP_PSK_STATE_RESULT_INDICATION_SENT
@ EAP_PSK_STATE_IDENTITY_REQUEST_SENT
int eap_psk_pchannel_encrypt(uint8_t *cipher, uint8_t tag[static EAP_PSK_TAG_LEN], uint8_t const tek[static EAP_PSK_TEK_LEN], uint32_t nonce, uint8_t const *header, size_t header_len, uint8_t const *plain, size_t plain_len)
EAX encrypt for the protected channel (RFC 4764 Section 3.3)
int eap_psk_mac_p(uint8_t mac_p[static EAP_PSK_MAC_LEN], uint8_t const ak[static EAP_PSK_AK_LEN], uint8_t const *id_p, size_t id_p_len, uint8_t const *id_s, size_t id_s_len, uint8_t const rand_s[static EAP_PSK_RAND_LEN], uint8_t const rand_p[static EAP_PSK_RAND_LEN])
Compute MAC_P = CMAC-AES-128(AK, ID_P || ID_S || RAND_S || RAND_P)
char * id_s
ID_S actually sent in the first message.
int eap_psk_derive_ak_kdk(uint8_t ak[static EAP_PSK_AK_LEN], uint8_t kdk[static EAP_PSK_KDK_LEN], uint8_t const psk[static EAP_PSK_PSK_LEN])
Key setup: derive AK (counter 1) and KDK (counter 2) from the PSK.
int eap_psk_pchannel_decrypt(uint8_t *plain, uint8_t const tek[static EAP_PSK_TEK_LEN], uint32_t nonce, uint8_t const *header, size_t header_len, uint8_t const *cipher, size_t cipher_len, uint8_t const tag[static EAP_PSK_TAG_LEN])
EAX decrypt-and-verify for the protected channel (RFC 4764 Section 3.3)
uint8_t * id_p
ID_P the peer asserted in the second message.
unlang_result_t section_result
Result of the last policy section.