|
13 | 13 | #include <psa/crypto.h>
|
14 | 14 | #include <psa/crypto_types.h>
|
15 | 15 | #include <zephyr/sys/util.h>
|
16 |
| -#if defined(CONFIG_BOOT_SIGNATURE_USING_KMU) |
17 |
| -#include <cracen_psa_kmu.h> |
18 |
| -#endif |
19 | 16 |
|
20 | 17 | BOOT_LOG_MODULE_REGISTER(ed25519_psa);
|
21 | 18 |
|
22 | 19 | #define SHA512_DIGEST_LENGTH 64
|
23 | 20 | #define EDDSA_KEY_LENGTH 32
|
24 | 21 | #define EDDSA_SIGNAGURE_LENGTH 64
|
25 | 22 |
|
26 |
| -#if defined(CONFIG_BOOT_SIGNATURE_USING_KMU) |
27 |
| -/* List of KMU stored key ids available for MCUboot */ |
28 |
| -#define MAKE_PSA_KMU_KEY_ID(id) PSA_KEY_HANDLE_FROM_CRACEN_KMU_SLOT(CRACEN_KMU_KEY_USAGE_SCHEME_RAW, id) |
29 |
| -static psa_key_id_t kmu_key_ids[3] = { |
30 |
| - MAKE_PSA_KMU_KEY_ID(226), |
31 |
| - MAKE_PSA_KMU_KEY_ID(228), |
32 |
| - MAKE_PSA_KMU_KEY_ID(230) |
33 |
| -}; |
34 |
| - |
35 |
| -#if defined(CONFIG_BOOT_KMU_KEYS_REVOCATION) |
36 |
| -#include <bootutil/key_revocation.h> |
37 |
| -static psa_key_id_t *validated_with = NULL; |
38 |
| -#endif |
39 |
| - |
40 |
| -BUILD_ASSERT(CONFIG_BOOT_SIGNATURE_KMU_SLOTS <= ARRAY_SIZE(kmu_key_ids), |
41 |
| - "Invalid number of KMU slots, up to 3 are supported on nRF54L15"); |
42 |
| -#endif |
43 |
| - |
44 |
| -#if !defined(CONFIG_BOOT_SIGNATURE_USING_KMU) |
45 | 23 | int ED25519_verify(const uint8_t *message, size_t message_len,
|
46 | 24 | const uint8_t signature[EDDSA_SIGNAGURE_LENGTH],
|
47 | 25 | const uint8_t public_key[EDDSA_KEY_LENGTH])
|
@@ -94,75 +72,3 @@ int ED25519_verify(const uint8_t *message, size_t message_len,
|
94 | 72 |
|
95 | 73 | return ret;
|
96 | 74 | }
|
97 |
| -#else |
98 |
| -int ED25519_verify(const uint8_t *message, size_t message_len, |
99 |
| - const uint8_t signature[EDDSA_SIGNAGURE_LENGTH], |
100 |
| - const uint8_t public_key[EDDSA_KEY_LENGTH]) |
101 |
| -{ |
102 |
| - ARG_UNUSED(public_key); |
103 |
| - /* Set to any error */ |
104 |
| - psa_status_t status = PSA_ERROR_BAD_STATE; |
105 |
| - int ret = 0; /* Fail by default */ |
106 |
| - |
107 |
| - /* Initialize PSA Crypto */ |
108 |
| - status = psa_crypto_init(); |
109 |
| - if (status != PSA_SUCCESS) { |
110 |
| - BOOT_LOG_ERR("PSA crypto init failed %d", status); |
111 |
| - return 0; |
112 |
| - } |
113 |
| - |
114 |
| - status = PSA_ERROR_BAD_STATE; |
115 |
| - |
116 |
| - for (int i = 0; i < CONFIG_BOOT_SIGNATURE_KMU_SLOTS; ++i) { |
117 |
| - psa_key_id_t kid = kmu_key_ids[i]; |
118 |
| - |
119 |
| - status = psa_verify_message(kid, PSA_ALG_PURE_EDDSA, message, |
120 |
| - message_len, signature, |
121 |
| - EDDSA_SIGNAGURE_LENGTH); |
122 |
| - if (status == PSA_SUCCESS) { |
123 |
| - ret = 1; |
124 |
| -#if defined(CONFIG_BOOT_KMU_KEYS_REVOCATION) |
125 |
| - validated_with = kmu_key_ids + i; |
126 |
| -#endif |
127 |
| - break; |
128 |
| - } |
129 |
| - |
130 |
| - BOOT_LOG_ERR("ED25519 signature verification failed %d", status); |
131 |
| - } |
132 |
| - |
133 |
| - return ret; |
134 |
| -} |
135 |
| -#if defined(CONFIG_BOOT_KMU_KEYS_REVOCATION) |
136 |
| -int exec_revoke(void) |
137 |
| -{ |
138 |
| - int ret = BOOT_KEY_REVOKE_OK; |
139 |
| - psa_status_t status = psa_crypto_init(); |
140 |
| - |
141 |
| - if (!validated_with) { |
142 |
| - ret = BOOT_KEY_REVOKE_INVALID; |
143 |
| - goto out; |
144 |
| - } |
145 |
| - |
146 |
| - if (status != PSA_SUCCESS) { |
147 |
| - BOOT_LOG_ERR("PSA crypto init failed with error %d", status); |
148 |
| - ret = BOOT_KEY_REVOKE_FAILED; |
149 |
| - goto out; |
150 |
| - } |
151 |
| - for (int i = 0; i < CONFIG_BOOT_SIGNATURE_KMU_SLOTS; i++) { |
152 |
| - if ((kmu_key_ids + i) == validated_with) { |
153 |
| - break; |
154 |
| - } |
155 |
| - BOOT_LOG_DBG("Invalidating key ID %d", i); |
156 |
| - |
157 |
| - status = psa_destroy_key(kmu_key_ids[i]); |
158 |
| - if (status == PSA_SUCCESS) { |
159 |
| - BOOT_LOG_DBG("Success on key ID %d", i); |
160 |
| - } else { |
161 |
| - BOOT_LOG_ERR("Key invalidation failed with: %d", status); |
162 |
| - } |
163 |
| - } |
164 |
| -out: |
165 |
| - return ret; |
166 |
| -} |
167 |
| -#endif /* CONFIG_BOOT_KMU_KEYS_REVOCATION */ |
168 |
| -#endif |
0 commit comments