diff options
author | miod <> | 2014-07-09 08:20:08 +0000 |
---|---|---|
committer | miod <> | 2014-07-09 08:20:08 +0000 |
commit | 8cbe58f0d357b14b0ce292d336469d0554a567bc (patch) | |
tree | 07872a7ef59da8cea3b3b4a101fa3580e4d658c0 /src/lib/libcrypto/rsa/rsa_depr.c | |
parent | bc1209e388500a20f5e75cab35d1b543ce0bbe74 (diff) | |
download | openbsd-8cbe58f0d357b14b0ce292d336469d0554a567bc.tar.gz openbsd-8cbe58f0d357b14b0ce292d336469d0554a567bc.tar.bz2 openbsd-8cbe58f0d357b14b0ce292d336469d0554a567bc.zip |
KNF
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_depr.c')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_depr.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_depr.c b/src/lib/libcrypto/rsa/rsa_depr.c index 5f60727255..6808b5aecb 100644 --- a/src/lib/libcrypto/rsa/rsa_depr.c +++ b/src/lib/libcrypto/rsa/rsa_depr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa_depr.c,v 1.3 2014/06/12 15:49:30 deraadt Exp $ */ | 1 | /* $OpenBSD: rsa_depr.c,v 1.4 2014/07/09 08:20:08 miod Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -64,34 +64,37 @@ | |||
64 | 64 | ||
65 | #ifndef OPENSSL_NO_DEPRECATED | 65 | #ifndef OPENSSL_NO_DEPRECATED |
66 | 66 | ||
67 | RSA *RSA_generate_key(int bits, unsigned long e_value, | 67 | RSA * |
68 | void (*callback)(int,int,void *), void *cb_arg) | 68 | RSA_generate_key(int bits, unsigned long e_value, |
69 | { | 69 | void (*callback)(int, int, void *), void *cb_arg) |
70 | { | ||
70 | BN_GENCB cb; | 71 | BN_GENCB cb; |
71 | int i; | 72 | int i; |
72 | RSA *rsa = RSA_new(); | 73 | RSA *rsa = RSA_new(); |
73 | BIGNUM *e = BN_new(); | 74 | BIGNUM *e = BN_new(); |
74 | 75 | ||
75 | if(!rsa || !e) goto err; | 76 | if (!rsa || !e) |
77 | goto err; | ||
76 | 78 | ||
77 | /* The problem is when building with 8, 16, or 32 BN_ULONG, | 79 | /* The problem is when building with 8, 16, or 32 BN_ULONG, |
78 | * unsigned long can be larger */ | 80 | * unsigned long can be larger */ |
79 | for (i=0; i<(int)sizeof(unsigned long)*8; i++) | 81 | for (i = 0; i < (int)sizeof(unsigned long) * 8; i++) { |
80 | { | 82 | if (e_value & (1UL << i)) |
81 | if (e_value & (1UL<<i)) | 83 | if (BN_set_bit(e, i) == 0) |
82 | if (BN_set_bit(e,i) == 0) | ||
83 | goto err; | 84 | goto err; |
84 | } | 85 | } |
85 | 86 | ||
86 | BN_GENCB_set_old(&cb, callback, cb_arg); | 87 | BN_GENCB_set_old(&cb, callback, cb_arg); |
87 | 88 | ||
88 | if(RSA_generate_key_ex(rsa, bits, e, &cb)) { | 89 | if (RSA_generate_key_ex(rsa, bits, e, &cb)) { |
89 | BN_free(e); | 90 | BN_free(e); |
90 | return rsa; | 91 | return rsa; |
91 | } | 92 | } |
92 | err: | 93 | err: |
93 | if(e) BN_free(e); | 94 | if (e) |
94 | if(rsa) RSA_free(rsa); | 95 | BN_free(e); |
96 | if (rsa) | ||
97 | RSA_free(rsa); | ||
95 | return 0; | 98 | return 0; |
96 | } | 99 | } |
97 | #endif | 100 | #endif |