@@ -198,6 +198,31 @@ static int s_ecc_test_shamir(void)
198198}
199199#endif
200200
201+ /* https://github.com/libtom/libtomcrypt/issues/630 */
202+ static int s_ecc_issue630 (void )
203+ {
204+ unsigned char protected_buffer [30 ], protected_buffer_copy [30 ];
205+ unsigned long keylen = 0 ;
206+ ecc_key key ;
207+ int low , high ;
208+
209+ ecc_sizes (& low , & high );
210+
211+ DO (ecc_make_key (& yarrow_prng , find_prng ("yarrow" ), high , & key ));
212+ if (yarrow_read (protected_buffer , sizeof (protected_buffer ), & yarrow_prng ) != sizeof (protected_buffer )) {
213+ return CRYPT_ERROR_READPRNG ;
214+ }
215+ XMEMCPY (protected_buffer_copy , protected_buffer , sizeof (protected_buffer ));
216+ COMPARE_TESTVECTOR (protected_buffer , sizeof (protected_buffer ), protected_buffer_copy , sizeof (protected_buffer ), "Ensure copy is equal" , 0 );
217+
218+ keylen = 10 ;
219+ SHOULD_FAIL (ecc_get_key (& protected_buffer [10 ], & keylen , PK_PRIVATE , & key ));
220+ COMPARE_TESTVECTOR (protected_buffer , 10 , protected_buffer_copy , 10 , "Start canary" , 1 );
221+ COMPARE_TESTVECTOR (& protected_buffer [20 ], 10 , & protected_buffer [20 ], 10 , "End canary" , 2 );
222+ ecc_free (& key );
223+ return 0 ;
224+ }
225+
201226/* https://github.com/libtom/libtomcrypt/issues/108 */
202227static int s_ecc_issue108 (void )
203228{
@@ -1591,6 +1616,7 @@ int ecc_test(void)
15911616 DO (s_ecc_test_mp ());
15921617 DO (s_ecc_issue108 ());
15931618 DO (s_ecc_issue443_447 ());
1619+ DO (s_ecc_issue630 ());
15941620#ifdef LTC_ECC_SHAMIR
15951621 DO (s_ecc_test_shamir ());
15961622 DO (s_ecc_test_recovery ());
0 commit comments