Update patch sent to request tracker - without gap for CRYPTO_EX_INDEX

Salz, Rich wrote:
>> External cryptographic modules may store addition information to key.
>> What about to define CRYPTO_EX_DATA for ec keys?
> That is the plan -- we will remove EX_EX_DATA and the internal API and just 
> use the standard crypto_ex_data stuff.  Want to make a more complete patch as 
> a github pull request? :)  Otherwise I'll get to it soon.
>


>From 07ad1979667aeb2ba99a8ed88f679fb684b8cf1c Mon Sep 17 00:00:00 2001
From: Roumen Petrov <[email protected]>
Date: Thu, 24 Dec 2015 09:59:29 +0200
Subject: [PATCH 01/13] extra data for EC_KEY

---
 crypto/ec/ec_lcl.h       |  1 +
 crypto/ec/ec_lib.c       | 10 ++++++++++
 include/openssl/crypto.h | 17 ++++++++---------
 include/openssl/ec.h     |  6 ++++++
 util/libeay.num          |  2 ++
 5 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/crypto/ec/ec_lcl.h b/crypto/ec/ec_lcl.h
index ebfaae3..912aa8e 100644
--- a/crypto/ec/ec_lcl.h
+++ b/crypto/ec/ec_lcl.h
@@ -267,6 +267,7 @@ struct ec_key_st {
     point_conversion_form_t conv_form;
     int references;
     int flags;
+    CRYPTO_EX_DATA ex_data;
     EC_EXTRA_DATA *method_data;
 } /* EC_KEY */ ;
 
diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c
index 7cb4759..e9e5832 100644
--- a/crypto/ec/ec_lib.c
+++ b/crypto/ec/ec_lib.c
@@ -1091,3 +1091,13 @@ int ec_precompute_mont_data(EC_GROUP *group)
     BN_CTX_free(ctx);
     return ret;
 }
+
+int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg)
+{
+    return (CRYPTO_set_ex_data(&key->ex_data, idx, arg));
+}
+
+void *EC_KEY_get_ex_data(const EC_KEY *key, int idx)
+{
+    return (CRYPTO_get_ex_data(&key->ex_data, idx));
+}
diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h
index 0d88a06..7fedb77 100644
--- a/include/openssl/crypto.h
+++ b/include/openssl/crypto.h
@@ -270,15 +270,14 @@ DECLARE_STACK_OF(void)
 # define CRYPTO_EX_INDEX_X509_STORE_CTX   5
 # define CRYPTO_EX_INDEX_DH               6
 # define CRYPTO_EX_INDEX_DSA              7
-# define CRYPTO_EX_INDEX_ECDH             8
-# define CRYPTO_EX_INDEX_ECDSA            9
-# define CRYPTO_EX_INDEX_RSA             10
-# define CRYPTO_EX_INDEX_ENGINE          11
-# define CRYPTO_EX_INDEX_UI              12
-# define CRYPTO_EX_INDEX_BIO             13
-# define CRYPTO_EX_INDEX_STORE           14
-# define CRYPTO_EX_INDEX_APP             15
-# define CRYPTO_EX_INDEX__COUNT          16
+# define CRYPTO_EX_INDEX_RSA              8
+# define CRYPTO_EX_INDEX_ENGINE           9
+# define CRYPTO_EX_INDEX_UI              10
+# define CRYPTO_EX_INDEX_BIO             11
+# define CRYPTO_EX_INDEX_STORE           12
+# define CRYPTO_EX_INDEX_APP             13
+# define CRYPTO_EX_INDEX_EC_KEY          14
+# define CRYPTO_EX_INDEX__COUNT          15
 
 /*
  * This is the default callbacks, but we can have others as well: this is
diff --git a/include/openssl/ec.h b/include/openssl/ec.h
index 1dc2db1..923844c 100644
--- a/include/openssl/ec.h
+++ b/include/openssl/ec.h
@@ -868,6 +868,12 @@ void *EC_KEY_insert_key_method_data(EC_KEY *key, void *data,
                                     void *(*dup_func) (void *),
                                     void (*free_func) (void *),
                                     void (*clear_free_func) (void *));
+
+#define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \
+    CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef)
+int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg);
+void *EC_KEY_get_ex_data(const EC_KEY *key, int idx);
+
 /* wrapper functions for the underlying EC_GROUP object */
 void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
 
diff --git a/util/libeay.num b/util/libeay.num
index e10a4f1..f92fba4 100755
--- a/util/libeay.num
+++ b/util/libeay.num
@@ -4735,3 +4735,5 @@ OPENSSL_strlcat                         5110	1_1_0	EXIST::FUNCTION:
 OPENSSL_memdup                          5111	1_1_0	NOEXIST::FUNCTION:
 CRYPTO_memdup                           5112	1_1_0	EXIST::FUNCTION:
 CRYPTO_strndup                          5113	1_1_0	EXIST::FUNCTION:
+EC_KEY_get_ex_data                      5114	1_1_0	EXIST::FUNCTION:EC
+EC_KEY_set_ex_data                      5115	1_1_0	EXIST::FUNCTION:EC
-- 
1.8.4

_______________________________________________
openssl-bugs-mod mailing list
[email protected]
https://mta.openssl.org/mailman/listinfo/openssl-bugs-mod
_______________________________________________
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev

Reply via email to