Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@chromium.org>2015-02-04 04:20:06 +0300
committerAdam Langley <agl@google.com>2015-02-06 23:56:10 +0300
commit4e04ee8786896b982ef2a65c11530ffdf3e942c8 (patch)
treeae372b12ff111d8a54ea7e3b5c07f05bbb7b7877 /crypto/engine
parent3fd1fbd1c80fdeff474b468308f47284c98f7f00 (diff)
Remove support for dynamic METHODs.
The ENGINE code had a concept of a stable-ABI for METHODs, because that might be a useful thing in the future when people want to have blobs that wrap PKCS#11 or something. However, at the moment nobody uses this feature and it didn't work very well anyway: I hadn't updated |ENGINE_free| to free them all and |set_method| was copying the methods, but not resetting the |is_static| flag. This change removes support for non-static methods. We can always put it back later if we need. Change-Id: Ic7401c8cb1cadd46b26a215f85bc48562efe9919 Reviewed-on: https://boringssl-review.googlesource.com/3300 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/engine')
-rw-r--r--crypto/engine/engine.c42
1 files changed, 12 insertions, 30 deletions
diff --git a/crypto/engine/engine.c b/crypto/engine/engine.c
index 5b8cf1c5..6c3300d3 100644
--- a/crypto/engine/engine.c
+++ b/crypto/engine/engine.c
@@ -15,6 +15,7 @@
#include <openssl/engine.h>
#include <string.h>
+#include <assert.h>
#include <openssl/dh.h>
#include <openssl/dsa.h>
@@ -43,33 +44,23 @@ ENGINE *ENGINE_new(void) {
}
void ENGINE_free(ENGINE *engine) {
- if (engine->dh_method != NULL) {
- METHOD_unref(engine->dh_method);
- }
-
+ /* Methods are currently required to be static so are not unref'ed. */
OPENSSL_free(engine);
}
/* set_method takes a pointer to a method and its given size and sets
- * |*out_member| to point to a copy of it. The copy is |compiled_size| bytes
- * long and has zero padding if needed. */
+ * |*out_member| to point to it. This function might want to be extended in the
+ * future to support making a copy of the method so that a stable ABI for
+ * ENGINEs can be supported. But, for the moment, all *_METHODS must be
+ * static. */
static int set_method(void **out_member, const void *method, size_t method_size,
size_t compiled_size) {
- void *copy = OPENSSL_malloc(compiled_size);
- if (copy == NULL) {
+ const struct openssl_method_common_st *common = method;
+ if (method_size != compiled_size || !common->is_static) {
return 0;
}
- memset(copy, 0, compiled_size);
-
- if (method_size > compiled_size) {
- method_size = compiled_size;
- }
- memcpy(copy, method, method_size);
-
- METHOD_unref(*out_member);
- *out_member = copy;
-
+ *out_member = (void*) method;
return 1;
}
@@ -114,25 +105,16 @@ ECDSA_METHOD *ENGINE_get_ECDSA_method(const ENGINE *engine) {
}
void METHOD_ref(void *method_in) {
- struct openssl_method_common_st *method = method_in;
-
- if (method->is_static) {
- return;
- }
-
- CRYPTO_add(&method->references, 1, CRYPTO_LOCK_ENGINE);
+ assert(((struct openssl_method_common_st*) method_in)->is_static);
}
void METHOD_unref(void *method_in) {
struct openssl_method_common_st *method = method_in;
- if (method == NULL || method->is_static) {
+ if (method == NULL) {
return;
}
-
- if (CRYPTO_add(&method->references, -1, CRYPTO_LOCK_ENGINE) == 0) {
- OPENSSL_free(method);
- }
+ assert(method->is_static);
}
OPENSSL_DECLARE_ERROR_REASON(ENGINE, OPERATION_NOT_SUPPORTED);