/*
* Principal Author: Brian Wellington
- * $Id: openssl_link.c,v 1.37 2000/09/08 14:23:46 bwelling Exp $
+ * $Id: openssl_link.c,v 1.38 2000/12/04 23:06:35 bwelling Exp $
*/
#if defined(OPENSSL)
#include <isc/entropy.h>
#include <isc/mem.h>
+#include <isc/mutex.h>
+#include <isc/mutexblock.h>
#include <isc/sha1.h>
#include <isc/string.h>
+#include <isc/thread.h>
#include <isc/util.h>
#include <dst/result.h>
#include <openssl/rand.h>
static RAND_METHOD *rm = NULL;
+static isc_mutex_t locks[CRYPTO_NUM_LOCKS];
static isc_result_t openssldsa_todns(const dst_key_t *key, isc_buffer_t *data);
DSA_free(dsa);
return (DST_R_OPENSSLFAILURE);
}
+ dsa->flags &= ~DSA_FLAG_CACHE_MONT_P;
key->opaque = dsa;
dsa = DSA_new();
if (dsa == NULL)
return (ISC_R_NOMEMORY);
+ dsa->flags &= ~DSA_FLAG_CACHE_MONT_P;
t = (unsigned int) *r.base++;
if (t > 8) {
dsa = DSA_new();
if (dsa == NULL)
DST_RET(ISC_R_NOMEMORY);
+ dsa->flags &= ~DSA_FLAG_CACHE_MONT_P;
key->opaque = dsa;
for (i=0; i < priv.nelements; i++) {
UNUSED(entropy);
}
+static void
+lock_callback(int mode, int type, const char *file, int line) {
+ if ((mode & CRYPTO_LOCK) != 0)
+ LOCK(&locks[type]);
+ else
+ UNLOCK(&locks[type]);
+}
+
+static unsigned long
+id_callback(void) {
+ return ((unsigned long)isc_thread_self());
+}
+
isc_result_t
dst__openssl_init(void) {
+ isc_result_t result;
+
CRYPTO_set_mem_functions(dst__mem_alloc, dst__mem_realloc,
dst__mem_free);
+ result = isc_mutexblock_init(locks, CRYPTO_NUM_LOCKS);
+ if (result != ISC_R_SUCCESS)
+ return (result);
+ CRYPTO_set_locking_callback(lock_callback);
+ CRYPTO_set_id_callback(id_callback);
rm = dst__mem_alloc(sizeof(RAND_METHOD));
if (rm == NULL)
return (ISC_R_NOMEMORY);
void
dst__openssl_destroy(void) {
+ RUNTIME_CHECK(isc_mutexblock_destroy(locks, CRYPTO_NUM_LOCKS) ==
+ ISC_R_SUCCESS);
dst__mem_free(rm);
}
/*
* Principal Author: Brian Wellington
- * $Id: openssldh_link.c,v 1.31 2000/09/08 14:23:48 bwelling Exp $
+ * $Id: openssldh_link.c,v 1.32 2000/12/04 23:06:36 bwelling Exp $
*/
#if defined(OPENSSL)
DH_free(dh);
return (DST_R_OPENSSLFAILURE);
}
+ dh->flags &= ~DH_FLAG_CACHE_MONT_P;
key->opaque = dh;
dh = DH_new();
if (dh == NULL)
return (ISC_R_NOMEMORY);
+ dh->flags &= ~DH_FLAG_CACHE_MONT_P;
/*
* Read the prime length. 1 & 2 are table entries, > 16 means a
dh = DH_new();
if (dh == NULL)
DST_RET(ISC_R_NOMEMORY);
+ dh->flags &= ~DH_FLAG_CACHE_MONT_P;
key->opaque = dh;
for (i=0; i < priv.nelements; i++) {
/*
* Principal Author: Brian Wellington
- * $Id: opensslrsa_link.c,v 1.4 2000/11/22 00:11:30 bwelling Exp $
+ * $Id: opensslrsa_link.c,v 1.5 2000/12/04 23:06:37 bwelling Exp $
*/
#if defined(OPENSSL)
else
e = RSA_F4;
rsa = RSA_generate_key(key->key_size, e, NULL, NULL);
+ rsa->flags &= ~(RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE);
if (rsa == NULL) {
ERR_clear_error();
rsa = RSA_new();
if (rsa == NULL)
return (ISC_R_NOMEMORY);
+ rsa->flags &= ~(RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE);
if (r.length < 1)
return (DST_R_INVALIDPUBLICKEY);
rsa = RSA_new();
if (rsa == NULL)
DST_RET(ISC_R_NOMEMORY);
+ rsa->flags &= ~(RSA_FLAG_CACHE_PUBLIC | RSA_FLAG_CACHE_PRIVATE);
key->opaque = rsa;
for (i = 0; i < priv.nelements; i++) {