From 74789be2c3953b12ef1237d8aad400e656c760ae Mon Sep 17 00:00:00 2001 From: km Date: Thu, 26 Mar 2026 10:13:25 +0900 Subject: [PATCH] =?UTF-8?q?=E9=8D=B5=E7=AE=A1=E7=90=86=E3=81=AE=E7=B5=B1?= =?UTF-8?q?=E4=B8=80=E3=81=A8=E9=87=8D=E8=A4=87=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 共通鍵ファイル追加:include/se050_scp03_keys.h, src/se050_scp03_keys.c - test_scp03_hardware.c: 重複鍵定義削除し共通ファイルを参照 - test_scp03_se050.c: 重複鍵定義削除し共通ファイルを参照 - 鍵値はプレースホルダー (TODO: PDF から正しい値に置き換え) 構造: se050_scp03_keys.c ├─ SE050C0_ENC/MAC/DEK_KEY ├─ SE050C1_ENC/MAC/DEK_KEY └─ SE050E2_ENC/MAC/DEK_KEY --- CMakeLists.txt | 1 + Makefile | 3 +- include/se050_scp03_keys.h | 40 ++++++++++++++++++ src/se050_scp03_keys.c | 81 +++++++++++++++++++++++++++++++++++++ tests/test_scp03_hardware.c | 17 +------- tests/test_scp03_se050.c | 56 +------------------------ 6 files changed, 127 insertions(+), 71 deletions(-) create mode 100644 include/se050_scp03_keys.h create mode 100644 src/se050_scp03_keys.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 05c7a5f..7493410 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ set(SOURCES src/se050_rng.c src/se050_x25519.c src/se050_scp03.c + src/se050_scp03_keys.c ) # Create library diff --git a/Makefile b/Makefile index 8cbf9ae..68fa834 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,8 @@ SRCS = src/se050_i2c_hal.c \ src/se050_keystore.c \ src/se050_rng.c \ src/se050_x25519.c \ - src/se050_scp03.c + src/se050_scp03.c \ + src/se050_scp03_keys.c # Object files OBJS = $(SRCS:.c=.o) diff --git a/include/se050_scp03_keys.h b/include/se050_scp03_keys.h new file mode 100644 index 0000000..7176e71 --- /dev/null +++ b/include/se050_scp03_keys.h @@ -0,0 +1,40 @@ +/** + * @file se050_scp03_keys.h + * @brief SE050 Platform SCP03 Keys + * + * Platform SCP03 keys for each SE050 chip type. + * Keys should be obtained from NXP documentation or secure provisioning. + * + * License: MIT (Clean-room implementation) + */ + +#ifndef SE050_SCP03_KEYS_H +#define SE050_SCP03_KEYS_H + +#include + +/* ============================================================================ + * SE050C0 Platform SCP03 Keys + * ============================================================================ */ + +extern const uint8_t SE050C0_ENC_KEY[16]; +extern const uint8_t SE050C0_MAC_KEY[16]; +extern const uint8_t SE050C0_DEK_KEY[16]; + +/* ============================================================================ + * SE050C1 Platform SCP03 Keys + * ============================================================================ */ + +extern const uint8_t SE050C1_ENC_KEY[16]; +extern const uint8_t SE050C1_MAC_KEY[16]; +extern const uint8_t SE050C1_DEK_KEY[16]; + +/* ============================================================================ + * SE050E2 Platform SCP03 Keys + * ============================================================================ */ + +extern const uint8_t SE050E2_ENC_KEY[16]; +extern const uint8_t SE050E2_MAC_KEY[16]; +extern const uint8_t SE050E2_DEK_KEY[16]; + +#endif /* SE050_SCP03_KEYS_H */ diff --git a/src/se050_scp03_keys.c b/src/se050_scp03_keys.c new file mode 100644 index 0000000..1c9dd3f --- /dev/null +++ b/src/se050_scp03_keys.c @@ -0,0 +1,81 @@ +/** + * @file se050_scp03_keys.c + * @brief SE050 Platform SCP03 Keys Implementation + * + * Platform SCP03 keys for each SE050 chip type. + * + * IMPORTANT: These are placeholder values. Replace with actual keys from: + * - NXP documentation + * - Secure provisioning process + * - Your organization's key management system + * + * License: MIT (Clean-room implementation) + */ + +#include "se050_scp03_keys.h" + +/* ============================================================================ + * SE050C0 Platform SCP03 Keys + * + * TODO: Replace with actual keys from NXP documentation or secure provisioning + * Reference: [Add PDF reference here] + * ============================================================================ */ + +const uint8_t SE050C0_ENC_KEY[16] = { + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, + 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF +}; + +const uint8_t SE050C0_MAC_KEY[16] = { + 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, + 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 +}; + +const uint8_t SE050C0_DEK_KEY[16] = { + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF +}; + +/* ============================================================================ + * SE050C1 Platform SCP03 Keys + * + * TODO: Replace with actual keys from NXP documentation or secure provisioning + * Reference: [Add PDF reference here] + * ============================================================================ */ + +const uint8_t SE050C1_ENC_KEY[16] = { + 0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6, 0x07, 0x18, + 0x29, 0x3A, 0x4B, 0x5C, 0x6D, 0x7E, 0x8F, 0x90 +}; + +const uint8_t SE050C1_MAC_KEY[16] = { + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, + 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 +}; + +const uint8_t SE050C1_DEK_KEY[16] = { + 0x98, 0x76, 0x54, 0x32, 0x10, 0xFE, 0xDC, 0xBA, + 0x98, 0x76, 0x54, 0x32, 0x10, 0xFE, 0xDC, 0xBA +}; + +/* ============================================================================ + * SE050E2 Platform SCP03 Keys + * + * TODO: Replace with actual keys from NXP documentation or secure provisioning + * Reference: [Add PDF reference here] + * ============================================================================ */ + +const uint8_t SE050E2_ENC_KEY[16] = { + 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, + 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44 +}; + +const uint8_t SE050E2_MAC_KEY[16] = { + 0x44, 0x33, 0x22, 0x11, 0x00, 0xFF, 0xEE, 0xDD, + 0xCC, 0xBB, 0xAA, 0x99, 0x88, 0x77, 0x66, 0x55 +}; + +const uint8_t SE050E2_DEK_KEY[16] = { + 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, + 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 +}; diff --git a/tests/test_scp03_hardware.c b/tests/test_scp03_hardware.c index e05aa54..aef6940 100644 --- a/tests/test_scp03_hardware.c +++ b/tests/test_scp03_hardware.c @@ -14,22 +14,7 @@ #include #include "se050_wireguard.h" #include "se050_crypto_utils.h" - -/* SE050C0 Default Platform SCP03 Keys */ -static const uint8_t SE050C0_ENC_KEY[16] = { - 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF -}; - -static const uint8_t SE050C0_MAC_KEY[16] = { - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 -}; - -static const uint8_t SE050C0_DEK_KEY[16] = { - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF -}; +#include "se050_scp03_keys.h" /* Test result counters */ static int test_passed = 0; diff --git a/tests/test_scp03_se050.c b/tests/test_scp03_se050.c index 26f7332..b910b96 100644 --- a/tests/test_scp03_se050.c +++ b/tests/test_scp03_se050.c @@ -25,9 +25,10 @@ #include "se050_wireguard.h" #include "se050_crypto_utils.h" +#include "se050_scp03_keys.h" /* ============================================================================ - * SE050 Chip Selection (compile-time) + * Chip Selection and Key Mapping * ============================================================================ */ #ifndef SE050_CHIP @@ -61,59 +62,6 @@ #error "Invalid SE050_CHIP. Use SE050C0, SE050C1, or SE050E2" #endif -/* ============================================================================ - * Platform SCP03 Keys per Chip Type - * Each chip type has its own 3-key set (ENC, MAC, DEK) - * ============================================================================ */ - -/* SE050C0 Platform SCP03 Keys */ -static const uint8_t SE050C0_ENC_KEY[16] = { - 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, - 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF -}; - -static const uint8_t SE050C0_MAC_KEY[16] = { - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, - 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10 -}; - -static const uint8_t SE050C0_DEK_KEY[16] = { - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF -}; - -/* SE050C1 Platform SCP03 Keys */ -static const uint8_t SE050C1_ENC_KEY[16] = { - 0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6, 0x07, 0x18, - 0x29, 0x3A, 0x4B, 0x5C, 0x6D, 0x7E, 0x8F, 0x90 -}; - -static const uint8_t SE050C1_MAC_KEY[16] = { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, - 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 -}; - -static const uint8_t SE050C1_DEK_KEY[16] = { - 0x98, 0x76, 0x54, 0x32, 0x10, 0xFE, 0xDC, 0xBA, - 0x98, 0x76, 0x54, 0x32, 0x10, 0xFE, 0xDC, 0xBA -}; - -/* SE050E2 Platform SCP03 Keys */ -static const uint8_t SE050E2_ENC_KEY[16] = { - 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, - 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44 -}; - -static const uint8_t SE050E2_MAC_KEY[16] = { - 0x44, 0x33, 0x22, 0x11, 0x00, 0xFF, 0xEE, 0xDD, - 0xCC, 0xBB, 0xAA, 0x99, 0x88, 0x77, 0x66, 0x55 -}; - -static const uint8_t SE050E2_DEK_KEY[16] = { - 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, - 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 -}; - /* ============================================================================ * Test Result Tracking * ============================================================================ */