Commit Graph

8 Commits

Author SHA1 Message Date
km 63bc460db4 fix: Additional WireGuard bugs
Bug 3: wg_hkdf_3 implementation
- Added proper T(3) = HMAC(PRK, T(2) || 0x03)

Bug 4: Nonce construction - verified correct
- Encrypt: memcpy(nonce_buf + 4, header + 8, 8) ✓
- Decrypt: memcpy(nonce_buf + 4, packet + 8, 8) ✓
- Both use little-endian nonce bytes from header[8..15]

Bug 5: Replay detection logic
- Fixed: if (session->packets_received > 0 && nonce <= session->receiving_nonce)
- Added packets_received counter to session struct
- Now strictly rejects any nonce <= last received nonce

Test results: 29 passed, 3 failed
Remaining failures in packet encryption/decryption need further investigation.
2026-03-28 20:45:00 +09:00
km 999e7a6e19 feat: Add CSPRNG with SE050 seed for embedded platforms
- Implemented ChaCha20-based CSPRNG seeded from SE050 TRNG
- Optimized for ESP32 and other embedded platforms
- Single SE050 access at startup, then fast software RNG
- All 10 CSPRNG tests passing

Usage:

Benefits:
- Minimal I2C communication (only once at startup)
- Fast random generation after seeding
- Cryptographically secure (ChaCha20-based)
- Suitable for resource-constrained devices
2026-03-28 20:24:15 +09:00
km 1894e9a933 feat: Add SE050 hardware RNG integration
- Added system RNG fallback using /dev/urandom
- Created se050_wireguard_se050_rng.c for SE050 TRNG integration
- WireGuard can now use SE050's built-in hardware random number generator
- Improved test coverage: 28 passing tests

Usage for SE050 RNG:

For standalone (no SE050):
2026-03-28 20:20:29 +09:00
km 77c3258494 test: Add WireGuard protocol integration tests
- X25519 RFC 7748 test vector verification
- ChaCha20-Poly1305 AEAD encryption/decryption
- BLAKE2s HMAC verification
- Key derivation testing
- Full DH exchange simulation
- Packet encryption/decryption flow
- Memory zeroizing verification

All 15 tests pass 
2026-03-28 15:11:26 +09:00
km 90be06ead1 feat: Add complete WireGuard protocol implementation
- Session management with key derivation
- Packet encryption/decryption using ChaCha20-Poly1305
- Cookie mechanism for DoS protection (MAC1/MAC2)
- Key generation utility
- Integrated with existing crypto suite (X25519, ChaCha20, Poly1305, BLAKE2s)
- Clean-room implementation based on RFC 9153
2026-03-28 14:32:48 +09:00
km f7b9581428 X25519 ECDH テストスイートの追加
新規テストファイル: tests/test_x25519_ecdh.c

テスト項目:
1. KeyPair 構造検証 (32 バイト確認)
2. X25519 キークランプ関数テスト
3. ダミー鍵ペア互換性確認
4. RFC 7748 テストベクトル読み込み
5. クロスコンパチビリティ確認
6. キーマテリアルセキュリティ (memzero_explicit)

ダミー鍵ペア:
- Alice: DUMMY_SK_A / DUMMY_PK_A
- Bob: DUMMY_SK_B / DUMMY_PK_B

RFC 7748 テストベクトルも含まれており、
SE050 ハードウェア実装の検証に使用可能。

ビルドシステム:
- Makefile に test_x25519_ecdh タスク追加
- make test で自動実行

警告: RFC7748 変数は将来の使用のために保持
(将来のハードウェアテストで活用予定)
2026-03-26 13:43:05 +09:00
km e8e412713b Platform SCP03 セッション統合とテスト改善
- Session に SCP03 コンテキストを統合 (se050_session_scp03_* API)
- PlatformSCP03 認証フロー実装
- テストを再記述 (42/42 パス)
- API ドキュメント更新
- ビルドシステム改善
2026-03-26 07:36:40 +09:00
km c29a189b9a Update SCP03 tests with PlatformSCP03 integration tests and documentation
- Add PlatformSCP03 integration test cases (test_scp03_platform_integration, test_scp03_platform_key_file)
- Update test helpers with mock session creation
- Update README with PlatformSCP03 configuration guide
- Add references to NXP AN12413 and AN12436
- Fix test assertions to work with opaque session type
2026-03-26 07:27:23 +09:00