summaryrefslogtreecommitdiff
path: root/openbsd-compat
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
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')
-rw-r--r--openbsd-compat/openssl-compat.c64
-rw-r--r--openbsd-compat/openssl-compat.h15
2 files changed, 77 insertions, 2 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)
diff --git a/openbsd-compat/openssl-compat.h b/openbsd-compat/openssl-compat.h
index beb81f420..c0ca20aaf 100644
--- a/openbsd-compat/openssl-compat.h
+++ b/openbsd-compat/openssl-compat.h
@@ -1,4 +1,4 @@
1/* $Id: openssl-compat.h,v 1.16 2010/10/07 11:06:44 djm Exp $ */ 1/* $Id: openssl-compat.h,v 1.17 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>
@@ -108,6 +108,19 @@ extern const EVP_CIPHER *evp_acss(void);
108# define SSLeay_add_all_algorithms() ssh_SSLeay_add_all_algorithms() 108# define SSLeay_add_all_algorithms() ssh_SSLeay_add_all_algorithms()
109# endif 109# endif
110 110
111# ifndef HAVE_BN_IS_PRIME_EX
112int BN_is_prime_ex(const BIGNUM *, int, BN_CTX *, void *);
113# endif
114
115# ifndef HAVE_DSA_GENERATE_PARAMETERS_EX
116int DSA_generate_parameters_ex(DSA *, int, const unsigned char *, int, int *,
117 unsigned long *, void *);
118# endif
119
120# ifndef HAVE_RSA_GENERATE_KEY_EX
121int RSA_generate_key_ex(RSA *, int, BIGNUM *, void *);
122# endif
123
111int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *, 124int ssh_EVP_CipherInit(EVP_CIPHER_CTX *, const EVP_CIPHER *, unsigned char *,
112 unsigned char *, int); 125 unsigned char *, int);
113int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int); 126int ssh_EVP_Cipher(EVP_CIPHER_CTX *, char *, char *, int);