summaryrefslogtreecommitdiff
path: root/openbsd-compat/openssl-compat.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2010-12-04 23:20:50 +1100
committerDarren Tucker <dtucker@zip.com.au>2010-12-04 23:20:50 +1100
commitebdef76b5df3c33b05128b4fb2cc484427f99ca6 (patch)
treef85300cb02af52a48ee1de7726e6382688504add /openbsd-compat/openssl-compat.c
parentd89745b9e7e2048c13b0173eadc2d41e23b6a79d (diff)
- (dtucker) [configure.ac moduli.c openbsd-compat/openssl-compat.{c,h}] Add
shims for the new, non-deprecated OpenSSL key generation functions for platforms that don't have the new interfaces.
Diffstat (limited to 'openbsd-compat/openssl-compat.c')
-rw-r--r--openbsd-compat/openssl-compat.c64
1 files changed, 63 insertions, 1 deletions
diff --git a/openbsd-compat/openssl-compat.c b/openbsd-compat/openssl-compat.c
index c9bb7cb50..e2d090cf1 100644
--- a/openbsd-compat/openssl-compat.c
+++ b/openbsd-compat/openssl-compat.c
@@ -1,4 +1,4 @@
1/* $Id: openssl-compat.c,v 1.10 2010/11/22 06:59:00 dtucker Exp $ */ 1/* $Id: openssl-compat.c,v 1.11 2010/12/04 12:20:50 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au> 4 * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au>
@@ -18,11 +18,16 @@
18 18
19#include "includes.h" 19#include "includes.h"
20 20
21#include <stdarg.h>
22#include <string.h>
23
21#ifdef USE_OPENSSL_ENGINE 24#ifdef USE_OPENSSL_ENGINE
22# include <openssl/engine.h> 25# include <openssl/engine.h>
23# include <openssl/conf.h> 26# include <openssl/conf.h>
24#endif 27#endif
25 28
29#include "log.h"
30
26#define SSH_DONT_OVERLOAD_OPENSSL_FUNCS 31#define SSH_DONT_OVERLOAD_OPENSSL_FUNCS
27#include "openssl-compat.h" 32#include "openssl-compat.h"
28 33
@@ -59,6 +64,63 @@ ssh_EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt)
59} 64}
60#endif 65#endif
61 66
67#ifndef HAVE_BN_IS_PRIME_EX
68int
69BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, void *cb)
70{
71 if (cb != NULL)
72 fatal("%s: callback args not supported", __func__);
73 return BN_is_prime(p, nchecks, NULL, ctx, NULL);
74}
75#endif
76
77#ifndef HAVE_RSA_GENERATE_KEY_EX
78int
79RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *bn_e, void *cb)
80{
81 RSA *new_rsa, tmp_rsa;
82 unsigned long e;
83
84 sleep(1);
85 if (cb != NULL)
86 fatal("%s: callback args not supported", __func__);
87 e = BN_get_word(bn_e);
88 if (e == 0xffffffffL)
89 fatal("%s: value of e too large", __func__);
90 new_rsa = RSA_generate_key(bits, e, NULL, NULL);
91 if (new_rsa == NULL)
92 return 0;
93 /* swap rsa/new_rsa then free new_rsa */
94 tmp_rsa = *rsa;
95 *rsa = *new_rsa;
96 *new_rsa = tmp_rsa;
97 RSA_free(new_rsa);
98 return 1;
99}
100#endif
101
102#ifndef HAVE_DSA_GENERATE_PARAMETERS_EX
103int
104DSA_generate_parameters_ex(DSA *dsa, int bits, const unsigned char *seed,
105 int seed_len, int *counter_ret, unsigned long *h_ret, void *cb)
106{
107 DSA *new_dsa, tmp_dsa;
108
109 if (cb != NULL)
110 fatal("%s: callback args not supported", __func__);
111 new_dsa = DSA_generate_parameters(bits, (unsigned char *)seed, seed_len,
112 counter_ret, h_ret, NULL, NULL);
113 if (new_dsa == NULL)
114 return 0;
115 /* swap dsa/new_dsa then free new_dsa */
116 tmp_dsa = *dsa;
117 *dsa = *new_dsa;
118 *new_dsa = tmp_dsa;
119 DSA_free(new_dsa);
120 return 1;
121}
122#endif
123
62#ifdef USE_OPENSSL_ENGINE 124#ifdef USE_OPENSSL_ENGINE
63void 125void
64ssh_SSLeay_add_all_algorithms(void) 126ssh_SSLeay_add_all_algorithms(void)