@@ -240,11 +240,12 @@ static int _ecc_issue108(void)
240240}
241241
242242/* https://github.com/libtom/libtomcrypt/issues/443 */
243- static int _ecc_issue443 (void )
243+ /* https://github.com/libtom/libtomcrypt/issues/447 */
244+ static int _ecc_issue443_447 (void )
244245{
245246 const ltc_ecc_curve * cu ;
246247 ecc_key key ;
247- int stat = 0 ;
248+ int err , stat = 0 ;
248249 unsigned char hash [64 ];
249250 unsigned long hashlen ;
250251 const unsigned char msg [] = { 0x54 ,0x65 ,0x73 ,0x74 };
@@ -274,18 +275,18 @@ static int _ecc_issue443(void)
274275 DO (ecc_find_curve ("secp256r1" , & cu ));
275276 DO (ecc_set_curve (cu , & key ));
276277 DO (ecc_set_key (pub1 , sizeof (pub1 ), PK_PUBLIC , & key ));
277- DO ( ecc_verify_hash_rfc7518 (sig1 , sizeof (sig1 ), hash , hashlen , & stat , & key ));
278+ err = ecc_verify_hash_rfc7518 (sig1 , sizeof (sig1 ), hash , hashlen , & stat , & key ); /* should fail */
278279 ecc_free (& key );
279- if (stat != 1 ) return CRYPT_FAIL_TESTVECTOR ;
280+ if (err != CRYPT_INVALID_PACKET ) return CRYPT_FAIL_TESTVECTOR ;
280281
281282 hashlen = sizeof (hash );
282283 DO (hash_memory (find_hash ("sha512" ), msg , sizeof (msg ), hash , & hashlen ));
283284 DO (ecc_find_curve ("secp521r1" , & cu ));
284285 DO (ecc_set_curve (cu , & key ));
285286 DO (ecc_set_key (pub2 , sizeof (pub2 ), PK_PUBLIC , & key ));
286- DO ( ecc_verify_hash_rfc7518 (sig2 , sizeof (sig2 ), hash , hashlen , & stat , & key ));
287+ err = ecc_verify_hash_rfc7518 (sig2 , sizeof (sig2 ), hash , hashlen , & stat , & key ); /* should fail */
287288 ecc_free (& key );
288- if (stat != 1 ) return CRYPT_FAIL_TESTVECTOR ;
289+ if (err != CRYPT_INVALID_PACKET ) return CRYPT_FAIL_TESTVECTOR ;
289290
290291 return CRYPT_OK ;
291292}
@@ -1598,7 +1599,7 @@ int ecc_tests(void)
15981599 DO (_ecc_import_export ());
15991600 DO (_ecc_test_mp ());
16001601 DO (_ecc_issue108 ());
1601- DO (_ecc_issue443 ());
1602+ DO (_ecc_issue443_447 ());
16021603#ifdef LTC_ECC_SHAMIR
16031604 DO (_ecc_test_shamir ());
16041605 DO (_ecc_test_recovery ());
0 commit comments