Debian Codegraph @

upstream/debian-unstable/man3/RSA_generate_key.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "RSA_GENERATE_KEY 3SSL"
58 .TH RSA_GENERATE_KEY 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 EVP_RSA_gen,
65 RSA_generate_key_ex, RSA_generate_key,
66 RSA_generate_multi_prime_key \- generate RSA key pair
67 .SH SYNOPSIS
68 .IX Header "SYNOPSIS"
69 .Vb 1
70 \& #include <openssl/rsa.h>
71 \&
72 \& EVP_PKEY *EVP_RSA_gen(unsigned int bits);
73 .Ve
74 .PP
75 The following functions have been deprecated since OpenSSL 3.0, and can be
76 hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
77 see \fBopenssl_user_macros\fR\|(7):
78 .PP
79 .Vb 2
80 \& int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
81 \& int RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes, BIGNUM *e, BN_GENCB *cb);
82 .Ve
83 .PP
84 The following function has been deprecated since OpenSSL 0.9.8, and can be
85 hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
86 see \fBopenssl_user_macros\fR\|(7):
87 .PP
88 .Vb 2
89 \& RSA *RSA_generate_key(int bits, unsigned long e,
90 \& void (*callback)(int, int, void *), void *cb_arg);
91 .Ve
92 .SH DESCRIPTION
93 .IX Header "DESCRIPTION"
94 \&\fBEVP_RSA_gen()\fR generates a new RSA key pair with modulus size \fIbits\fR.
95 .PP
96 All of the functions described below are deprecated.
97 Applications should instead use \fBEVP_RSA_gen()\fR, \fBEVP_PKEY_Q_keygen\fR\|(3), or
98 \&\fBEVP_PKEY_keygen_init\fR\|(3) and \fBEVP_PKEY_keygen\fR\|(3).
99 .PP
100 \&\fBRSA_generate_key_ex()\fR generates a 2\-prime RSA key pair and stores it in the
101 \&\fBRSA\fR structure provided in \fIrsa\fR.
102 .PP
103 \&\fBRSA_generate_multi_prime_key()\fR generates a multi-prime RSA key pair and stores
104 it in the \fBRSA\fR structure provided in \fIrsa\fR. The number of primes is given by
105 the \fIprimes\fR parameter.
106 If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
107 external circumstances (see \fBRAND\fR\|(7)), the operation will fail.
108 .PP
109 The modulus size will be of length \fIbits\fR, the number of primes to form the
110 modulus will be \fIprimes\fR, and the public exponent will be \fIe\fR. Key sizes
111 with \fInum\fR < 1024 should be considered insecure. The exponent is an odd
112 number, typically 3, 17 or 65537.
113 .PP
114 In order to maintain adequate security level, the maximum number of permitted
115 \&\fIprimes\fR depends on modulus bit length:
116 .PP
117 .Vb 3
118 \& <1024 | >=1024 | >=4096 | >=8192
119 \& \-\-\-\-\-\-+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-
120 \& 2 | 3 | 4 | 5
121 .Ve
122 .PP
123 A callback function may be used to provide feedback about the
124 progress of the key generation. If \fIcb\fR is not NULL, it
125 will be called as follows using the \fBBN_GENCB_call()\fR function
126 described on the \fBBN_generate_prime\fR\|(3) page.
127 .PP
128 \&\fBRSA_generate_key()\fR is similar to \fBRSA_generate_key_ex()\fR but
129 expects an old-style callback function; see
130 \&\fBBN_generate_prime\fR\|(3) for information on the old-style callback.
131 .IP \(bu 2
132 While a random prime number is generated, it is called as
133 described in \fBBN_generate_prime\fR\|(3).
134 .IP \(bu 2
135 When the n\-th randomly generated prime is rejected as not
136 suitable for the key, \fIBN_GENCB_call(cb, 2, n)\fR is called.
137 .IP \(bu 2
138 When a random p has been found with p\-1 relatively prime to \fIe\fR,
139 it is called as \fIBN_GENCB_call(cb, 3, 0)\fR.
140 .PP
141 The process is then repeated for prime q and other primes (if any)
142 with \fIBN_GENCB_call(cb, 3, i)\fR where \fIi\fR indicates the i\-th prime.
143 .SH "RETURN VALUES"
144 .IX Header "RETURN VALUES"
145 \&\fBEVP_RSA_gen()\fR returns an \fIEVP_PKEY\fR or NULL on failure.
146 .PP
147 \&\fBRSA_generate_multi_prime_key()\fR returns 1 on success or 0 on error.
148 \&\fBRSA_generate_key_ex()\fR returns 1 on success or 0 on error.
149 The error codes can be obtained by \fBERR_get_error\fR\|(3).
150 .PP
151 \&\fBRSA_generate_key()\fR returns a pointer to the RSA structure or
152 NULL if the key generation fails.
153 .SH BUGS
154 .IX Header "BUGS"
155 \&\fIBN_GENCB_call(cb, 2, x)\fR is used with two different meanings.
156 .SH "SEE ALSO"
157 .IX Header "SEE ALSO"
158 \&\fBEVP_PKEY_Q_keygen\fR\|(3)
159 \&\fBBN_generate_prime\fR\|(3), \fBERR_get_error\fR\|(3),
160 \&\fBRAND_bytes\fR\|(3), \fBRAND\fR\|(7)
161 .SH HISTORY
162 .IX Header "HISTORY"
163 \&\fBEVP_RSA_gen()\fR was added in OpenSSL 3.0.
164 All other functions described here were deprecated in OpenSSL 3.0.
165 For replacement see \fBEVP_PKEY\-RSA\fR\|(7).
166 .SH COPYRIGHT
167 .IX Header "COPYRIGHT"
168 Copyright 2000\-2021 The OpenSSL Project Authors. All Rights Reserved.
169 .PP
170 Licensed under the Apache License 2.0 (the "License"). You may not use
171 this file except in compliance with the License. You can obtain a copy
172 in the file LICENSE in the source distribution or at
173 <https://www.openssl.org/source/license.html>.