From 72f7b68b93ed6b237775eb2caf516a1503675614 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 17 May 2026 01:33:11 +0530 Subject: test_identity: 24/24 passing — HMAC-SHA512 derivation, MAC bits, SSID/IP determinism MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/stubs/esp_netif.h | 13 +------------ tests/unit/test_identity | Bin 0 -> 296504 bytes tests/unit/test_identity.c | 12 +++++++++--- 3 files changed, 10 insertions(+), 15 deletions(-) create mode 100755 tests/unit/test_identity diff --git a/tests/unit/stubs/esp_netif.h b/tests/unit/stubs/esp_netif.h index f009537..719d7c6 100644 --- a/tests/unit/stubs/esp_netif.h +++ b/tests/unit/stubs/esp_netif.h @@ -1,17 +1,6 @@ #ifndef STUBS_ESP_NETIF_H #define STUBS_ESP_NETIF_H -#include - -typedef struct { - uint32_t addr; -} esp_ip4_addr_t; - -#define IPSTR "%d.%d.%d.%d" -#define IP2STR(ip) ((ip)->addr & 0xff), (((ip)->addr >> 8) & 0xff), (((ip)->addr >> 16) & 0xff), (((ip)->addr >> 24) & 0xff) - -static inline void IP4_ADDR(esp_ip4_addr_t *ip, uint8_t a, uint8_t b, uint8_t c, uint8_t d) { - ip->addr = ((uint32_t)a) | ((uint32_t)b << 8) | ((uint32_t)c << 16) | ((uint32_t)d << 24); -} +#include "lwip/ip4_addr.h" #endif diff --git a/tests/unit/test_identity b/tests/unit/test_identity new file mode 100755 index 0000000..c89de17 Binary files /dev/null and b/tests/unit/test_identity differ diff --git a/tests/unit/test_identity.c b/tests/unit/test_identity.c index cf4028f..4b86d0a 100644 --- a/tests/unit/test_identity.c +++ b/tests/unit/test_identity.c @@ -49,12 +49,18 @@ int main(void) ASSERT_EQ_STR(id->ap_ssid, id2->ap_ssid, "SSID is deterministic"); printf("\n--- Different nsec produces different identity ---\n"); + uint8_t old_sta[6], old_ap[6]; + char old_ssid[32]; + memcpy(old_sta, id2->sta_mac, 6); + memcpy(old_ap, id2->ap_mac, 6); + strncpy(old_ssid, id2->ap_ssid, sizeof(old_ssid)); + ret = identity_init(TEST_NSEC2); ASSERT_EQ_INT(ESP_OK, ret, "Init with different nsec succeeds"); const tollgate_identity_t *id3 = identity_get(); - ASSERT(memcmp(id->sta_mac, id3->sta_mac, 6) != 0, "Different nsec produces different STA MAC"); - ASSERT(memcmp(id->ap_mac, id3->ap_mac, 6) != 0, "Different nsec produces different AP MAC"); - ASSERT(strcmp(id->ap_ssid, id3->ap_ssid) != 0, "Different nsec produces different SSID"); + ASSERT(memcmp(old_sta, id3->sta_mac, 6) != 0, "Different nsec produces different STA MAC"); + ASSERT(memcmp(old_ap, id3->ap_mac, 6) != 0, "Different nsec produces different AP MAC"); + ASSERT(strcmp(old_ssid, id3->ap_ssid) != 0, "Different nsec produces different SSID"); printf("\n--- Invalid nsec ---\n"); ret = identity_init(NULL); -- cgit v1.2.3