rsa.c (76262) | rsa.c (92559) |
---|---|
1/* 2 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * All rights reserved 5 * 6 * As far as I am concerned, the code I have written for this software 7 * can be used freely for any purpose. Any derived versions of this 8 * software must be clearly marked as such, and if the derived work is --- 46 unchanged lines hidden (view full) --- 55 * 56 * RSA in 3 lines of perl by Adam Back <aba@atlax.ex.ac.uk>, 1995, as 57 * included below: 58 * 59 * [gone - had to be deleted - what a pity] 60 */ 61 62#include "includes.h" | 1/* 2 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * All rights reserved 5 * 6 * As far as I am concerned, the code I have written for this software 7 * can be used freely for any purpose. Any derived versions of this 8 * software must be clearly marked as such, and if the derived work is --- 46 unchanged lines hidden (view full) --- 55 * 56 * RSA in 3 lines of perl by Adam Back <aba@atlax.ex.ac.uk>, 1995, as 57 * included below: 58 * 59 * [gone - had to be deleted - what a pity] 60 */ 61 62#include "includes.h" |
63RCSID("$OpenBSD: rsa.c,v 1.22 2001/03/26 23:23:23 markus Exp $"); 64RCSID("$FreeBSD: head/crypto/openssh/rsa.c 76262 2001-05-04 04:14:23Z green $"); | 63RCSID("$OpenBSD: rsa.c,v 1.24 2001/12/27 18:22:16 markus Exp $"); 64RCSID("$FreeBSD: head/crypto/openssh/rsa.c 92559 2002-03-18 10:09:43Z des $"); |
65 66#include "rsa.h" 67#include "log.h" 68#include "xmalloc.h" 69 70void 71rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key) 72{ --- 43 unchanged lines hidden (view full) --- 116 } 117 memset(outbuf, 0, olen); 118 memset(inbuf, 0, ilen); 119 xfree(outbuf); 120 xfree(inbuf); 121 return len; 122} 123 | 65 66#include "rsa.h" 67#include "log.h" 68#include "xmalloc.h" 69 70void 71rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key) 72{ --- 43 unchanged lines hidden (view full) --- 116 } 117 memset(outbuf, 0, olen); 118 memset(inbuf, 0, ilen); 119 xfree(outbuf); 120 xfree(inbuf); 121 return len; 122} 123 |
124/* calculate p-1 and q-1 */ |
|
124void | 125void |
125generate_additional_parameters(RSA *rsa) | 126rsa_generate_additional_parameters(RSA *rsa) |
126{ 127 BIGNUM *aux; 128 BN_CTX *ctx; | 127{ 128 BIGNUM *aux; 129 BN_CTX *ctx; |
129 /* Generate additional parameters */ 130 aux = BN_new(); 131 ctx = BN_CTX_new(); | |
132 | 130 |
131 if ((aux = BN_new()) == NULL) 132 fatal("rsa_generate_additional_parameters: BN_new failed"); 133 if ((ctx = BN_CTX_new()) == NULL) 134 fatal("rsa_generate_additional_parameters: BN_CTX_new failed"); 135 |
|
133 BN_sub(aux, rsa->q, BN_value_one()); 134 BN_mod(rsa->dmq1, rsa->d, aux, ctx); 135 136 BN_sub(aux, rsa->p, BN_value_one()); 137 BN_mod(rsa->dmp1, rsa->d, aux, ctx); 138 139 BN_clear_free(aux); 140 BN_CTX_free(ctx); 141} 142 | 136 BN_sub(aux, rsa->q, BN_value_one()); 137 BN_mod(rsa->dmq1, rsa->d, aux, ctx); 138 139 BN_sub(aux, rsa->p, BN_value_one()); 140 BN_mod(rsa->dmp1, rsa->d, aux, ctx); 141 142 BN_clear_free(aux); 143 BN_CTX_free(ctx); 144} 145 |