Latest update.
This commit is contained in:
+10
-10
@@ -43,7 +43,7 @@ int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group,
|
||||
{
|
||||
BIGNUM *tmp, *x, *y, *z;
|
||||
int ret = 0, z0;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
|
||||
/* clear error queue */
|
||||
@@ -81,7 +81,7 @@ int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group,
|
||||
if (!BN_GF2m_add(tmp, x, tmp))
|
||||
goto err;
|
||||
if (!BN_GF2m_mod_solve_quad_arr(z, tmp, group->poly, ctx)) {
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
unsigned long err = ERR_peek_last_error();
|
||||
|
||||
if (ERR_GET_LIB(err) == ERR_LIB_BN
|
||||
@@ -113,7 +113,7 @@ int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group,
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
@@ -132,7 +132,7 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
|
||||
int used_ctx = 0;
|
||||
BIGNUM *x, *y, *yxi;
|
||||
size_t field_len, i, skip;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
@@ -168,7 +168,7 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
|
||||
goto err;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL) {
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
if (ctx == NULL)
|
||||
@@ -236,7 +236,7 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
|
||||
|
||||
if (used_ctx)
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
@@ -244,7 +244,7 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
|
||||
err:
|
||||
if (used_ctx)
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return 0;
|
||||
@@ -263,7 +263,7 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
BIGNUM *x, *y, *yxi;
|
||||
size_t field_len, enc_len;
|
||||
int ret = 0;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
@@ -305,7 +305,7 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL) {
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
if (ctx == NULL)
|
||||
@@ -358,7 +358,7 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
+14
-14
@@ -182,7 +182,7 @@ int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group,
|
||||
{
|
||||
int ret = 0;
|
||||
BIGNUM *b;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
|
||||
if (ctx == NULL) {
|
||||
@@ -213,7 +213,7 @@ int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group,
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
@@ -361,7 +361,7 @@ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
|
||||
{
|
||||
BIGNUM *x0, *y0, *x1, *y1, *x2, *y2, *s, *t;
|
||||
int ret = 0;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
@@ -377,7 +377,7 @@ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL) {
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
if (ctx == NULL)
|
||||
@@ -467,7 +467,7 @@ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
@@ -514,7 +514,7 @@ int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
|
||||
int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *,
|
||||
const BIGNUM *, BN_CTX *);
|
||||
int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
@@ -528,7 +528,7 @@ int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
|
||||
if (!point->Z_is_one)
|
||||
return -1;
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL) {
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
if (ctx == NULL)
|
||||
@@ -566,7 +566,7 @@ int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
@@ -584,7 +584,7 @@ int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a,
|
||||
{
|
||||
BIGNUM *aX, *aY, *bX, *bY;
|
||||
int ret = -1;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
@@ -599,7 +599,7 @@ int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a,
|
||||
return ((BN_cmp(a->X, b->X) == 0) && BN_cmp(a->Y, b->Y) == 0) ? 0 : 1;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL) {
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
if (ctx == NULL)
|
||||
@@ -623,7 +623,7 @@ int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a,
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
@@ -635,14 +635,14 @@ int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point,
|
||||
{
|
||||
BIGNUM *x, *y;
|
||||
int ret = 0;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
if (point->Z_is_one || EC_POINT_is_at_infinity(group, point))
|
||||
return 1;
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL) {
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
if (ctx == NULL)
|
||||
@@ -670,7 +670,7 @@ int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point,
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@
|
||||
#include "internal/nelem.h"
|
||||
#include "crypto/asn1_dsa.h"
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
|
||||
int EC_GROUP_get_basis_type(const EC_GROUP *group)
|
||||
{
|
||||
@@ -1237,7 +1237,7 @@ int i2o_ECPublicKey(const EC_KEY *a, unsigned char **out)
|
||||
DECLARE_ASN1_FUNCTIONS(ECDSA_SIG)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_name(ECDSA_SIG, ECDSA_SIG)
|
||||
|
||||
#endif /* FIPS_MODE */
|
||||
#endif /* FIPS_MODULE */
|
||||
|
||||
ECDSA_SIG *ECDSA_SIG_new(void)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only,
|
||||
|
||||
int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx)
|
||||
{
|
||||
#ifdef FIPS_MODE
|
||||
#ifdef FIPS_MODULE
|
||||
/*
|
||||
* ECC domain parameter validation.
|
||||
* See SP800-56A R3 5.5.2 "Assurances of Domain-Parameter Validity" Part 1b.
|
||||
@@ -114,5 +114,5 @@ int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx)
|
||||
BN_CTX_free(new_ctx);
|
||||
EC_POINT_free(point);
|
||||
return ret;
|
||||
#endif /* FIPS_MODE */
|
||||
#endif /* FIPS_MODULE */
|
||||
}
|
||||
+1
-1
@@ -463,7 +463,7 @@ int EVP_PKEY_CTX_get_ec_paramgen_curve_name(EVP_PKEY_CTX *ctx,
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid)
|
||||
{
|
||||
if (ctx == NULL || !EVP_PKEY_CTX_IS_GEN_OP(ctx)) {
|
||||
|
||||
+21
-21
@@ -200,7 +200,7 @@ static const struct {
|
||||
}
|
||||
};
|
||||
|
||||
# ifndef FIPS_MODE
|
||||
# ifndef FIPS_MODULE
|
||||
/* the x9.62 prime curves (minus the nist prime curves) */
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
@@ -379,7 +379,7 @@ static const struct {
|
||||
0x43, 0x21, 0x46, 0x52, 0x65, 0x51
|
||||
}
|
||||
};
|
||||
#endif /* FIPS_MODE */
|
||||
#endif /* FIPS_MODULE */
|
||||
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
@@ -419,7 +419,7 @@ static const struct {
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
/* the secg prime curves (minus the nist and x9.62 prime curves) */
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
@@ -841,13 +841,13 @@ static const struct {
|
||||
0x5C, 0x5C, 0x2A, 0x3D
|
||||
}
|
||||
};
|
||||
#endif /* FIPS_MODE */
|
||||
#endif /* FIPS_MODULE */
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
|
||||
/* characteristic two curves */
|
||||
|
||||
# ifndef FIPS_MODE
|
||||
# ifndef FIPS_MODULE
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
unsigned char data[20 + 15 * 6];
|
||||
@@ -975,7 +975,7 @@ static const struct {
|
||||
0x33, 0x04, 0x9B, 0xA9, 0x8F
|
||||
}
|
||||
};
|
||||
# endif /* FIPS_MODE */
|
||||
# endif /* FIPS_MODULE */
|
||||
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
@@ -1007,7 +1007,7 @@ static const struct {
|
||||
}
|
||||
};
|
||||
|
||||
# ifndef FIPS_MODE
|
||||
# ifndef FIPS_MODULE
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
unsigned char data[0 + 21 * 6];
|
||||
@@ -1036,7 +1036,7 @@ static const struct {
|
||||
0xAA, 0xB6, 0x89, 0xC2, 0x9C, 0xA7, 0x10, 0x27, 0x9B
|
||||
}
|
||||
};
|
||||
# endif /* FIPS_MODE */
|
||||
# endif /* FIPS_MODULE */
|
||||
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
@@ -1067,7 +1067,7 @@ static const struct {
|
||||
}
|
||||
};
|
||||
|
||||
# ifndef FIPS_MODE
|
||||
# ifndef FIPS_MODULE
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
unsigned char data[20 + 25 * 6];
|
||||
@@ -1143,7 +1143,7 @@ static const struct {
|
||||
0xD5
|
||||
}
|
||||
};
|
||||
# endif /* FIPS_MODE */
|
||||
# endif /* FIPS_MODULE */
|
||||
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
@@ -1219,7 +1219,7 @@ static const struct {
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
unsigned char data[0 + 30 * 6];
|
||||
@@ -1255,7 +1255,7 @@ static const struct {
|
||||
0x1D, 0xA8, 0x00, 0xE4, 0x78, 0xA5
|
||||
}
|
||||
};
|
||||
# endif /* FIPS_MODE */
|
||||
# endif /* FIPS_MODULE */
|
||||
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
@@ -1539,7 +1539,7 @@ static const struct {
|
||||
}
|
||||
};
|
||||
|
||||
# ifndef FIPS_MODE
|
||||
# ifndef FIPS_MODULE
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
unsigned char data[20 + 21 * 6];
|
||||
@@ -2224,7 +2224,7 @@ static const struct {
|
||||
0xED, 0xF9, 0x7C, 0x44, 0xDB, 0x9F, 0x24, 0x20, 0xBA, 0xFC, 0xA7, 0x5E
|
||||
}
|
||||
};
|
||||
# endif /* FIPS_MODE */
|
||||
# endif /* FIPS_MODULE */
|
||||
#endif /* OPENSSL_NO_EC2M */
|
||||
|
||||
/*
|
||||
@@ -2235,7 +2235,7 @@ static const struct {
|
||||
* generation mechanism is different from those defined in ANSI X9.62.
|
||||
*/
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
unsigned char data[0 + 20 * 6];
|
||||
@@ -2775,9 +2775,9 @@ static const struct {
|
||||
0x9C, 0xA9, 0x00, 0x69
|
||||
}
|
||||
};
|
||||
#endif /* FIPS_MODE */
|
||||
#endif /* FIPS_MODULE */
|
||||
|
||||
#if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODE)
|
||||
#if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODULE)
|
||||
static const struct {
|
||||
EC_CURVE_DATA h;
|
||||
unsigned char data[0 + 32 * 6];
|
||||
@@ -2824,7 +2824,7 @@ typedef struct _ec_list_element_st {
|
||||
const char *comment;
|
||||
} ec_list_element;
|
||||
|
||||
#ifdef FIPS_MODE
|
||||
#ifdef FIPS_MODULE
|
||||
static const ec_list_element curve_list[] = {
|
||||
/* prime field curves */
|
||||
/* secg curves */
|
||||
@@ -3113,7 +3113,7 @@ static const ec_list_element curve_list[] = {
|
||||
"SM2 curve over a 256 bit prime field"},
|
||||
# endif
|
||||
};
|
||||
#endif /* FIPS_MODE */
|
||||
#endif /* FIPS_MODULE */
|
||||
|
||||
#define curve_list_length OSSL_NELEM(curve_list)
|
||||
|
||||
@@ -3165,7 +3165,7 @@ int ec_curve_name2nid(const char *name)
|
||||
if ((nid = EC_curve_nist2nid(name)) != NID_undef)
|
||||
return nid;
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
/*
|
||||
* TODO(3.0) Figure out if we can use other names than the NIST names
|
||||
* ("B-163", "K-163" & "P-192") in the FIPS module, or if other names
|
||||
@@ -3302,7 +3302,7 @@ EC_GROUP *EC_GROUP_new_by_curve_name_ex(OPENSSL_CTX *libctx, int nid)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
EC_GROUP *EC_GROUP_new_by_curve_name(int nid)
|
||||
{
|
||||
return EC_GROUP_new_by_curve_name_ex(NULL, nid);
|
||||
|
||||
+9
-9
@@ -26,7 +26,7 @@
|
||||
static int ecdsa_keygen_pairwise_test(EC_KEY *eckey, OSSL_CALLBACK *cb,
|
||||
void *cbarg);
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
EC_KEY *EC_KEY_new(void)
|
||||
{
|
||||
return ec_key_new_method_int(NULL, NULL);
|
||||
@@ -56,7 +56,7 @@ EC_KEY *EC_KEY_new_by_curve_name_ex(OPENSSL_CTX *ctx, int nid)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
EC_KEY *EC_KEY_new_by_curve_name(int nid)
|
||||
{
|
||||
return EC_KEY_new_by_curve_name_ex(NULL, nid);
|
||||
@@ -79,14 +79,14 @@ void EC_KEY_free(EC_KEY *r)
|
||||
if (r->meth != NULL && r->meth->finish != NULL)
|
||||
r->meth->finish(r);
|
||||
|
||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODE)
|
||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
|
||||
ENGINE_finish(r->engine);
|
||||
#endif
|
||||
|
||||
if (r->group && r->group->meth->keyfinish)
|
||||
r->group->meth->keyfinish(r);
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_EC_KEY, r, &r->ex_data);
|
||||
#endif
|
||||
CRYPTO_THREAD_lock_free(r->lock);
|
||||
@@ -108,7 +108,7 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
|
||||
dest->meth->finish(dest);
|
||||
if (dest->group && dest->group->meth->keyfinish)
|
||||
dest->group->meth->keyfinish(dest);
|
||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODE)
|
||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
|
||||
if (ENGINE_finish(dest->engine) == 0)
|
||||
return 0;
|
||||
dest->engine = NULL;
|
||||
@@ -156,14 +156,14 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
|
||||
dest->conv_form = src->conv_form;
|
||||
dest->version = src->version;
|
||||
dest->flags = src->flags;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_EC_KEY,
|
||||
&dest->ex_data, &src->ex_data))
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
if (src->meth != dest->meth) {
|
||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODE)
|
||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
|
||||
if (src->engine != NULL && ENGINE_init(src->engine) == 0)
|
||||
return NULL;
|
||||
dest->engine = src->engine;
|
||||
@@ -312,9 +312,9 @@ int ec_generate_key(OPENSSL_CTX *libctx, EC_KEY *eckey, int pairwise_test)
|
||||
|
||||
eckey->dirty_cnt++;
|
||||
|
||||
#ifdef FIPS_MODE
|
||||
#ifdef FIPS_MODULE
|
||||
pairwise_test = 1;
|
||||
#endif /* FIPS_MODE */
|
||||
#endif /* FIPS_MODULE */
|
||||
|
||||
ok = 1;
|
||||
if (pairwise_test) {
|
||||
|
||||
@@ -65,7 +65,7 @@ int EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth)
|
||||
if (finish != NULL)
|
||||
finish(key);
|
||||
|
||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODE)
|
||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
|
||||
ENGINE_finish(key->engine);
|
||||
key->engine = NULL;
|
||||
#endif
|
||||
@@ -96,7 +96,7 @@ EC_KEY *ec_key_new_method_int(OPENSSL_CTX *libctx, ENGINE *engine)
|
||||
}
|
||||
|
||||
ret->meth = EC_KEY_get_default_method();
|
||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODE)
|
||||
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
|
||||
if (engine != NULL) {
|
||||
if (!ENGINE_init(engine)) {
|
||||
ECerr(EC_F_EC_KEY_NEW_METHOD_INT, ERR_R_ENGINE_LIB);
|
||||
@@ -118,7 +118,7 @@ EC_KEY *ec_key_new_method_int(OPENSSL_CTX *libctx, ENGINE *engine)
|
||||
ret->conv_form = POINT_CONVERSION_UNCOMPRESSED;
|
||||
|
||||
/* No ex_data inside the FIPS provider */
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_EC_KEY, ret, &ret->ex_data)) {
|
||||
goto err;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ EC_KEY *ec_key_new_method_int(OPENSSL_CTX *libctx, ENGINE *engine)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
EC_KEY *EC_KEY_new_method(ENGINE *engine)
|
||||
{
|
||||
return ec_key_new_method_int(NULL, engine);
|
||||
|
||||
+46
-20
@@ -65,7 +65,7 @@ EC_GROUP *EC_GROUP_new_ex(OPENSSL_CTX *libctx, const EC_METHOD *meth)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
EC_GROUP *EC_GROUP_new(const EC_METHOD *meth)
|
||||
{
|
||||
return EC_GROUP_new_ex(NULL, meth);
|
||||
@@ -597,7 +597,7 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx)
|
||||
{
|
||||
int r = 0;
|
||||
BIGNUM *a1, *a2, *a3, *b1, *b2, *b3;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *ctx_new = NULL;
|
||||
#endif
|
||||
|
||||
@@ -612,7 +612,7 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx)
|
||||
if (a->meth->flags & EC_FLAGS_CUSTOM_CURVE)
|
||||
return 0;
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL)
|
||||
ctx_new = ctx = BN_CTX_new();
|
||||
#endif
|
||||
@@ -628,7 +628,7 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx)
|
||||
b3 = BN_CTX_get(ctx);
|
||||
if (b3 == NULL) {
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(ctx_new);
|
||||
#endif
|
||||
return -1;
|
||||
@@ -680,7 +680,7 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx)
|
||||
}
|
||||
end:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(ctx_new);
|
||||
#endif
|
||||
return r;
|
||||
@@ -1041,13 +1041,14 @@ int EC_POINTs_make_affine(const EC_GROUP *group, size_t num,
|
||||
* methods.
|
||||
*/
|
||||
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
|
||||
size_t num, const EC_POINT *points[],
|
||||
const BIGNUM *scalars[], BN_CTX *ctx)
|
||||
{
|
||||
int ret = 0;
|
||||
size_t i = 0;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
@@ -1066,7 +1067,7 @@ int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL)
|
||||
ctx = new_ctx = BN_CTX_secure_new();
|
||||
#endif
|
||||
@@ -1081,26 +1082,51 @@ int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
|
||||
/* use default */
|
||||
ret = ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx);
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,
|
||||
const EC_POINT *point, const BIGNUM *p_scalar, BN_CTX *ctx)
|
||||
{
|
||||
/* just a convenient interface to EC_POINTs_mul() */
|
||||
int ret = 0;
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
const EC_POINT *points[1];
|
||||
const BIGNUM *scalars[1];
|
||||
if (!ec_point_is_compat(r, group)
|
||||
|| (point != NULL && !ec_point_is_compat(point, group))) {
|
||||
ECerr(EC_F_EC_POINT_MUL, EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
points[0] = point;
|
||||
scalars[0] = p_scalar;
|
||||
if (g_scalar == NULL && p_scalar == NULL)
|
||||
return EC_POINT_set_to_infinity(group, r);
|
||||
|
||||
return EC_POINTs_mul(group, r, g_scalar,
|
||||
(point != NULL
|
||||
&& p_scalar != NULL), points, scalars, ctx);
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL)
|
||||
ctx = new_ctx = BN_CTX_secure_new();
|
||||
#endif
|
||||
if (ctx == NULL) {
|
||||
ECerr(EC_F_EC_POINT_MUL, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (group->meth->mul != NULL)
|
||||
ret = group->meth->mul(group, r, g_scalar, point != NULL
|
||||
&& p_scalar != NULL, &point, &p_scalar, ctx);
|
||||
else
|
||||
/* use default */
|
||||
ret = ec_wNAF_mul(group, r, g_scalar, point != NULL
|
||||
&& p_scalar != NULL, &point, &p_scalar, ctx);
|
||||
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
@@ -1161,7 +1187,7 @@ static int ec_precompute_mont_data(EC_GROUP *group)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg)
|
||||
{
|
||||
return CRYPTO_set_ex_data(&key->ex_data, idx, arg);
|
||||
@@ -1185,14 +1211,14 @@ static int ec_field_inverse_mod_ord(const EC_GROUP *group, BIGNUM *r,
|
||||
{
|
||||
BIGNUM *e = NULL;
|
||||
int ret = 0;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
if (group->mont_data == NULL)
|
||||
return 0;
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL)
|
||||
ctx = new_ctx = BN_CTX_secure_new();
|
||||
#endif
|
||||
@@ -1222,7 +1248,7 @@ static int ec_field_inverse_mod_ord(const EC_GROUP *group, BIGNUM *r,
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
|
||||
@@ -288,7 +288,7 @@ struct ec_key_st {
|
||||
point_conversion_form_t conv_form;
|
||||
CRYPTO_REF_COUNT references;
|
||||
int flags;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
#endif
|
||||
CRYPTO_RWLOCK *lock;
|
||||
|
||||
+3
-3
@@ -833,7 +833,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
EC_POINT **points = NULL;
|
||||
EC_PRE_COMP *pre_comp;
|
||||
int ret = 0;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
@@ -848,7 +848,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
goto err;
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL)
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
#endif
|
||||
@@ -965,7 +965,7 @@ int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
EC_ec_pre_comp_free(pre_comp);
|
||||
|
||||
@@ -1299,7 +1299,7 @@ int ec_GFp_nistp224_group_set_curve(EC_GROUP *group, const BIGNUM *p,
|
||||
{
|
||||
int ret = 0;
|
||||
BIGNUM *curve_p, *curve_a, *curve_b;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
|
||||
if (ctx == NULL)
|
||||
@@ -1326,7 +1326,7 @@ int ec_GFp_nistp224_group_set_curve(EC_GROUP *group, const BIGNUM *p,
|
||||
ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx);
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
@@ -1617,14 +1617,14 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
BIGNUM *x, *y;
|
||||
EC_POINT *generator = NULL;
|
||||
felem tmp_felems[32];
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
/* throw away old precomputation */
|
||||
EC_pre_comp_free(group);
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL)
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
#endif
|
||||
@@ -1738,7 +1738,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
EC_POINT_free(generator);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
EC_nistp224_pre_comp_free(pre);
|
||||
|
||||
@@ -1912,7 +1912,7 @@ int ec_GFp_nistp256_group_set_curve(EC_GROUP *group, const BIGNUM *p,
|
||||
{
|
||||
int ret = 0;
|
||||
BIGNUM *curve_p, *curve_a, *curve_b;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
|
||||
if (ctx == NULL)
|
||||
@@ -1939,7 +1939,7 @@ int ec_GFp_nistp256_group_set_curve(EC_GROUP *group, const BIGNUM *p,
|
||||
ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx);
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
@@ -2239,14 +2239,14 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
EC_POINT *generator = NULL;
|
||||
smallfelem tmp_smallfelems[32];
|
||||
felem x_tmp, y_tmp, z_tmp;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
/* throw away old precomputation */
|
||||
EC_pre_comp_free(group);
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL)
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
#endif
|
||||
@@ -2370,7 +2370,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
EC_POINT_free(generator);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
EC_nistp256_pre_comp_free(pre);
|
||||
|
||||
@@ -1752,7 +1752,7 @@ int ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p,
|
||||
{
|
||||
int ret = 0;
|
||||
BIGNUM *curve_p, *curve_a, *curve_b;
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
|
||||
if (ctx == NULL)
|
||||
@@ -1779,7 +1779,7 @@ int ec_GFp_nistp521_group_set_curve(EC_GROUP *group, const BIGNUM *p,
|
||||
ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx);
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
return ret;
|
||||
@@ -2075,14 +2075,14 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
BIGNUM *x, *y;
|
||||
EC_POINT *generator = NULL;
|
||||
felem tmp_felems[16];
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX *new_ctx = NULL;
|
||||
#endif
|
||||
|
||||
/* throw away old precomputation */
|
||||
EC_pre_comp_free(group);
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
if (ctx == NULL)
|
||||
ctx = new_ctx = BN_CTX_new();
|
||||
#endif
|
||||
@@ -2176,7 +2176,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
EC_POINT_free(generator);
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
BN_CTX_free(new_ctx);
|
||||
#endif
|
||||
EC_nistp521_pre_comp_free(pre);
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,
|
||||
BIGNUM *tmp1, *tmp2, *x, *y;
|
||||
int ret = 0;
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
/* clear error queue */
|
||||
ERR_clear_error();
|
||||
#endif
|
||||
@@ -107,7 +107,7 @@ int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group,
|
||||
}
|
||||
|
||||
if (!BN_mod_sqrt(y, tmp1, group->field, ctx)) {
|
||||
#ifndef FIPS_MODE
|
||||
#ifndef FIPS_MODULE
|
||||
unsigned long err = ERR_peek_last_error();
|
||||
|
||||
if (ERR_GET_LIB(err) == ERR_LIB_BN
|
||||
|
||||
+38
-10
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <openssl/core_names.h>
|
||||
#include <openssl/params.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/err.h>
|
||||
#include "crypto/ecx.h"
|
||||
#include "ecx_backend.h"
|
||||
|
||||
@@ -18,10 +20,35 @@
|
||||
* implementations alike.
|
||||
*/
|
||||
|
||||
int ecx_public_from_private(ECX_KEY *key)
|
||||
{
|
||||
switch (key->type) {
|
||||
case ECX_KEY_TYPE_X25519:
|
||||
X25519_public_from_private(key->pubkey, key->privkey);
|
||||
break;
|
||||
case ECX_KEY_TYPE_ED25519:
|
||||
if (!ED25519_public_from_private(key->libctx, key->pubkey, key->privkey)) {
|
||||
ECerr(0, EC_R_FAILED_MAKING_PUBLIC_KEY);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case ECX_KEY_TYPE_X448:
|
||||
X448_public_from_private(key->pubkey, key->privkey);
|
||||
break;
|
||||
case ECX_KEY_TYPE_ED448:
|
||||
if (!ED448_public_from_private(key->libctx, key->pubkey, key->privkey)) {
|
||||
ECerr(0, EC_R_FAILED_MAKING_PUBLIC_KEY);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ecx_key_fromdata(ECX_KEY *ecx, const OSSL_PARAM params[],
|
||||
int include_private)
|
||||
{
|
||||
size_t privkeylen = 0, pubkeylen;
|
||||
size_t privkeylen = 0, pubkeylen = 0;
|
||||
const OSSL_PARAM *param_priv_key = NULL, *param_pub_key;
|
||||
unsigned char *pubkey;
|
||||
|
||||
@@ -32,11 +59,8 @@ int ecx_key_fromdata(ECX_KEY *ecx, const OSSL_PARAM params[],
|
||||
if (include_private)
|
||||
param_priv_key =
|
||||
OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
|
||||
/*
|
||||
* If a private key is present then a public key must also be present.
|
||||
* Alternatively we've just got a public key.
|
||||
*/
|
||||
if (param_pub_key == NULL)
|
||||
|
||||
if (param_pub_key == NULL && param_priv_key == NULL)
|
||||
return 0;
|
||||
|
||||
if (param_priv_key != NULL
|
||||
@@ -46,15 +70,19 @@ int ecx_key_fromdata(ECX_KEY *ecx, const OSSL_PARAM params[],
|
||||
return 0;
|
||||
|
||||
pubkey = ecx->pubkey;
|
||||
if (!OSSL_PARAM_get_octet_string(param_pub_key,
|
||||
(void **)&pubkey,
|
||||
sizeof(ecx->pubkey), &pubkeylen))
|
||||
if (param_pub_key != NULL
|
||||
&& !OSSL_PARAM_get_octet_string(param_pub_key,
|
||||
(void **)&pubkey,
|
||||
sizeof(ecx->pubkey), &pubkeylen))
|
||||
return 0;
|
||||
|
||||
if (pubkeylen != ecx->keylen
|
||||
if ((param_pub_key != NULL && pubkeylen != ecx->keylen)
|
||||
|| (param_priv_key != NULL && privkeylen != ecx->keylen))
|
||||
return 0;
|
||||
|
||||
if (param_pub_key == NULL && !ecx_public_from_private(ecx))
|
||||
return 0;
|
||||
|
||||
ecx->haspubkey = 1;
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
: ((id) == EVP_PKEY_X448 ? X448_KEYLEN \
|
||||
: ED448_KEYLEN))
|
||||
#define KEYNID2TYPE(id) \
|
||||
(IS25519(id) ? ECX_KEY_TYPE_X25519 \
|
||||
(IS25519(id) ? ((id) == EVP_PKEY_X25519 ? ECX_KEY_TYPE_X25519 \
|
||||
: ECX_KEY_TYPE_ED25519) \
|
||||
: ((id) == EVP_PKEY_X448 ? ECX_KEY_TYPE_X448 \
|
||||
: ((id) == EVP_PKEY_ED25519 ? ECX_KEY_TYPE_ED25519 \
|
||||
: ECX_KEY_TYPE_ED448)))
|
||||
: ECX_KEY_TYPE_ED448))
|
||||
#define KEYLEN(p) KEYLENID((p)->ameth->pkey_id)
|
||||
+2
-1
@@ -10,13 +10,14 @@
|
||||
#include <openssl/err.h>
|
||||
#include "crypto/ecx.h"
|
||||
|
||||
ECX_KEY *ecx_key_new(ECX_KEY_TYPE type, int haspubkey)
|
||||
ECX_KEY *ecx_key_new(OPENSSL_CTX *libctx, ECX_KEY_TYPE type, int haspubkey)
|
||||
{
|
||||
ECX_KEY *ret = OPENSSL_zalloc(sizeof(*ret));
|
||||
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
ret->libctx = libctx;
|
||||
ret->haspubkey = haspubkey;
|
||||
switch (type) {
|
||||
case ECX_KEY_TYPE_X25519:
|
||||
|
||||
+9
-25
@@ -59,7 +59,7 @@ static int ecx_key_op(EVP_PKEY *pkey, int id, const X509_ALGOR *palg,
|
||||
}
|
||||
}
|
||||
|
||||
key = ecx_key_new(KEYNID2TYPE(id), 1);
|
||||
key = ecx_key_new(libctx, KEYNID2TYPE(id), 1);
|
||||
if (key == NULL) {
|
||||
ECerr(EC_F_ECX_KEY_OP, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
@@ -88,25 +88,9 @@ static int ecx_key_op(EVP_PKEY *pkey, int id, const X509_ALGOR *palg,
|
||||
} else {
|
||||
memcpy(privkey, p, KEYLENID(id));
|
||||
}
|
||||
switch (id) {
|
||||
case EVP_PKEY_X25519:
|
||||
X25519_public_from_private(pubkey, privkey);
|
||||
break;
|
||||
case EVP_PKEY_ED25519:
|
||||
if (!ED25519_public_from_private(libctx, pubkey, privkey)) {
|
||||
ECerr(EC_F_ECX_KEY_OP, EC_R_FAILED_MAKING_PUBLIC_KEY);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case EVP_PKEY_X448:
|
||||
X448_public_from_private(pubkey, privkey);
|
||||
break;
|
||||
case EVP_PKEY_ED448:
|
||||
if (!ED448_public_from_private(libctx, pubkey, privkey)) {
|
||||
ECerr(EC_F_ECX_KEY_OP, EC_R_FAILED_MAKING_PUBLIC_KEY);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
if (!ecx_public_from_private(key)) {
|
||||
ECerr(EC_F_ECX_KEY_OP, EC_R_FAILED_MAKING_PUBLIC_KEY);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +439,7 @@ static int ecx_generic_import_from(const OSSL_PARAM params[], void *vpctx,
|
||||
{
|
||||
EVP_PKEY_CTX *pctx = vpctx;
|
||||
EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(pctx);
|
||||
ECX_KEY *ecx = ecx_key_new(KEYNID2TYPE(keytype), 0);
|
||||
ECX_KEY *ecx = ecx_key_new(pctx->libctx, KEYNID2TYPE(keytype), 0);
|
||||
|
||||
if (ecx == NULL) {
|
||||
ERR_raise(ERR_LIB_DH, ERR_R_MALLOC_FAILURE);
|
||||
@@ -963,7 +947,7 @@ static int s390x_pkey_ecx_keygen25519(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
ECX_KEY *key = ecx_key_new(ECX_KEY_TYPE_X25519, 1);
|
||||
ECX_KEY *key = ecx_key_new(ctx->libctx, ECX_KEY_TYPE_X25519, 1);
|
||||
unsigned char *privkey = NULL, *pubkey;
|
||||
|
||||
if (key == NULL) {
|
||||
@@ -1005,7 +989,7 @@ static int s390x_pkey_ecx_keygen448(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
ECX_KEY *key = ecx_key_new(ECX_KEY_TYPE_X448, 1);
|
||||
ECX_KEY *key = ecx_key_new(ctx->libctx, ECX_KEY_TYPE_X448, 1);
|
||||
unsigned char *privkey = NULL, *pubkey;
|
||||
|
||||
if (key == NULL) {
|
||||
@@ -1050,7 +1034,7 @@ static int s390x_pkey_ecd_keygen25519(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
|
||||
};
|
||||
unsigned char x_dst[32], buff[SHA512_DIGEST_LENGTH];
|
||||
ECX_KEY *key = ecx_key_new(ECX_KEY_TYPE_ED25519, 1);
|
||||
ECX_KEY *key = ecx_key_new(ctx->libctx, ECX_KEY_TYPE_ED25519, 1);
|
||||
unsigned char *privkey = NULL, *pubkey;
|
||||
unsigned int sz;
|
||||
|
||||
@@ -1107,7 +1091,7 @@ static int s390x_pkey_ecd_keygen448(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
|
||||
0x24, 0xbc, 0xb6, 0x6e, 0x71, 0x46, 0x3f, 0x69, 0x00
|
||||
};
|
||||
unsigned char x_dst[57], buff[114];
|
||||
ECX_KEY *key = ecx_key_new(ECX_KEY_TYPE_ED448, 1);
|
||||
ECX_KEY *key = ecx_key_new(ctx->libctx, ECX_KEY_TYPE_ED448, 1);
|
||||
unsigned char *privkey = NULL, *pubkey;
|
||||
EVP_MD_CTX *hashctx = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user