From 59bc67052b54608469d4f5637fa778d372737222 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Mon, 6 Jun 2011 13:18:03 +0000 Subject: [PATCH] Add flags field to EC_KEY structure (backport from HEAD). --- crypto/ec/ec.h | 10 ++++++++++ crypto/ec/ec_key.c | 17 +++++++++++++++++ crypto/ec/ec_lcl.h | 1 + 3 files changed, 28 insertions(+) diff --git a/crypto/ec/ec.h b/crypto/ec/ec.h index 64d0a2948d..c4fedeec25 100644 --- a/crypto/ec/ec.h +++ b/crypto/ec/ec.h @@ -701,11 +701,21 @@ typedef struct ec_key_st EC_KEY; #define EC_PKEY_NO_PARAMETERS 0x001 #define EC_PKEY_NO_PUBKEY 0x002 +/* some values for the flags field */ +#define EC_FLAG_NON_FIPS_ALLOW 0x1 +#define EC_FLAG_FIPS_CHECKED 0x2 + /** Creates a new EC_KEY object. * \return EC_KEY object or NULL if an error occurred. */ EC_KEY *EC_KEY_new(void); +int EC_KEY_get_flags(const EC_KEY *key); + +void EC_KEY_set_flags(EC_KEY *key, int flags); + +void EC_KEY_clear_flags(EC_KEY *key, int flags); + /** Creates a new EC_KEY object using a named curve as underlying * EC_GROUP object. * \param nid NID of the named curve. diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index 2e91b5405d..101dd8d3d0 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -78,6 +78,7 @@ EC_KEY *EC_KEY_new(void) } ret->version = 1; + ret->flags = 0; ret->group = NULL; ret->pub_key = NULL; ret->priv_key= NULL; @@ -197,6 +198,7 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src) dest->enc_flag = src->enc_flag; dest->conv_form = src->conv_form; dest->version = src->version; + dest->flags = src->flags; return dest; } @@ -537,3 +539,18 @@ int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx) return 0; return EC_GROUP_precompute_mult(key->group, ctx); } + +int EC_KEY_get_flags(const EC_KEY *key) + { + return key->flags; + } + +void EC_KEY_set_flags(EC_KEY *key, int flags) + { + key->flags |= flags; + } + +void EC_KEY_clear_flags(EC_KEY *key, int flags) + { + key->flags &= ~flags; + } diff --git a/crypto/ec/ec_lcl.h b/crypto/ec/ec_lcl.h index 2e978181b9..afa1efa4bc 100644 --- a/crypto/ec/ec_lcl.h +++ b/crypto/ec/ec_lcl.h @@ -249,6 +249,7 @@ struct ec_key_st { point_conversion_form_t conv_form; int references; + int flags; EC_EXTRA_DATA *method_data; } /* EC_KEY */; -- 2.25.1