diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2023-04-17 20:41:03 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2023-04-17 20:41:03 +0000 |
commit | 443f7869c1b36be6b10cda9e2769e5e025ae507e (patch) | |
tree | c9f8b434f2f765af71e6688fd64c55dc368515b5 /regress | |
parent | 8ea73d820e49c720065baa7d75d90c5641766936 (diff) |
Switch all ec tests to using dynamic linking
This only requires very minor changes and simplifies testing quite a bit.
Some of the changes can be undone after the next bump.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/lib/libcrypto/ec/Makefile | 4 | ||||
-rw-r--r-- | regress/lib/libcrypto/ec/ec_point_conversion.c | 8 | ||||
-rw-r--r-- | regress/lib/libcrypto/ec/ectest.c | 10 |
3 files changed, 14 insertions, 8 deletions
diff --git a/regress/lib/libcrypto/ec/Makefile b/regress/lib/libcrypto/ec/Makefile index 081eeb56bd0..0826b44a25d 100644 --- a/regress/lib/libcrypto/ec/Makefile +++ b/regress/lib/libcrypto/ec/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.7 2023/04/17 20:36:08 tb Exp $ +# $OpenBSD: Makefile,v 1.8 2023/04/17 20:41:02 tb Exp $ PROGS += ectest PROGS += ec_asn1_test PROGS += ec_point_conversion -LDADD = ${CRYPTO_INT} +LDADD = -lcrypto DPADD = ${LIBCRYPTO} WARNINGS = Yes CFLAGS += -DLIBRESSL_CRYPTO_INTERNAL -DLIBRESSL_INTERNAL diff --git a/regress/lib/libcrypto/ec/ec_point_conversion.c b/regress/lib/libcrypto/ec/ec_point_conversion.c index 5a97f67b941..dca35ced590 100644 --- a/regress/lib/libcrypto/ec/ec_point_conversion.c +++ b/regress/lib/libcrypto/ec/ec_point_conversion.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_point_conversion.c,v 1.9 2023/04/15 21:53:38 tb Exp $ */ +/* $OpenBSD: ec_point_conversion.c,v 1.10 2023/04/17 20:41:02 tb Exp $ */ /* * Copyright (c) 2021 Theo Buehler <tb@openbsd.org> * Copyright (c) 2021 Joel Sing <jsing@openbsd.org> @@ -177,8 +177,10 @@ test_random_points_on_curve(EC_builtin_curve *curve) for (i = 0; i < N_RANDOM_POINTS; i++) { EC_POINT *random_point; - if (!bn_rand_interval(random, BN_value_one(), order)) - errx(1, "bn_rand_interval"); + do { + if (!BN_rand_range(random, order)) + errx(1, "BN_rand_range"); + } while (BN_is_zero(random)); if ((random_point = EC_POINT_new(group)) == NULL) errx(1, "EC_POINT_new"); diff --git a/regress/lib/libcrypto/ec/ectest.c b/regress/lib/libcrypto/ec/ectest.c index 2b9c6a99f38..d2253609cdd 100644 --- a/regress/lib/libcrypto/ec/ectest.c +++ b/regress/lib/libcrypto/ec/ectest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ectest.c,v 1.13 2023/04/13 05:25:30 tb Exp $ */ +/* $OpenBSD: ectest.c,v 1.14 2023/04/17 20:41:02 tb Exp $ */ /* crypto/ec/ectest.c */ /* * Originally written by Bodo Moeller for the OpenSSL project. @@ -96,6 +96,9 @@ #define TIMING_RAND_PT 1 #define TIMING_SIMUL 2 +int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, + const EC_POINT *point, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx); + /* test multiplication with group order, long and negative scalars */ static void group_order_tests(EC_GROUP *group) @@ -132,7 +135,8 @@ group_order_tests(EC_GROUP *group) ABORT; fprintf(stdout, " ok\n"); fprintf(stdout, "long/negative scalar tests ... "); - if (!BN_one(n1)) + /* XXX - switch back to BN_one() after next bump. */ + if (!BN_set_word(n1, 1)) ABORT; /* n1 = 1 - order */ if (!BN_sub(n1, n1, order)) @@ -342,7 +346,7 @@ prime_field_tests(void) fprintf(stdout, "\nGenerator as octet string, hybrid form:\n "); for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]); - if (!EC_POINT_get_Jprojective_coordinates(group, R, x, y, z, ctx)) + if (!EC_POINT_get_Jprojective_coordinates_GFp(group, R, x, y, z, ctx)) ABORT; fprintf(stdout, "\nA representation of the inverse of that generator in\nJacobian projective coordinates:\n X = 0x"); BN_print_fp(stdout, x); |