Latest update.
This commit is contained in:
+26
-10
@@ -8,6 +8,14 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* We need access to the deprecated EC_POINTs_mul for testing purposes
|
||||
* when the deprecated calls are not hidden
|
||||
*/
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
# define OPENSSL_SUPPRESS_DEPRECATED
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "internal/nelem.h"
|
||||
#include "testutil.h"
|
||||
@@ -64,8 +72,10 @@ static int group_order_tests(EC_GROUP *group)
|
||||
goto err;
|
||||
|
||||
for (i = 1; i <= 2; i++) {
|
||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
const BIGNUM *scalars[6];
|
||||
const EC_POINT *points[6];
|
||||
# endif
|
||||
|
||||
if (!TEST_true(BN_set_word(n1, i))
|
||||
/*
|
||||
@@ -97,11 +107,11 @@ static int group_order_tests(EC_GROUP *group)
|
||||
/* Add P to verify the result. */
|
||||
|| !TEST_true(EC_POINT_add(group, Q, Q, P, ctx))
|
||||
|| !TEST_true(EC_POINT_is_at_infinity(group, Q))
|
||||
|
||||
/* Exercise EC_POINTs_mul, including corner cases. */
|
||||
|| !TEST_false(EC_POINT_is_at_infinity(group, P)))
|
||||
goto err;
|
||||
|
||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
/* Exercise EC_POINTs_mul, including corner cases. */
|
||||
scalars[0] = scalars[1] = BN_value_one();
|
||||
points[0] = points[1] = P;
|
||||
|
||||
@@ -125,6 +135,7 @@ static int group_order_tests(EC_GROUP *group)
|
||||
if (!TEST_true(EC_POINTs_mul(group, P, NULL, 6, points, scalars, ctx))
|
||||
|| !TEST_true(EC_POINT_is_at_infinity(group, P)))
|
||||
goto err;
|
||||
# endif
|
||||
}
|
||||
|
||||
r = 1;
|
||||
@@ -152,8 +163,10 @@ static int prime_field_tests(void)
|
||||
*P_256 = NULL, *P_384 = NULL, *P_521 = NULL;
|
||||
EC_POINT *P = NULL, *Q = NULL, *R = NULL;
|
||||
BIGNUM *x = NULL, *y = NULL, *z = NULL, *yplusone = NULL;
|
||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
const EC_POINT *points[4];
|
||||
const BIGNUM *scalars[4];
|
||||
# endif
|
||||
unsigned char buf[100];
|
||||
size_t len, r = 0;
|
||||
int k;
|
||||
@@ -548,6 +561,9 @@ static int prime_field_tests(void)
|
||||
|| !TEST_true(EC_POINT_is_at_infinity(group, R)) /* R = P + 2Q */
|
||||
|| !TEST_false(EC_POINT_is_at_infinity(group, Q)))
|
||||
goto err;
|
||||
|
||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
TEST_note("combined multiplication ...");
|
||||
points[0] = Q;
|
||||
points[1] = Q;
|
||||
points[2] = Q;
|
||||
@@ -558,11 +574,10 @@ static int prime_field_tests(void)
|
||||
|| !TEST_BN_even(y)
|
||||
|| !TEST_true(BN_rshift1(y, y)))
|
||||
goto err;
|
||||
|
||||
scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */
|
||||
scalars[1] = y;
|
||||
|
||||
TEST_note("combined multiplication ...");
|
||||
|
||||
/* z is still the group order */
|
||||
if (!TEST_true(EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx))
|
||||
|| !TEST_true(EC_POINTs_mul(group, R, z, 2, points, scalars, ctx))
|
||||
@@ -593,10 +608,8 @@ static int prime_field_tests(void)
|
||||
if (!TEST_true(EC_POINTs_mul(group, P, NULL, 4, points, scalars, ctx))
|
||||
|| !TEST_true(EC_POINT_is_at_infinity(group, P)))
|
||||
goto err;
|
||||
|
||||
# endif
|
||||
TEST_note(" ok\n");
|
||||
|
||||
|
||||
r = 1;
|
||||
err:
|
||||
BN_CTX_free(ctx);
|
||||
@@ -803,8 +816,10 @@ static int char2_curve_test(int n)
|
||||
BIGNUM *x = NULL, *y = NULL, *z = NULL, *cof = NULL, *yplusone = NULL;
|
||||
EC_GROUP *group = NULL, *variable = NULL;
|
||||
EC_POINT *P = NULL, *Q = NULL, *R = NULL;
|
||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
const EC_POINT *points[3];
|
||||
const BIGNUM *scalars[3];
|
||||
# endif
|
||||
struct c2_curve_test *const test = char2_curve_tests + n;
|
||||
|
||||
if (!TEST_ptr(ctx = BN_CTX_new())
|
||||
@@ -888,6 +903,8 @@ static int char2_curve_test(int n)
|
||||
|| !TEST_false(EC_POINT_is_at_infinity(group, Q)))
|
||||
goto err;
|
||||
|
||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
TEST_note("combined multiplication ...");
|
||||
points[0] = Q;
|
||||
points[1] = Q;
|
||||
points[2] = Q;
|
||||
@@ -899,8 +916,6 @@ static int char2_curve_test(int n)
|
||||
scalars[0] = y; /* (group order + 1)/2, so y*Q + y*Q = Q */
|
||||
scalars[1] = y;
|
||||
|
||||
TEST_note("combined multiplication ...");
|
||||
|
||||
/* z is still the group order */
|
||||
if (!TEST_true(EC_POINTs_mul(group, P, NULL, 2, points, scalars, ctx))
|
||||
|| !TEST_true(EC_POINTs_mul(group, R, z, 2, points, scalars, ctx))
|
||||
@@ -929,7 +944,8 @@ static int char2_curve_test(int n)
|
||||
|
||||
if (!TEST_true(EC_POINTs_mul(group, P, NULL, 3, points, scalars, ctx))
|
||||
|| !TEST_true(EC_POINT_is_at_infinity(group, P)))
|
||||
goto err;;
|
||||
goto err;
|
||||
# endif
|
||||
}
|
||||
|
||||
r = 1;
|
||||
|
||||
Reference in New Issue
Block a user