The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Functions | Variables
eap_psk_tests.c File Reference

Known-answer tests for the EAP-PSK (RFC 4764) cryptographic primitives. More...

#include <freeradius-devel/util/test/acutest.h>
#include "crypto.c"
+ Include dependency graph for eap_psk_tests.c:

Go to the source code of this file.

Functions

static void test_cmac_rfc4493 (void)
 AES-CMAC vectors from RFC 4493 Section 4.
 
static void test_derive_ak_kdk (void)
 AK/KDK derivation matches hostap's implementation.
 
static void test_derive_keys (void)
 TEK/MSK/EMSK derivation matches hostap's implementation.
 
static void test_header (uint8_t header[EAP_PSK_HEADER_LEN], uint8_t code, uint16_t eap_len, uint8_t flags)
 
static void test_macs (void)
 MAC_P and MAC_S match hostap's implementation.
 
static void test_pchannel_decrypt (void)
 Protected channel decryption round-trips, and rejects tampering.
 
static void test_pchannel_encrypt (void)
 Protected channel encryption matches hostap, for both message directions.
 

Variables

static uint8_t const expect_ak [EAP_PSK_AK_LEN]
 
static uint8_t const expect_emsk [EAP_PSK_EMSK_LEN]
 
static uint8_t const expect_kdk [EAP_PSK_KDK_LEN]
 
static uint8_t const expect_mac_p [EAP_PSK_MAC_LEN]
 
static uint8_t const expect_mac_s [EAP_PSK_MAC_LEN]
 
static uint8_t const expect_msg3_cipher = 0x8f
 
static uint8_t const expect_msg3_tag [EAP_PSK_TAG_LEN]
 
static uint8_t const expect_msg4_cipher = 0xcc
 
static uint8_t const expect_msg4_tag [EAP_PSK_TAG_LEN]
 
static uint8_t const expect_msk [EAP_PSK_MSK_LEN]
 
static uint8_t const expect_tek [EAP_PSK_TEK_LEN]
 
static char const test_id_p [] = "bob@example.com"
 
static char const test_id_s [] = "FreeRADIUS"
 
 TEST_LIST
 
static uint8_t const test_psk [EAP_PSK_PSK_LEN]
 
static uint8_t const test_rand_p [EAP_PSK_RAND_LEN]
 
static uint8_t const test_rand_s [EAP_PSK_RAND_LEN]
 

Detailed Description

Known-answer tests for the EAP-PSK (RFC 4764) cryptographic primitives.

Id
f520d45e479c01d88127446790469c8bc568739d

RFC 4764 publishes no test vectors, so verification is done in two layers:

  1. The CMAC core is checked against the official AES-CMAC vectors from RFC 4493 Section 4.
  2. The EAP-PSK derivations (AK/KDK, TEK/MSK/EMSK, MAC_P, MAC_S, and the EAX protected channel) are checked against known-answer values computed with hostap's INDEPENDENT implementation (src/eap_common/eap_psk_common.c, src/crypto/aes-omac1.c and aes-eax.c, hostap commit f541de4), for the fixed inputs documented below.

Definition in file eap_psk_tests.c.

Function Documentation

◆ test_cmac_rfc4493()

static void test_cmac_rfc4493 ( void  )
static

AES-CMAC vectors from RFC 4493 Section 4.

Definition at line 135 of file eap_psk_tests.c.

+ Here is the call graph for this function:

◆ test_derive_ak_kdk()

static void test_derive_ak_kdk ( void  )
static

AK/KDK derivation matches hostap's implementation.

Definition at line 193 of file eap_psk_tests.c.

+ Here is the call graph for this function:

◆ test_derive_keys()

static void test_derive_keys ( void  )
static

TEK/MSK/EMSK derivation matches hostap's implementation.

Definition at line 205 of file eap_psk_tests.c.

+ Here is the call graph for this function:

◆ test_header()

static void test_header ( uint8_t  header[EAP_PSK_HEADER_LEN],
uint8_t  code,
uint16_t  eap_len,
uint8_t  flags 
)
static

