rsa.c (57430) | rsa.c (57971) |
---|---|
1/* 2 * 3 * rsa.c 4 * 5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 6 * 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 8 * All rights reserved --- 17 unchanged lines hidden (view full) --- 26 * Birkhauser, 1994. 27 * 28 * The RSA Frequently Asked Questions document by RSA Data Security, Inc., 1995. 29 * 30 * RSA in 3 lines of perl by Adam Back <aba@atlax.ex.ac.uk>, 1995, as included 31 * below: 32 * 33 * [gone - had to be deleted - what a pity] | 1/* 2 * 3 * rsa.c 4 * 5 * Author: Tatu Ylonen <ylo@cs.hut.fi> 6 * 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 8 * All rights reserved --- 17 unchanged lines hidden (view full) --- 26 * Birkhauser, 1994. 27 * 28 * The RSA Frequently Asked Questions document by RSA Data Security, Inc., 1995. 29 * 30 * RSA in 3 lines of perl by Adam Back <aba@atlax.ex.ac.uk>, 1995, as included 31 * below: 32 * 33 * [gone - had to be deleted - what a pity] |
34 * 35 * $FreeBSD: head/crypto/openssh/rsa.c 57971 2000-03-13 09:55:53Z kris $ |
|
34 * 35*/ 36 37#include "includes.h" 38RCSID("$Id: rsa.c,v 1.12 2000/02/21 21:47:31 markus Exp $"); 39 40#include "rsa.h" 41#include "ssh.h" --- 78 unchanged lines hidden (view full) --- 120 outbuf = xmalloc(olen); 121 122 ilen = BN_num_bytes(in); 123 inbuf = xmalloc(ilen); 124 BN_bn2bin(in, inbuf); 125 126 if ((len = RSA_public_encrypt(ilen, inbuf, outbuf, key, 127 RSA_PKCS1_PADDING)) <= 0) | 36 * 37*/ 38 39#include "includes.h" 40RCSID("$Id: rsa.c,v 1.12 2000/02/21 21:47:31 markus Exp $"); 41 42#include "rsa.h" 43#include "ssh.h" --- 78 unchanged lines hidden (view full) --- 122 outbuf = xmalloc(olen); 123 124 ilen = BN_num_bytes(in); 125 inbuf = xmalloc(ilen); 126 BN_bn2bin(in, inbuf); 127 128 if ((len = RSA_public_encrypt(ilen, inbuf, outbuf, key, 129 RSA_PKCS1_PADDING)) <= 0) |
128 fatal("rsa_public_encrypt() failed"); | 130 if (BN_num_bits(key->n) > 1024 && RSA_libversion() == RSALIB_RSAREF) 131 fatal("rsa_private_encrypt() failed: RSAREF cannot handle keys larger than 1024 bits."); 132 else 133 fatal("rsa_private_encrypt() failed."); |
129 130 BN_bin2bn(outbuf, len, out); 131 132 memset(outbuf, 0, olen); 133 memset(inbuf, 0, ilen); 134 xfree(outbuf); 135 xfree(inbuf); 136} --- 8 unchanged lines hidden (view full) --- 145 outbuf = xmalloc(olen); 146 147 ilen = BN_num_bytes(in); 148 inbuf = xmalloc(ilen); 149 BN_bn2bin(in, inbuf); 150 151 if ((len = RSA_private_decrypt(ilen, inbuf, outbuf, key, 152 RSA_PKCS1_PADDING)) <= 0) | 134 135 BN_bin2bn(outbuf, len, out); 136 137 memset(outbuf, 0, olen); 138 memset(inbuf, 0, ilen); 139 xfree(outbuf); 140 xfree(inbuf); 141} --- 8 unchanged lines hidden (view full) --- 150 outbuf = xmalloc(olen); 151 152 ilen = BN_num_bytes(in); 153 inbuf = xmalloc(ilen); 154 BN_bn2bin(in, inbuf); 155 156 if ((len = RSA_private_decrypt(ilen, inbuf, outbuf, key, 157 RSA_PKCS1_PADDING)) <= 0) |
153 fatal("rsa_private_decrypt() failed"); | 158 if (BN_num_bits(key->n) > 1024 && RSA_libversion() == RSALIB_RSAREF) 159 fatal("rsa_private_decrypt() failed: RSAREF cannot handle keys larger than 1024 bits."); 160 else 161 fatal("rsa_private_decrypt() failed."); |
154 155 BN_bin2bn(outbuf, len, out); 156 157 memset(outbuf, 0, olen); 158 memset(inbuf, 0, ilen); 159 xfree(outbuf); 160 xfree(inbuf); 161} 162 163/* Set whether to output verbose messages during key generation. */ 164 165void 166rsa_set_verbose(int verbose) 167{ 168 rsa_verbose = verbose; 169} | 162 163 BN_bin2bn(outbuf, len, out); 164 165 memset(outbuf, 0, olen); 166 memset(inbuf, 0, ilen); 167 xfree(outbuf); 168 xfree(inbuf); 169} 170 171/* Set whether to output verbose messages during key generation. */ 172 173void 174rsa_set_verbose(int verbose) 175{ 176 rsa_verbose = verbose; 177} |