@@ -240,11 +240,12 @@ static int _ecc_issue108(void)
240
240
}
241
241
242
242
/* 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 )
244
245
{
245
246
const ltc_ecc_curve * cu ;
246
247
ecc_key key ;
247
- int stat = 0 ;
248
+ int err , stat = 0 ;
248
249
unsigned char hash [64 ];
249
250
unsigned long hashlen ;
250
251
const unsigned char msg [] = { 0x54 ,0x65 ,0x73 ,0x74 };
@@ -274,18 +275,18 @@ static int _ecc_issue443(void)
274
275
DO (ecc_find_curve ("secp256r1" , & cu ));
275
276
DO (ecc_set_curve (cu , & key ));
276
277
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 */
278
279
ecc_free (& key );
279
- if (stat != 1 ) return CRYPT_FAIL_TESTVECTOR ;
280
+ if (err != CRYPT_INVALID_PACKET ) return CRYPT_FAIL_TESTVECTOR ;
280
281
281
282
hashlen = sizeof (hash );
282
283
DO (hash_memory (find_hash ("sha512" ), msg , sizeof (msg ), hash , & hashlen ));
283
284
DO (ecc_find_curve ("secp521r1" , & cu ));
284
285
DO (ecc_set_curve (cu , & key ));
285
286
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 */
287
288
ecc_free (& key );
288
- if (stat != 1 ) return CRYPT_FAIL_TESTVECTOR ;
289
+ if (err != CRYPT_INVALID_PACKET ) return CRYPT_FAIL_TESTVECTOR ;
289
290
290
291
return CRYPT_OK ;
291
292
}
@@ -1598,7 +1599,7 @@ int ecc_tests(void)
1598
1599
DO (_ecc_import_export ());
1599
1600
DO (_ecc_test_mp ());
1600
1601
DO (_ecc_issue108 ());
1601
- DO (_ecc_issue443 ());
1602
+ DO (_ecc_issue443_447 ());
1602
1603
#ifdef LTC_ECC_SHAMIR
1603
1604
DO (_ecc_test_shamir ());
1604
1605
DO (_ecc_test_recovery ());
0 commit comments