Definition at line 121 of file eap_psk_tests.c.

+ Here is the caller graph for this function:

◆ test_macs()

static void test_macs ( void  )
static

MAC_P and MAC_S match hostap's implementation.

Definition at line 218 of file eap_psk_tests.c.

+ Here is the call graph for this function:

◆ test_pchannel_decrypt()

static void test_pchannel_decrypt ( void  )
static

Protected channel decryption round-trips, and rejects tampering.

Definition at line 260 of file eap_psk_tests.c.

+ Here is the call graph for this function:

◆ test_pchannel_encrypt()

static void test_pchannel_encrypt ( void  )
static

Protected channel encryption matches hostap, for both message directions.

Definition at line 237 of file eap_psk_tests.c.

+ Here is the call graph for this function:

Variable Documentation

◆ expect_ak

uint8_t const expect_ak[EAP_PSK_AK_LEN]
static
Initial value:
= {
0x18, 0xb6, 0x2d, 0x2c, 0x84, 0xc5, 0xe4, 0x57,
0x1a, 0xfc, 0x41, 0xa2, 0x9d, 0xb7, 0x1f, 0x4d
}

Definition at line 63 of file eap_psk_tests.c.

◆ expect_emsk

uint8_t const expect_emsk[EAP_PSK_EMSK_LEN]
static
Initial value:
= {
0xd2, 0x0b, 0x6b, 0x75, 0x56, 0x33, 0x92, 0x00,
0xf0, 0x4e, 0x65, 0x30, 0xeb, 0x7d, 0x3c, 0x61,
0xa7, 0x81, 0x0b, 0x5c, 0xa9, 0x3f, 0x4c, 0x0b,
0xa8, 0x9e, 0xa5, 0xee, 0xdf, 0x63, 0x4a, 0x69,
0x79, 0x29, 0x20, 0xa6, 0xca, 0xea, 0x9d, 0x8e,
0x7b, 0x11, 0x2d, 0x63, 0x83, 0xdd, 0x85, 0x88,
0xb6, 0x8b, 0x74, 0xf6, 0xe7, 0xc2, 0xf8, 0xd5,
0x1a, 0xce, 0x97, 0x06, 0x71, 0x17, 0xac, 0x92
}

Definition at line 85 of file eap_psk_tests.c.

◆ expect_kdk

uint8_t const expect_kdk[EAP_PSK_KDK_LEN]
static
Initial value:
= {
0x97, 0xb7, 0x04, 0x35, 0x00, 0x85, 0x02, 0x83,
0x63, 0x92, 0x46, 0x12, 0x56, 0x5b, 0x9b, 0x0d
}

Definition at line 67 of file eap_psk_tests.c.

◆ expect_mac_p

uint8_t const expect_mac_p[EAP_PSK_MAC_LEN]
static
Initial value:
= {
0x97, 0xb0, 0xed, 0xe6, 0x89, 0xa3, 0xe4, 0x55,
0x3d, 0x8b, 0x30, 0x22, 0x58, 0xd1, 0x95, 0x12
}

Definition at line 95 of file eap_psk_tests.c.

◆ expect_mac_s

uint8_t const expect_mac_s[EAP_PSK_MAC_LEN]
static
Initial value:
= {
0x25, 0xa1, 0xd6, 0x46, 0x87, 0x9e, 0xef, 0x18,
0x7d, 0x1c, 0xc1, 0xff, 0x17, 0x7e, 0x26, 0x6d
}

Definition at line 99 of file eap_psk_tests.c.

◆ expect_msg3_cipher

uint8_t const expect_msg3_cipher = 0x8f
static

Definition at line 110 of file eap_psk_tests.c.

◆ expect_msg3_tag

uint8_t const expect_msg3_tag[EAP_PSK_TAG_LEN]
static
Initial value:
= {
0x47, 0xd6, 0x44, 0x26, 0x5c, 0xae, 0x5a, 0x68,
0x9a, 0x40, 0xa4, 0x7a, 0xc5, 0x4d, 0xdf, 0x80
}

