@@ -118,76 +118,7 @@ BOOT_LOG_MODULE_DECLARE(mcuboot);
118
118
# define KEY_BUF_SIZE (SIG_BUF_SIZE + 24)
119
119
#endif /* !MCUBOOT_HW_KEY */
120
120
121
- #if !defined(CONFIG_BOOT_SIGNATURE_USING_KMU )
122
- #if !defined(MCUBOOT_HW_KEY )
123
- static int
124
- bootutil_find_key (uint8_t * keyhash , uint8_t keyhash_len )
125
- {
126
- bootutil_sha_context sha_ctx ;
127
- int i ;
128
- const struct bootutil_key * key ;
129
- uint8_t hash [IMAGE_HASH_SIZE ];
130
-
131
- BOOT_LOG_DBG ("bootutil_find_key" );
132
-
133
- if (keyhash_len > IMAGE_HASH_SIZE ) {
134
- return -1 ;
135
- }
136
-
137
- for (i = 0 ; i < bootutil_key_cnt ; i ++ ) {
138
- key = & bootutil_keys [i ];
139
- bootutil_sha_init (& sha_ctx );
140
- bootutil_sha_update (& sha_ctx , key -> key , * key -> len );
141
- bootutil_sha_finish (& sha_ctx , hash );
142
- bootutil_sha_drop (& sha_ctx );
143
- if (!memcmp (hash , keyhash , keyhash_len )) {
144
- return i ;
145
- }
146
- }
147
- return -1 ;
148
- }
149
- #else /* !MCUBOOT_HW_KEY */
150
- extern unsigned int pub_key_len ;
151
- static int
152
- bootutil_find_key (uint8_t image_index , uint8_t * key , uint16_t key_len )
153
- {
154
- bootutil_sha_context sha_ctx ;
155
- uint8_t hash [IMAGE_HASH_SIZE ];
156
- uint8_t key_hash [IMAGE_HASH_SIZE ];
157
- size_t key_hash_size = sizeof (key_hash );
158
- int rc ;
159
- FIH_DECLARE (fih_rc , FIH_FAILURE );
160
-
161
- BOOT_LOG_DBG ("bootutil_find_key: image_index %d" , image_index );
162
-
163
- bootutil_sha_init (& sha_ctx );
164
- bootutil_sha_update (& sha_ctx , key , key_len );
165
- bootutil_sha_finish (& sha_ctx , hash );
166
- bootutil_sha_drop (& sha_ctx );
167
-
168
- rc = boot_retrieve_public_key_hash (image_index , key_hash , & key_hash_size );
169
- if (rc ) {
170
- return -1 ;
171
- }
172
-
173
- /* Adding hardening to avoid this potential attack:
174
- * - Image is signed with an arbitrary key and the corresponding public
175
- * key is added as a TLV field.
176
- * - During public key validation (comparing against key-hash read from
177
- * HW) a fault is injected to accept the public key as valid one.
178
- */
179
- FIH_CALL (boot_fih_memequal , fih_rc , hash , key_hash , key_hash_size );
180
- if (FIH_EQ (fih_rc , FIH_SUCCESS )) {
181
- bootutil_keys [0 ].key = key ;
182
- pub_key_len = key_len ;
183
- return 0 ;
184
- }
185
-
186
- return -1 ;
187
- }
188
- #endif /* !MCUBOOT_HW_KEY */
189
121
#endif /* !MCUBOOT_BUILTIN_KEY */
190
- #endif /* !defined(CONFIG_BOOT_SIGNATURE_USING_KMU) */
191
122
#endif /* EXPECTED_SIG_TLV */
192
123
193
124
#if defined(MCUBOOT_SIGN_PURE )
0 commit comments