@@ -198,6 +198,31 @@ static int s_ecc_test_shamir(void)
198
198
}
199
199
#endif
200
200
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
+
201
226
/* https://github.com/libtom/libtomcrypt/issues/108 */
202
227
static int s_ecc_issue108 (void )
203
228
{
@@ -1591,6 +1616,7 @@ int ecc_test(void)
1591
1616
DO (s_ecc_test_mp ());
1592
1617
DO (s_ecc_issue108 ());
1593
1618
DO (s_ecc_issue443_447 ());
1619
+ DO (s_ecc_issue630 ());
1594
1620
#ifdef LTC_ECC_SHAMIR
1595
1621
DO (s_ecc_test_shamir ());
1596
1622
DO (s_ecc_test_recovery ());
0 commit comments