3737#include "image.h"
3838#include "loader.h"
3939
40+ static uint8_t key_buffer [2 * sizeof (ecc_key )];
41+
4042void print_buf (uint8_t * buf , int len )
4143{
4244 int i ;
@@ -76,7 +78,7 @@ int main(int argc, char *argv[])
7678 char in_name [PATH_MAX ];
7779 char signed_name [PATH_MAX ];
7880 char * dot ;
79- ecc_key key ;
81+ ecc_key * key = ( ecc_key * ) key_buffer ;
8082 Sha256 sha ;
8183 Sha256 keyhash ;
8284 uint8_t shabuf [SHA256_DIGEST_SIZE ];
@@ -132,17 +134,17 @@ int main(int argc, char *argv[])
132134 perror (argv [2 ]);
133135 exit (2 );
134136 }
135- wc_ecc_init (& key );
137+ wc_ecc_init (key );
136138 r = read (key_fd , inkey , 3 * ECC_KEY_SIZE );
137139 if (r < 0 ) {
138140 perror ("read" );
139141 exit (3 );
140142 }
141- r = wc_ecc_import_unsigned (& key , inkey , inkey + ECC_KEY_SIZE , inkey + 2 * ECC_KEY_SIZE , ECC_SECP256R1 );
143+ r = wc_ecc_import_unsigned (key , inkey , inkey + ECC_KEY_SIZE , inkey + 2 * ECC_KEY_SIZE , ECC_SECP256R1 );
142144 if (r < 0 ) {
143145 printf ("Errror importing key\n" );
144146 }
145- printf ("key.type = %d\n" , key . type );
147+ printf ("key.type = %d\n" , key -> type );
146148 close (key_fd );
147149
148150
@@ -183,11 +185,11 @@ int main(int argc, char *argv[])
183185 break ;
184186 }
185187 wc_Sha256Final (& sha , shabuf );
186- if (wc_ecc_sign_hash_ex (shabuf , SHA256_DIGEST_SIZE , & rng , & key , & mpr , & mps ) != MP_OKAY ) {
188+ if (wc_ecc_sign_hash_ex (shabuf , SHA256_DIGEST_SIZE , & rng , key , & mpr , & mps ) != MP_OKAY ) {
187189 printf ("Error signing hash\n" );
188190 exit (1 );
189191 }
190- if (wc_ecc_verify_hash_ex (& mpr , & mps , shabuf , SHA256_DIGEST_SIZE , & res , & key ) != MP_OKAY ) {
192+ if (wc_ecc_verify_hash_ex (& mpr , & mps , shabuf , SHA256_DIGEST_SIZE , & res , key ) != MP_OKAY ) {
191193 printf ("Error verifying hash\n" );
192194 exit (1 );
193195 }
@@ -205,7 +207,7 @@ int main(int argc, char *argv[])
205207
206208#ifdef VERIFY_SIGNATURE_TEST
207209 {
208- ecc_key pubk ;
210+ ecc_key * pubk = ( ecc_key * ) key_buffer ;
209211 int ret ;
210212 int fd ;
211213 mp_int r , s ;
@@ -216,7 +218,7 @@ int main(int argc, char *argv[])
216218 mp_read_unsigned_bin (& r , signature , ECC_KEY_SIZE );
217219 mp_read_unsigned_bin (& s , signature + ECC_KEY_SIZE , ECC_KEY_SIZE );
218220
219- ret = wc_ecc_init (& pubk );
221+ ret = wc_ecc_init (pubk );
220222 if (ret < 0 )
221223 {
222224 perror ("initializing ecc key" );
@@ -234,13 +236,13 @@ int main(int argc, char *argv[])
234236 exit (2 );
235237 }
236238
237- ret = wc_ecc_import_unsigned (& pubk , pubk_buf , pubk_buf + ECC_KEY_SIZE , NULL , ECC_SECP256R1 );
239+ ret = wc_ecc_import_unsigned (pubk , pubk_buf , pubk_buf + ECC_KEY_SIZE , NULL , ECC_SECP256R1 );
238240 if (ret != MP_OKAY ) {
239241 perror ("importing public key" );
240242 exit (2 );
241243 }
242- printf ("pubkey.type = %d\n" , pubk . type );
243- ret = wc_ecc_verify_hash_ex (& r , & s , shabuf , SHA256_DIGEST_SIZE , & res , & pubk );
244+ printf ("pubkey.type = %d\n" , pubk -> type );
245+ ret = wc_ecc_verify_hash_ex (& r , & s , shabuf , SHA256_DIGEST_SIZE , & res , pubk );
244246 if (ret != MP_OKAY ) {
245247 printf ("Verify operation failed.\n" );
246248 } else if (res == 0 ) {
0 commit comments