summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2021-04-20 17:23:38 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2021-04-20 17:23:38 +0000
commit90bfd3bf17ffb63deebfb7709a8f760dadff935a (patch)
tree91318bf6bffd2405d6bfc31b939db35212b9f630 /lib
parent3c53d1b3c0851b4ee6db6c93dc8de359bfb8c254 (diff)
Simplify code after adding EC_POINT_{s,g}et_affine_coordinates()
ok jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/ec/ec_key.c31
-rw-r--r--lib/libcrypto/ecdh/ech_key.c19
-rw-r--r--lib/libcrypto/ecdsa/ecs_ossl.c41
3 files changed, 18 insertions, 73 deletions
diff --git a/lib/libcrypto/ec/ec_key.c b/lib/libcrypto/ec/ec_key.c
index 348156e6800..27b8f266087 100644
--- a/lib/libcrypto/ec/ec_key.c
+++ b/lib/libcrypto/ec/ec_key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec_key.c,v 1.25 2021/04/20 17:16:37 tb Exp $ */
+/* $OpenBSD: ec_key.c,v 1.26 2021/04/20 17:23:37 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project.
*/
@@ -381,7 +381,7 @@ EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y)
BN_CTX *ctx = NULL;
BIGNUM *tx, *ty;
EC_POINT *point = NULL;
- int ok = 0, tmp_nid, is_char_two = 0;
+ int ok = 0;
if (!key || !key->group || !x || !y) {
ECerror(ERR_R_PASSED_NULL_PARAMETER);
@@ -396,34 +396,15 @@ EC_KEY_set_public_key_affine_coordinates(EC_KEY * key, BIGNUM * x, BIGNUM * y)
if (!point)
goto err;
- tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(key->group));
-
- if (tmp_nid == NID_X9_62_characteristic_two_field)
- is_char_two = 1;
-
if ((tx = BN_CTX_get(ctx)) == NULL)
goto err;
if ((ty = BN_CTX_get(ctx)) == NULL)
goto err;
-#ifndef OPENSSL_NO_EC2M
- if (is_char_two) {
- if (!EC_POINT_set_affine_coordinates(key->group, point,
- x, y, ctx))
- goto err;
- if (!EC_POINT_get_affine_coordinates(key->group, point,
- tx, ty, ctx))
- goto err;
- } else
-#endif
- {
- if (!EC_POINT_set_affine_coordinates(key->group, point,
- x, y, ctx))
- goto err;
- if (!EC_POINT_get_affine_coordinates(key->group, point,
- tx, ty, ctx))
- goto err;
- }
+ if (!EC_POINT_set_affine_coordinates(key->group, point, x, y, ctx))
+ goto err;
+ if (!EC_POINT_get_affine_coordinates(key->group, point, tx, ty, ctx))
+ goto err;
/*
* Check if retrieved coordinates match originals: if not values are
* out of range.
diff --git a/lib/libcrypto/ecdh/ech_key.c b/lib/libcrypto/ecdh/ech_key.c
index c82002ea46d..e59ce8bc3c0 100644
--- a/lib/libcrypto/ecdh/ech_key.c
+++ b/lib/libcrypto/ecdh/ech_key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ech_key.c,v 1.10 2021/04/20 17:16:38 tb Exp $ */
+/* $OpenBSD: ech_key.c,v 1.11 2021/04/20 17:23:37 tb Exp $ */
/* ====================================================================
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
*
@@ -140,21 +140,10 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
goto err;
}
- if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) ==
- NID_X9_62_prime_field) {
- if (!EC_POINT_get_affine_coordinates(group, tmp, x, y, ctx)) {
- ECDHerror(ECDH_R_POINT_ARITHMETIC_FAILURE);
- goto err;
- }
- }
-#ifndef OPENSSL_NO_EC2M
- else {
- if (!EC_POINT_get_affine_coordinates(group, tmp, x, y, ctx)) {
- ECDHerror(ECDH_R_POINT_ARITHMETIC_FAILURE);
- goto err;
- }
+ if (!EC_POINT_get_affine_coordinates(group, tmp, x, y, ctx)) {
+ ECDHerror(ECDH_R_POINT_ARITHMETIC_FAILURE);
+ goto err;
}
-#endif
buflen = ECDH_size(ecdh);
len = BN_num_bytes(x);
diff --git a/lib/libcrypto/ecdsa/ecs_ossl.c b/lib/libcrypto/ecdsa/ecs_ossl.c
index aa97a3ad738..e7e7a526657 100644
--- a/lib/libcrypto/ecdsa/ecs_ossl.c
+++ b/lib/libcrypto/ecdsa/ecs_ossl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ecs_ossl.c,v 1.21 2021/04/20 17:16:38 tb Exp $ */
+/* $OpenBSD: ecs_ossl.c,v 1.22 2021/04/20 17:23:37 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project
*/
@@ -205,23 +205,11 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
ECDSAerror(ERR_R_EC_LIB);
goto err;
}
- if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) ==
- NID_X9_62_prime_field) {
- if (!EC_POINT_get_affine_coordinates(group, point,
- X, NULL, ctx)) {
- ECDSAerror(ERR_R_EC_LIB);
- goto err;
- }
- }
-#ifndef OPENSSL_NO_EC2M
- else { /* NID_X9_62_characteristic_two_field */
- if (!EC_POINT_get_affine_coordinates(group, point,
- X, NULL, ctx)) {
- ECDSAerror(ERR_R_EC_LIB);
- goto err;
- }
+ if (!EC_POINT_get_affine_coordinates(group, point, X, NULL,
+ ctx)) {
+ ECDSAerror(ERR_R_EC_LIB);
+ goto err;
}
-#endif
if (!BN_nnmod(r, X, order, ctx)) {
ECDSAerror(ERR_R_BN_LIB);
goto err;
@@ -521,23 +509,10 @@ ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig,
ECDSAerror(ERR_R_EC_LIB);
goto err;
}
- if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) ==
- NID_X9_62_prime_field) {
- if (!EC_POINT_get_affine_coordinates(group, point, X, NULL,
- ctx)) {
- ECDSAerror(ERR_R_EC_LIB);
- goto err;
- }
- }
-#ifndef OPENSSL_NO_EC2M
- else { /* NID_X9_62_characteristic_two_field */
- if (!EC_POINT_get_affine_coordinates(group, point, X, NULL,
- ctx)) {
- ECDSAerror(ERR_R_EC_LIB);
- goto err;
- }
+ if (!EC_POINT_get_affine_coordinates(group, point, X, NULL, ctx)) {
+ ECDSAerror(ERR_R_EC_LIB);
+ goto err;
}
-#endif
if (!BN_nnmod(u1, X, order, ctx)) {
ECDSAerror(ERR_R_BN_LIB);
goto err;