diff options
| author | Your Name <you@example.com> | 2026-05-17 01:33:11 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-17 01:33:11 +0530 |
| commit | 72f7b68b93ed6b237775eb2caf516a1503675614 (patch) | |
| tree | c60c860ea460b8e0a99982bd3adc26f7113657df | |
| parent | 347d29658959c7e4b368a15134c183f4ce7a25bc (diff) | |
test_identity: 24/24 passing — HMAC-SHA512 derivation, MAC bits, SSID/IP determinism
| -rw-r--r-- | tests/unit/stubs/esp_netif.h | 13 | ||||
| -rwxr-xr-x | tests/unit/test_identity | bin | 0 -> 296504 bytes | |||
| -rw-r--r-- | tests/unit/test_identity.c | 12 |
3 files changed, 10 insertions, 15 deletions
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 @@ | |||
| 1 | #ifndef STUBS_ESP_NETIF_H | 1 | #ifndef STUBS_ESP_NETIF_H |
| 2 | #define STUBS_ESP_NETIF_H | 2 | #define STUBS_ESP_NETIF_H |
| 3 | 3 | ||
| 4 | #include <stdint.h> | 4 | #include "lwip/ip4_addr.h" |
| 5 | |||
| 6 | typedef struct { | ||
| 7 | uint32_t addr; | ||
| 8 | } esp_ip4_addr_t; | ||
| 9 | |||
| 10 | #define IPSTR "%d.%d.%d.%d" | ||
| 11 | #define IP2STR(ip) ((ip)->addr & 0xff), (((ip)->addr >> 8) & 0xff), (((ip)->addr >> 16) & 0xff), (((ip)->addr >> 24) & 0xff) | ||
| 12 | |||
| 13 | static inline void IP4_ADDR(esp_ip4_addr_t *ip, uint8_t a, uint8_t b, uint8_t c, uint8_t d) { | ||
| 14 | ip->addr = ((uint32_t)a) | ((uint32_t)b << 8) | ((uint32_t)c << 16) | ((uint32_t)d << 24); | ||
| 15 | } | ||
| 16 | 5 | ||
| 17 | #endif | 6 | #endif |
diff --git a/tests/unit/test_identity b/tests/unit/test_identity new file mode 100755 index 0000000..c89de17 --- /dev/null +++ b/tests/unit/test_identity | |||
| Binary files 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) | |||
| 49 | ASSERT_EQ_STR(id->ap_ssid, id2->ap_ssid, "SSID is deterministic"); | 49 | ASSERT_EQ_STR(id->ap_ssid, id2->ap_ssid, "SSID is deterministic"); |
| 50 | 50 | ||
| 51 | printf("\n--- Different nsec produces different identity ---\n"); | 51 | printf("\n--- Different nsec produces different identity ---\n"); |
| 52 | uint8_t old_sta[6], old_ap[6]; | ||
| 53 | char old_ssid[32]; | ||
| 54 | memcpy(old_sta, id2->sta_mac, 6); | ||
| 55 | memcpy(old_ap, id2->ap_mac, 6); | ||
| 56 | strncpy(old_ssid, id2->ap_ssid, sizeof(old_ssid)); | ||
| 57 | |||
| 52 | ret = identity_init(TEST_NSEC2); | 58 | ret = identity_init(TEST_NSEC2); |
| 53 | ASSERT_EQ_INT(ESP_OK, ret, "Init with different nsec succeeds"); | 59 | ASSERT_EQ_INT(ESP_OK, ret, "Init with different nsec succeeds"); |
| 54 | const tollgate_identity_t *id3 = identity_get(); | 60 | const tollgate_identity_t *id3 = identity_get(); |
| 55 | ASSERT(memcmp(id->sta_mac, id3->sta_mac, 6) != 0, "Different nsec produces different STA MAC"); | 61 | ASSERT(memcmp(old_sta, id3->sta_mac, 6) != 0, "Different nsec produces different STA MAC"); |
| 56 | ASSERT(memcmp(id->ap_mac, id3->ap_mac, 6) != 0, "Different nsec produces different AP MAC"); | 62 | ASSERT(memcmp(old_ap, id3->ap_mac, 6) != 0, "Different nsec produces different AP MAC"); |
| 57 | ASSERT(strcmp(id->ap_ssid, id3->ap_ssid) != 0, "Different nsec produces different SSID"); | 63 | ASSERT(strcmp(old_ssid, id3->ap_ssid) != 0, "Different nsec produces different SSID"); |
| 58 | 64 | ||
| 59 | printf("\n--- Invalid nsec ---\n"); | 65 | printf("\n--- Invalid nsec ---\n"); |
| 60 | ret = identity_init(NULL); | 66 | ret = identity_init(NULL); |