@@ -1353,7 +1353,8 @@ static int hashing(void) {
13531353 int code = RLC_ERR ;
13541354 ep_t a ;
13551355 bn_t n ;
1356- uint8_t msg [5 ];
1356+ /* Allocate buffer with plenty of room. */
1357+ uint8_t msg [4 * RLC_FP_BYTES ];
13571358
13581359 ep_null (a );
13591360 bn_null (n );
@@ -1365,12 +1366,12 @@ static int hashing(void) {
13651366 ep_curve_get_ord (n );
13661367
13671368 TEST_CASE ("point hashing is correct" ) {
1368- rand_bytes (msg , sizeof ( msg ));
1369- ep_map (a , msg , sizeof ( msg ));
1369+ rand_bytes (msg , ep_map_rnd_size ( ));
1370+ ep_map (a , msg , ep_map_rnd_size ( ));
13701371 TEST_ASSERT (ep_on_curve (a ) && ep_is_infty (a ) == 0 , end );
13711372 ep_mul (a , a , n );
13721373 TEST_ASSERT (ep_on_curve (a ) && ep_is_infty (a ) == 1 , end );
1373- ep_map_rnd (a , msg , sizeof ( msg ));
1374+ ep_map_rnd (a , msg , ep_map_rnd_size ( ));
13741375 TEST_ASSERT (ep_on_curve (a ) && ep_is_infty (a ) == 0 , end );
13751376 ep_mul (a , a , n );
13761377 TEST_ASSERT (ep_on_curve (a ) && ep_is_infty (a ) == 1 , end );
@@ -1379,8 +1380,8 @@ static int hashing(void) {
13791380
13801381#if EP_MAP == BASIC || !defined(STRIP )
13811382 TEST_CASE ("basic point hashing is correct" ) {
1382- rand_bytes (msg , sizeof ( msg ));
1383- ep_map_basic (a , msg , sizeof ( msg ));
1383+ rand_bytes (msg , ep_map_rnd_size ( ));
1384+ ep_map_basic (a , msg , ep_map_rnd_size ( ));
13841385 TEST_ASSERT (ep_on_curve (a ) && ep_is_infty (a ) == 0 , end );
13851386 ep_mul (a , a , n );
13861387 TEST_ASSERT (ep_on_curve (a ) && ep_is_infty (a ) == 1 , end );
@@ -1390,8 +1391,8 @@ static int hashing(void) {
13901391
13911392#if EP_MAP == SSWUM || !defined(STRIP )
13921393 TEST_CASE ("simplified SWU point hashing is correct" ) {
1393- rand_bytes (msg , sizeof ( msg ));
1394- ep_map_sswum (a , msg , sizeof ( msg ));
1394+ rand_bytes (msg , ep_map_rnd_size ( ));
1395+ ep_map_sswum (a , msg , ep_map_rnd_size ( ));
13951396 TEST_ASSERT (ep_on_curve (a ) && ep_is_infty (a ) == 0 , end );
13961397 ep_mul (a , a , n );
13971398 TEST_ASSERT (ep_on_curve (a ) && ep_is_infty (a ) == 1 , end );
@@ -1403,8 +1404,8 @@ static int hashing(void) {
14031404 if (!ep_curve_is_super ()) {
14041405 if (ep_curve_opt_a () == RLC_ZERO || ep_curve_opt_b () == RLC_ZERO ) {
14051406 TEST_CASE ("swift point hashing is correct" ) {
1406- rand_bytes (msg , sizeof ( msg ));
1407- ep_map_swift (a , msg , sizeof ( msg ));
1407+ rand_bytes (msg , ep_map_rnd_size ( ));
1408+ ep_map_swift (a , msg , ep_map_rnd_size ( ));
14081409 TEST_ASSERT (ep_on_curve (a ) && ep_is_infty (a ) == 0 , end );
14091410 ep_mul (a , a , n );
14101411 TEST_ASSERT (ep_on_curve (a ) && ep_is_infty (a ) == 1 , end );
0 commit comments