summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rsa
diff options
context:
space:
mode:
authormarkus <>2002-09-05 12:51:52 +0000
committermarkus <>2002-09-05 12:51:52 +0000
commit5514995a9d5ed91db089875adb509c7781357c0e (patch)
tree2484410a46ba6c05ef94c253da36fbceef990b64 /src/lib/libcrypto/rsa
parentfd9566423b542798f5c8b06e68101a9ea5bb9885 (diff)
downloadopenbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.gz
openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.bz2
openbsd-5514995a9d5ed91db089875adb509c7781357c0e.zip
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/rsa')
-rw-r--r--src/lib/libcrypto/rsa/rsa_null.c23
-rw-r--r--src/lib/libcrypto/rsa/rsa_test.c14
2 files changed, 21 insertions, 16 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_null.c b/src/lib/libcrypto/rsa/rsa_null.c
index 7b58a0eca3..64057fbdcf 100644
--- a/src/lib/libcrypto/rsa/rsa_null.c
+++ b/src/lib/libcrypto/rsa/rsa_null.c
@@ -69,16 +69,16 @@
69 * operations (like storing RSA keys) are permitted. 69 * operations (like storing RSA keys) are permitted.
70 */ 70 */
71 71
72static int RSA_null_public_encrypt(int flen, unsigned char *from, 72static int RSA_null_public_encrypt(int flen, const unsigned char *from,
73 unsigned char *to, RSA *rsa,int padding); 73 unsigned char *to, RSA *rsa,int padding);
74static int RSA_null_private_encrypt(int flen, unsigned char *from, 74static int RSA_null_private_encrypt(int flen, const unsigned char *from,
75 unsigned char *to, RSA *rsa,int padding); 75 unsigned char *to, RSA *rsa,int padding);
76static int RSA_null_public_decrypt(int flen, unsigned char *from, 76static int RSA_null_public_decrypt(int flen, const unsigned char *from,
77 unsigned char *to, RSA *rsa,int padding); 77 unsigned char *to, RSA *rsa,int padding);
78static int RSA_null_private_decrypt(int flen, unsigned char *from, 78static int RSA_null_private_decrypt(int flen, const unsigned char *from,
79 unsigned char *to, RSA *rsa,int padding); 79 unsigned char *to, RSA *rsa,int padding);
80#if 0 /* not currently used */ 80#if 0 /* not currently used */
81static int RSA_null_mod_exp(BIGNUM *r0, BIGNUM *i, RSA *rsa); 81static int RSA_null_mod_exp(const BIGNUM *r0, const BIGNUM *i, RSA *rsa);
82#endif 82#endif
83static int RSA_null_init(RSA *rsa); 83static int RSA_null_init(RSA *rsa);
84static int RSA_null_finish(RSA *rsa); 84static int RSA_null_finish(RSA *rsa);
@@ -88,40 +88,41 @@ static RSA_METHOD rsa_null_meth={
88 RSA_null_public_decrypt, 88 RSA_null_public_decrypt,
89 RSA_null_private_encrypt, 89 RSA_null_private_encrypt,
90 RSA_null_private_decrypt, 90 RSA_null_private_decrypt,
91 NULL, NULL, 91 NULL,
92 NULL,
92 RSA_null_init, 93 RSA_null_init,
93 RSA_null_finish, 94 RSA_null_finish,
94 0, 95 0,
95 NULL, 96 NULL,
96 }; 97 };
97 98
98RSA_METHOD *RSA_null_method(void) 99const RSA_METHOD *RSA_null_method(void)
99 { 100 {
100 return(&rsa_null_meth); 101 return(&rsa_null_meth);
101 } 102 }
102 103
103static int RSA_null_public_encrypt(int flen, unsigned char *from, 104static int RSA_null_public_encrypt(int flen, const unsigned char *from,
104 unsigned char *to, RSA *rsa, int padding) 105 unsigned char *to, RSA *rsa, int padding)
105 { 106 {
106 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 107 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
107 return -1; 108 return -1;
108 } 109 }
109 110
110static int RSA_null_private_encrypt(int flen, unsigned char *from, 111static int RSA_null_private_encrypt(int flen, const unsigned char *from,
111 unsigned char *to, RSA *rsa, int padding) 112 unsigned char *to, RSA *rsa, int padding)
112 { 113 {
113 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 114 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
114 return -1; 115 return -1;
115 } 116 }
116 117
117static int RSA_null_private_decrypt(int flen, unsigned char *from, 118static int RSA_null_private_decrypt(int flen, const unsigned char *from,
118 unsigned char *to, RSA *rsa, int padding) 119 unsigned char *to, RSA *rsa, int padding)
119 { 120 {
120 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 121 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
121 return -1; 122 return -1;
122 } 123 }
123 124
124static int RSA_null_public_decrypt(int flen, unsigned char *from, 125static int RSA_null_public_decrypt(int flen, const unsigned char *from,
125 unsigned char *to, RSA *rsa, int padding) 126 unsigned char *to, RSA *rsa, int padding)
126 { 127 {
127 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED); 128 RSAerr(RSA_F_RSA_NULL, RSA_R_RSA_OPERATIONS_NOT_SUPPORTED);
diff --git a/src/lib/libcrypto/rsa/rsa_test.c b/src/lib/libcrypto/rsa/rsa_test.c
index e5ae0c1f69..b8b462d33b 100644
--- a/src/lib/libcrypto/rsa/rsa_test.c
+++ b/src/lib/libcrypto/rsa/rsa_test.c
@@ -3,12 +3,12 @@
3#include <stdio.h> 3#include <stdio.h>
4#include <string.h> 4#include <string.h>
5 5
6#include "openssl/e_os.h" 6#include "e_os.h"
7 7
8#include <openssl/crypto.h> 8#include <openssl/crypto.h>
9#include <openssl/err.h> 9#include <openssl/err.h>
10#include <openssl/rand.h> 10#include <openssl/rand.h>
11#ifdef NO_RSA 11#ifdef OPENSSL_NO_RSA
12int main(int argc, char *argv[]) 12int main(int argc, char *argv[])
13{ 13{
14 printf("No RSA support\n"); 14 printf("No RSA support\n");
@@ -16,6 +16,7 @@ int main(int argc, char *argv[])
16} 16}
17#else 17#else
18#include <openssl/rsa.h> 18#include <openssl/rsa.h>
19#include <openssl/engine.h>
19 20
20#define SetKey \ 21#define SetKey \
21 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \ 22 key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
@@ -219,10 +220,12 @@ int main(int argc, char *argv[])
219 int clen = 0; 220 int clen = 0;
220 int num; 221 int num;
221 222
223 CRYPTO_malloc_debug_init();
224 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
225 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
226
222 RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */ 227 RAND_seed(rnd_seed, sizeof rnd_seed); /* or OAEP may fail */
223 228
224 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
225
226 plen = sizeof(ptext_ex) - 1; 229 plen = sizeof(ptext_ex) - 1;
227 230
228 for (v = 0; v < 3; v++) 231 for (v = 0; v < 3; v++)
@@ -305,9 +308,10 @@ int main(int argc, char *argv[])
305 RSA_free(key); 308 RSA_free(key);
306 } 309 }
307 310
311 CRYPTO_cleanup_all_ex_data();
308 ERR_remove_state(0); 312 ERR_remove_state(0);
309 313
310 CRYPTO_mem_leaks_fp(stdout); 314 CRYPTO_mem_leaks_fp(stderr);
311 315
312 return err; 316 return err;
313 } 317 }