diff options
author | tb <> | 2023-04-13 14:59:13 +0000 |
---|---|---|
committer | tb <> | 2023-04-13 14:59:13 +0000 |
commit | 15b6ca969589a3b9b2069bb0b796c42e2f146fc4 (patch) | |
tree | 4f989651344b778b6d4b5b824baf6c4cb56290d1 /src/lib/libcrypto/rsa/rsa_depr.c | |
parent | 444a1e2335883999b57e5f9b1f505b5915c2da3d (diff) | |
download | openbsd-15b6ca969589a3b9b2069bb0b796c42e2f146fc4.tar.gz openbsd-15b6ca969589a3b9b2069bb0b796c42e2f146fc4.tar.bz2 openbsd-15b6ca969589a3b9b2069bb0b796c42e2f146fc4.zip |
Move RSA_generate_key() from rsa_depr.c to rsa_gen.c
Discussed with jsing
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_depr.c')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_depr.c | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_depr.c b/src/lib/libcrypto/rsa/rsa_depr.c index 2d8d55a693..0c3aa67874 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.11 2023/04/09 19:10:23 tb Exp $ */ | 1 | /* $OpenBSD: rsa_depr.c,v 1.12 2023/04/13 14:59:13 tb 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 | * |
@@ -66,35 +66,3 @@ | |||
66 | 66 | ||
67 | #include "bn_local.h" | 67 | #include "bn_local.h" |
68 | 68 | ||
69 | RSA * | ||
70 | RSA_generate_key(int bits, unsigned long e_value, | ||
71 | void (*callback)(int, int, void *), void *cb_arg) | ||
72 | { | ||
73 | BN_GENCB cb; | ||
74 | int i; | ||
75 | RSA *rsa = RSA_new(); | ||
76 | BIGNUM *e = BN_new(); | ||
77 | |||
78 | if (!rsa || !e) | ||
79 | goto err; | ||
80 | |||
81 | /* The problem is when building with 8, 16, or 32 BN_ULONG, | ||
82 | * unsigned long can be larger */ | ||
83 | for (i = 0; i < (int)sizeof(unsigned long) * 8; i++) { | ||
84 | if (e_value & (1UL << i)) | ||
85 | if (BN_set_bit(e, i) == 0) | ||
86 | goto err; | ||
87 | } | ||
88 | |||
89 | BN_GENCB_set_old(&cb, callback, cb_arg); | ||
90 | |||
91 | if (RSA_generate_key_ex(rsa, bits, e, &cb)) { | ||
92 | BN_free(e); | ||
93 | return rsa; | ||
94 | } | ||
95 | err: | ||
96 | BN_free(e); | ||
97 | RSA_free(rsa); | ||
98 | |||
99 | return 0; | ||
100 | } | ||