summaryrefslogtreecommitdiff
path: root/openbsd-compat/openssl-compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/openssl-compat.c')
-rw-r--r--openbsd-compat/openssl-compat.c76
1 files changed, 75 insertions, 1 deletions
diff --git a/openbsd-compat/openssl-compat.c b/openbsd-compat/openssl-compat.c
index 420496caa..b617fdf19 100644
--- a/openbsd-compat/openssl-compat.c
+++ b/openbsd-compat/openssl-compat.c
@@ -1,4 +1,4 @@
1/* $Id: openssl-compat.c,v 1.9 2010/01/28 23:54:11 dtucker Exp $ */ 1/* $Id: openssl-compat.c,v 1.13 2011/01/21 22:37:06 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,10 +18,20 @@
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>
26# include <openssl/conf.h>
27#endif
28
29#ifndef HAVE_RSA_GET_DEFAULT_METHOD
30# include <openssl/rsa.h>
23#endif 31#endif
24 32
33#include "log.h"
34
25#define SSH_DONT_OVERLOAD_OPENSSL_FUNCS 35#define SSH_DONT_OVERLOAD_OPENSSL_FUNCS
26#include "openssl-compat.h" 36#include "openssl-compat.h"
27 37
@@ -58,6 +68,70 @@ ssh_EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt)
58} 68}
59#endif 69#endif
60 70
71#ifndef HAVE_BN_IS_PRIME_EX
72int
73BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, void *cb)
74{
75 if (cb != NULL)
76 fatal("%s: callback args not supported", __func__);
77 return BN_is_prime(p, nchecks, NULL, ctx, NULL);
78}
79#endif
80
81#ifndef HAVE_RSA_GENERATE_KEY_EX
82int
83RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *bn_e, void *cb)
84{
85 RSA *new_rsa, tmp_rsa;
86 unsigned long e;
87
88 if (cb != NULL)
89 fatal("%s: callback args not supported", __func__);
90 e = BN_get_word(bn_e);
91 if (e == 0xffffffffL)
92 fatal("%s: value of e too large", __func__);
93 new_rsa = RSA_generate_key(bits, e, NULL, NULL);
94 if (new_rsa == NULL)
95 return 0;
96 /* swap rsa/new_rsa then free new_rsa */
97 tmp_rsa = *rsa;
98 *rsa = *new_rsa;
99 *new_rsa = tmp_rsa;
100 RSA_free(new_rsa);
101 return 1;
102}
103#endif
104
105#ifndef HAVE_DSA_GENERATE_PARAMETERS_EX
106int
107DSA_generate_parameters_ex(DSA *dsa, int bits, const unsigned char *seed,
108 int seed_len, int *counter_ret, unsigned long *h_ret, void *cb)
109{
110 DSA *new_dsa, tmp_dsa;
111
112 if (cb != NULL)
113 fatal("%s: callback args not supported", __func__);
114 new_dsa = DSA_generate_parameters(bits, (unsigned char *)seed, seed_len,
115 counter_ret, h_ret, NULL, NULL);
116 if (new_dsa == NULL)
117 return 0;
118 /* swap dsa/new_dsa then free new_dsa */
119 tmp_dsa = *dsa;
120 *dsa = *new_dsa;
121 *new_dsa = tmp_dsa;
122 DSA_free(new_dsa);
123 return 1;
124}
125#endif
126
127#ifndef HAVE_RSA_GET_DEFAULT_METHOD
128RSA_METHOD *
129RSA_get_default_method(void)
130{
131 return RSA_PKCS1_SSLeay();
132}
133#endif
134
61#ifdef USE_OPENSSL_ENGINE 135#ifdef USE_OPENSSL_ENGINE
62void 136void
63ssh_SSLeay_add_all_algorithms(void) 137ssh_SSLeay_add_all_algorithms(void)