early-access version 2698

This commit is contained in:
pineappleEA
2022-04-24 22:29:35 +02:00
parent c96f949832
commit caa0c2911b
486 changed files with 37806 additions and 14362 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: ecs_ossl.c,v 1.20 2019/06/04 18:15:27 tb Exp $ */
/* $OpenBSD: ecs_ossl.c,v 1.24 2022/04/07 17:37:25 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project
*/
@@ -163,6 +163,11 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
goto err;
}
if (BN_cmp(order, BN_value_one()) <= 0) {
ECDSAerror(EC_R_INVALID_GROUP_ORDER);
goto err;
}
/* Preallocate space. */
order_bits = BN_num_bits(order);
if (!BN_set_bit(k, order_bits) ||
@@ -205,30 +210,18 @@ 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_GFp(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;
}
#ifndef OPENSSL_NO_EC2M
else { /* NID_X9_62_characteristic_two_field */
if (!EC_POINT_get_affine_coordinates_GF2m(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;
}
} while (BN_is_zero(r));
if (!BN_mod_inverse_ct(k, k, order, ctx)) {
if (BN_mod_inverse_ct(k, k, order, ctx) == NULL) {
ECDSAerror(ERR_R_BN_LIB);
goto err;
}
@@ -499,7 +492,7 @@ ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig,
if (!ecdsa_prepare_digest(dgst, dgst_len, order, m))
goto err;
if (!BN_mod_inverse_ct(u2, sig->s, order, ctx)) { /* w = inv(s) */
if (BN_mod_inverse_ct(u2, sig->s, order, ctx) == NULL) { /* w = inv(s) */
ECDSAerror(ERR_R_BN_LIB);
goto err;
}
@@ -521,23 +514,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_GFp(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;
}
#ifndef OPENSSL_NO_EC2M
else { /* NID_X9_62_characteristic_two_field */
if (!EC_POINT_get_affine_coordinates_GF2m(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;