summaryrefslogtreecommitdiff
path: root/src/lib/libssl/doc/SSL_CTX_set_tmp_rsa_callback.3
diff options
context:
space:
mode:
authorbentley <>2014-10-12 09:33:04 +0000
committerbentley <>2014-10-12 09:33:04 +0000
commit82b7f378b6907ab315a6e50322d2a0a8794a0aa9 (patch)
treea5087bf8d016a6041c2b6822fbecfd8f6c5e70b1 /src/lib/libssl/doc/SSL_CTX_set_tmp_rsa_callback.3
parent0a63f0cf49369e1926567ab62e04e3355cedf0cd (diff)
downloadopenbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.tar.gz
openbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.tar.bz2
openbsd-82b7f378b6907ab315a6e50322d2a0a8794a0aa9.zip
Convert libssl manpages from pod to mdoc(7).
libcrypto has not been started yet. ok schwarze@ miod@
Diffstat (limited to 'src/lib/libssl/doc/SSL_CTX_set_tmp_rsa_callback.3')
-rw-r--r--src/lib/libssl/doc/SSL_CTX_set_tmp_rsa_callback.3228
1 files changed, 228 insertions, 0 deletions
diff --git a/src/lib/libssl/doc/SSL_CTX_set_tmp_rsa_callback.3 b/src/lib/libssl/doc/SSL_CTX_set_tmp_rsa_callback.3
new file mode 100644
index 0000000000..55b3aaafed
--- /dev/null
+++ b/src/lib/libssl/doc/SSL_CTX_set_tmp_rsa_callback.3
@@ -0,0 +1,228 @@
1.Dd $Mdocdate: October 12 2014 $
2.Dt SSL_CTX_SET_TMP_RSA_CALLBACK.POD 3
3.Os
4.Sh NAME
5.Nm SSL_CTX_set_tmp_rsa_callback ,
6.Nm SSL_CTX_set_tmp_rsa ,
7.Nm SSL_CTX_need_tmp_rsa ,
8.Nm SSL_set_tmp_rsa_callback ,
9.Nm SSL_set_tmp_rsa ,
10.Nm SSL_need_tmp_rsa
11.Nd handle RSA keys for ephemeral key exchange
12.Sh SYNOPSIS
13.In openssl/ssl.h
14.Ft void
15.Fo SSL_CTX_set_tmp_rsa_callback
16.Fa "SSL_CTX *ctx"
17.Fa "RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength)"
18.Fc
19.Ft long
20.Fn SSL_CTX_set_tmp_rsa "SSL_CTX *ctx" "RSA *rsa"
21.Ft long
22.Fn SSL_CTX_need_tmp_rsa "SSL_CTX *ctx"
23.Ft void
24.Fo SSL_set_tmp_rsa_callback
25.Fa "SSL_CTX *ctx"
26.Fa "RSA *(*tmp_rsa_callback)(SSL *ssl, int is_export, int keylength)"
27.Fc
28.Ft long
29.Fn SSL_set_tmp_rsa "SSL *ssl" "RSA *rsa"
30.Ft long
31.Fn SSL_need_tmp_rsa "SSL *ssl"
32.Ft RSA *
33.Fn "(*tmp_rsa_callback)" "SSL *ssl" "int is_export" "int keylength"
34.Sh DESCRIPTION
35.Fn SSL_CTX_set_tmp_rsa_callback
36sets the callback function for
37.Fa ctx
38to be used when a temporary/ephemeral RSA key is required to
39.Fa tmp_rsa_callback .
40The callback is inherited by all
41.Vt SSL
42objects newly created from
43.Fa ctx
44with
45.Xr SSL_new 3 .
46Already created SSL objects are not affected.
47.Pp
48.Fn SSL_CTX_set_tmp_rsa
49sets the temporary/ephemeral RSA key to be used to be
50.Fa rsa .
51The key is inherited by all
52.Vt SSL
53objects newly created from
54.Fa ctx
55with
56.Xr SSL_new 3 .
57Already created SSL objects are not affected.
58.Pp
59.Fn SSL_CTX_need_tmp_rsa
60returns 1,
61if a temporary/ephemeral RSA key is needed for RSA-based strength-limited
62.Sq exportable
63ciphersuites because a RSA key with a keysize larger than 512 bits is installed.
64.Pp
65.Fn SSL_set_tmp_rsa_callback
66sets the callback only for
67.Fa ssl .
68.Pp
69.Fn SSL_set_tmp_rsa
70sets the key only for
71.Fa ssl .
72.Pp
73.Fn SSL_need_tmp_rsa
74returns 1,
75if a temporary/ephemeral RSA key is needed for RSA-based strength-limited
76.Sq exportable
77ciphersuites because a RSA key with a keysize larger than 512 bits is installed.
78.Pp
79These functions apply to SSL/TLS servers only.
80.Sh NOTES
81When using a cipher with RSA authentication,
82an ephemeral RSA key exchange can take place.
83In this case the session data are negotiated using the ephemeral/temporary RSA
84key and the RSA key supplied and certified by the certificate chain is only
85used for signing.
86.Pp
87Under previous export restrictions, ciphers with RSA keys shorter (512 bits)
88than the usual key length of 1024 bits were created.
89To use these ciphers with RSA keys of usual length, an ephemeral key exchange
90must be performed, as the normal (certified) key cannot be directly used.
91.Pp
92Using ephemeral RSA key exchange yields forward secrecy,
93as the connection can only be decrypted when the RSA key is known.
94By generating a temporary RSA key inside the server application that is lost
95when the application is left, it becomes impossible for an attacker to decrypt
96past sessions, even if he gets hold of the normal (certified) RSA key,
97as this key was used for signing only.
98The downside is that creating a RSA key is computationally expensive.
99.Pp
100Additionally, the use of ephemeral RSA key exchange is only allowed in the TLS
101standard when the RSA key can be used for signing only, that is,
102for export ciphers.
103Using ephemeral RSA key exchange for other purposes violates the standard and
104can break interoperability with clients.
105It is therefore strongly recommended to not use ephemeral RSA key exchange and
106use EDH (Ephemeral Diffie-Hellman) key exchange instead in order to achieve
107forward secrecy (see
108.Xr SSL_CTX_set_tmp_dh_callback 3 ) .
109.Pp
110On OpenSSL servers ephemeral RSA key exchange is therefore disabled by default
111and must be explicitly enabled using the
112.Dv SSL_OP_EPHEMERAL_RSA
113option of
114.Xr SSL_CTX_set_options 3 ,
115violating the TLS/SSL
116standard.
117When ephemeral RSA key exchange is required for export ciphers,
118it will automatically be used without this option!
119.Pp
120An application may either directly specify the key or can supply the key via
121a callback function.
122The callback approach has the advantage that the callback may generate the key
123only in case it is actually needed.
124However, as the generation of a RSA key is costly,
125it will lead to a significant delay in the handshake procedure.
126Another advantage of the callback function is that it can supply keys of
127different size (e.g., for
128.Dv SSL_OP_EPHEMERAL_RSA
129usage) while the explicit setting of the key is only useful for key size of
130512 bits to satisfy the export restricted ciphers and does give away key length
131if a longer key would be allowed.
132.Pp
133The
134.Fa tmp_rsa_callback
135is called with the
136.Fa keylength
137needed and the
138.Fa is_export
139information.
140The
141.Fa is_export
142flag is set when the ephemeral RSA key exchange is performed with an export
143cipher.
144.Sh RETURN VALUES
145.Fn SSL_CTX_set_tmp_rsa_callback
146and
147.Fn SSL_set_tmp_rsa_callback
148do not return diagnostic output.
149.Pp
150.Fn SSL_CTX_set_tmp_rsa
151and
152.Fn SSL_set_tmp_rsa
153return 1 on success and 0 on failure.
154Check the error queue to find out the reason of failure.
155.Pp
156.Fn SSL_CTX_need_tmp_rsa
157and
158.Fn SSL_need_tmp_rsa
159return 1 if a temporary RSA key is needed and 0 otherwise.
160.Sh EXAMPLES
161Generate temporary RSA keys to prepare ephemeral RSA key exchange.
162As the generation of a RSA key costs a lot of computer time,
163they are saved for later reuse.
164For demonstration purposes, two keys for 512 bits and 1024 bits
165respectively are generated.
166.Bd -literal
167\&...
168
169/* Set up ephemeral RSA stuff */
170RSA *rsa_512 = NULL;
171RSA *rsa_1024 = NULL;
172
173rsa_512 = RSA_generate_key(512, RSA_F4, NULL, NULL);
174if (rsa_512 == NULL)
175 evaluate_error_queue();
176
177rsa_1024 = RSA_generate_key(1024, RSA_F4, NULL, NULL);
178if (rsa_1024 == NULL)
179 evaluate_error_queue();
180
181\&...
182
183RSA *
184tmp_rsa_callback(SSL *s, int is_export, int keylength)
185{
186 RSA *rsa_tmp = NULL;
187
188 switch (keylength) {
189 case 512:
190 if (rsa_512)
191 rsa_tmp = rsa_512;
192 else {
193 /*
194 * generate on the fly,
195 * should not happen in this example
196 */
197 rsa_tmp = RSA_generate_key(keylength, RSA_F4, NULL,
198 NULL);
199 rsa_512 = rsa_tmp; /* Remember for later reuse */
200 }
201 break;
202 case 1024:
203 if (rsa_1024)
204 rsa_tmp = rsa_1024;
205 else
206 should_not_happen_in_this_example();
207 break;
208 default:
209 /*
210 * Generating a key on the fly is very costly,
211 * so use what is there
212 */
213 if (rsa_1024)
214 rsa_tmp = rsa_1024;
215 else
216 /* Use at least a shorter key */
217 rsa_tmp = rsa_512;
218 }
219 return rsa_tmp;
220}
221.Ed
222.Sh SEE ALSO
223.Xr ciphers 1 ,
224.Xr ssl 3 ,
225.Xr SSL_CTX_set_cipher_list 3 ,
226.Xr SSL_CTX_set_options 3 ,
227.Xr SSL_CTX_set_tmp_dh_callback 3 ,
228.Xr SSL_new 3