25
25
#include "bootutil/crypto/sha.h"
26
26
27
27
#define EDDSA_SIGNATURE_LENGTH 64
28
-
29
- static const uint8_t ed25519_pubkey_oid [] = MBEDTLS_OID_ISO_IDENTIFIED_ORG "\x65\x70" ;
30
28
#define NUM_ED25519_BYTES 32
31
29
32
30
extern int ED25519_verify (const uint8_t * message , size_t message_len ,
33
31
const uint8_t signature [EDDSA_SIGNATURE_LENGTH ],
34
32
const uint8_t public_key [NUM_ED25519_BYTES ]);
35
33
34
+ #if !defined(CONFIG_BOOT_SIGNATURE_USING_KMU )
35
+
36
+ static const uint8_t ed25519_pubkey_oid [] = MBEDTLS_OID_ISO_IDENTIFIED_ORG "\x65\x70" ;
37
+
36
38
/*
37
39
* Parse the public key used for signing.
38
40
*/
@@ -71,21 +73,25 @@ bootutil_import_key(uint8_t **cp, uint8_t *end)
71
73
72
74
return 0 ;
73
75
}
76
+ #endif
74
77
75
78
fih_ret
76
79
bootutil_verify_sig (uint8_t * hash , uint32_t hlen , uint8_t * sig , size_t slen ,
77
80
uint8_t key_id )
78
81
{
79
82
int rc ;
80
83
FIH_DECLARE (fih_rc , FIH_FAILURE );
81
- uint8_t * pubkey ;
84
+ uint8_t * pubkey = NULL ;
85
+ #if !defined(CONFIG_BOOT_SIGNATURE_USING_KMU )
82
86
uint8_t * end ;
87
+ #endif
83
88
84
89
if (hlen != IMAGE_HASH_SIZE || slen != EDDSA_SIGNATURE_LENGTH ) {
85
90
FIH_SET (fih_rc , FIH_FAILURE );
86
91
goto out ;
87
92
}
88
93
94
+ #if !defined(CONFIG_BOOT_SIGNATURE_USING_KMU )
89
95
pubkey = (uint8_t * )bootutil_keys [key_id ].key ;
90
96
end = pubkey + * bootutil_keys [key_id ].len ;
91
97
@@ -94,6 +100,7 @@ bootutil_verify_sig(uint8_t *hash, uint32_t hlen, uint8_t *sig, size_t slen,
94
100
FIH_SET (fih_rc , FIH_FAILURE );
95
101
goto out ;
96
102
}
103
+ #endif
97
104
98
105
rc = ED25519_verify (hash , IMAGE_HASH_SIZE , sig , pubkey );
99
106
@@ -115,14 +122,17 @@ bootutil_verify_img(const uint8_t *img, uint32_t size,
115
122
{
116
123
int rc ;
117
124
FIH_DECLARE (fih_rc , FIH_FAILURE );
118
- uint8_t * pubkey ;
125
+ uint8_t * pubkey = NULL ;
126
+ #if !defined(CONFIG_BOOT_SIGNATURE_USING_KMU )
119
127
uint8_t * end ;
128
+ #endif
120
129
121
130
if (slen != EDDSA_SIGNATURE_LENGTH ) {
122
131
FIH_SET (fih_rc , FIH_FAILURE );
123
132
goto out ;
124
133
}
125
134
135
+ #if !defined(CONFIG_BOOT_SIGNATURE_USING_KMU )
126
136
pubkey = (uint8_t * )bootutil_keys [key_id ].key ;
127
137
end = pubkey + * bootutil_keys [key_id ].len ;
128
138
@@ -131,6 +141,7 @@ bootutil_verify_img(const uint8_t *img, uint32_t size,
131
141
FIH_SET (fih_rc , FIH_FAILURE );
132
142
goto out ;
133
143
}
144
+ #endif
134
145
135
146
rc = ED25519_verify (img , size , sig , pubkey );
136
147
0 commit comments