1RSA_GENERATE_KEY(3)                 OpenSSL                RSA_GENERATE_KEY(3)
2
3
4

NAME

6       RSA_generate_key_ex, RSA_generate_key, RSA_generate_multi_prime_key -
7       generate RSA key pair
8

SYNOPSIS

10        #include <openssl/rsa.h>
11
12        int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
13        int RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes, BIGNUM *e, BN_GENCB *cb);
14
15       Deprecated:
16
17        #if OPENSSL_API_COMPAT < 0x00908000L
18        RSA *RSA_generate_key(int bits, unsigned long e,
19                              void (*callback)(int, int, void *), void *cb_arg);
20        #endif
21

DESCRIPTION

23       RSA_generate_key_ex() generates a 2-prime RSA key pair and stores it in
24       the RSA structure provided in rsa. The pseudo-random number generator
25       must be seeded prior to calling RSA_generate_key_ex().
26
27       RSA_generate_multi_prime_key() generates a multi-prime RSA key pair and
28       stores it in the RSA structure provided in rsa. The number of primes is
29       given by the primes parameter. The random number generator must be
30       seeded when calling RSA_generate_multi_prime_key().  If the automatic
31       seeding or reseeding of the OpenSSL CSPRNG fails due to external
32       circumstances (see RAND(7)), the operation will fail.
33
34       The modulus size will be of length bits, the number of primes to form
35       the modulus will be primes, and the public exponent will be e. Key
36       sizes with num < 1024 should be considered insecure. The exponent is an
37       odd number, typically 3, 17 or 65537.
38
39       In order to maintain adequate security level, the maximum number of
40       permitted primes depends on modulus bit length:
41
42          <1024 | >=1024 | >=4096 | >=8192
43          ------+--------+--------+-------
44            2   |   3    |   4    |   5
45
46       A callback function may be used to provide feedback about the progress
47       of the key generation. If cb is not NULL, it will be called as follows
48       using the BN_GENCB_call() function described on the
49       BN_generate_prime(3) page.
50
51       RSA_generate_key() is similar to RSA_generate_key_ex() but expects an
52       old-style callback function; see BN_generate_prime(3) for information
53       on the old-style callback.
54
55       • While a random prime number is generated, it is called as described
56         in BN_generate_prime(3).
57
58       • When the n-th randomly generated prime is rejected as not suitable
59         for the key, BN_GENCB_call(cb, 2, n) is called.
60
61       • When a random p has been found with p-1 relatively prime to e, it is
62         called as BN_GENCB_call(cb, 3, 0).
63
64       The process is then repeated for prime q and other primes (if any) with
65       BN_GENCB_call(cb, 3, i) where i indicates the i-th prime.
66

RETURN VALUES

68       RSA_generate_multi_prime_key() returns 1 on success or 0 on error.
69       RSA_generate_key_ex() returns 1 on success or 0 on error.  The error
70       codes can be obtained by ERR_get_error(3).
71
72       RSA_generate_key() returns a pointer to the RSA structure or NULL if
73       the key generation fails.
74

BUGS

76       BN_GENCB_call(cb, 2, x) is used with two different meanings.
77

SEE ALSO

79       ERR_get_error(3), RAND_bytes(3), BN_generate_prime(3), RAND(7)
80

HISTORY

82       RSA_generate_key() was deprecated in OpenSSL 0.9.8; use
83       RSA_generate_key_ex() instead.
84
86       Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
87
88       Licensed under the OpenSSL license (the "License").  You may not use
89       this file except in compliance with the License.  You can obtain a copy
90       in the file LICENSE in the source distribution or at
91       <https://www.openssl.org/source/license.html>.
92
93
94
951.1.1q                            2023-07-20               RSA_GENERATE_KEY(3)
Impressum