Definition at line 111 of file eap_psk_tests.c.

◆ expect_msg4_cipher

uint8_t const expect_msg4_cipher = 0xcc
static

Definition at line 115 of file eap_psk_tests.c.

◆ expect_msg4_tag

uint8_t const expect_msg4_tag[EAP_PSK_TAG_LEN]
static
Initial value:
= {
0x7a, 0x7a, 0x71, 0x52, 0x7b, 0x1f, 0x04, 0x7a,
0x77, 0xfb, 0xf0, 0xef, 0xa6, 0x73, 0xf7, 0x54
}

Definition at line 116 of file eap_psk_tests.c.

◆ expect_msk

uint8_t const expect_msk[EAP_PSK_MSK_LEN]
static
Initial value:
= {
0xe2, 0x82, 0xc7, 0xc3, 0x2f, 0x4a, 0x3b, 0x28,
0xf1, 0x8d, 0x75, 0x86, 0x0f, 0xa2, 0x67, 0x1c,
0x46, 0xd0, 0x71, 0xe2, 0xf7, 0xe5, 0x09, 0xce,
0x2e, 0x98, 0xae, 0x9a, 0xe3, 0x34, 0x99, 0x77,
0x05, 0xf9, 0x27, 0xd1, 0x84, 0xea, 0xd2, 0x71,
0xf9, 0xbc, 0xb1, 0xb7, 0xa1, 0xf9, 0x22, 0x30,
0xbf, 0x0d, 0xc9, 0x0d, 0x94, 0x61, 0x17, 0xaa,
0xe0, 0xd7, 0x84, 0xb8, 0x35, 0x59, 0x57, 0xd5
}

Definition at line 75 of file eap_psk_tests.c.

◆ expect_tek

uint8_t const expect_tek[EAP_PSK_TEK_LEN]
static
Initial value:
= {
0x96, 0xa0, 0x0b, 0x88, 0x8b, 0x1f, 0x6b, 0x2f,
0x8e, 0x20, 0x1e, 0xe9, 0x6a, 0x22, 0x77, 0xf6
}

Definition at line 71 of file eap_psk_tests.c.

◆ test_id_p

char const test_id_p[] = "bob@example.com"
static

Definition at line 58 of file eap_psk_tests.c.

◆ test_id_s

char const test_id_s[] = "FreeRADIUS"
static

Definition at line 57 of file eap_psk_tests.c.

◆ TEST_LIST

TEST_LIST
Initial value:
= {
{ "cmac_rfc4493", test_cmac_rfc4493 },
{ "derive_ak_kdk", test_derive_ak_kdk },
{ "derive_keys", test_derive_keys },
{ "macs", test_macs },
{ "pchannel_encrypt", test_pchannel_encrypt },
{ "pchannel_decrypt", test_pchannel_decrypt },
{ NULL, NULL }
}
static void test_macs(void)
MAC_P and MAC_S match hostap's implementation.
static void test_derive_ak_kdk(void)
AK/KDK derivation matches hostap's implementation.
static void test_cmac_rfc4493(void)
AES-CMAC vectors from RFC 4493 Section 4.
static void test_pchannel_decrypt(void)
Protected channel decryption round-trips, and rejects tampering.
static void test_pchannel_encrypt(void)
Protected channel encryption matches hostap, for both message directions.
static void test_derive_keys(void)
TEK/MSK/EMSK derivation matches hostap's implementation.

Definition at line 300 of file eap_psk_tests.c.

◆ test_psk

uint8_t const test_psk[EAP_PSK_PSK_LEN]
static
Initial value:
= {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
}

Definition at line 45 of file eap_psk_tests.c.

◆ test_rand_p

uint8_t const test_rand_p[EAP_PSK_RAND_LEN]
static
Initial value:
= {
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f
}

Definition at line 53 of file eap_psk_tests.c.

◆ test_rand_s

uint8_t const test_rand_s[EAP_PSK_RAND_LEN]
static
Initial value:
= {
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
}

Definition at line 49 of file eap_psk_tests.c.