diff options
author | schwarze <> | 2016-11-05 15:32:20 +0000 |
---|---|---|
committer | schwarze <> | 2016-11-05 15:32:20 +0000 |
commit | 5af30545c000c195ca6e44f207da004e5780ddb5 (patch) | |
tree | 1672f1234352c29443fcacb44e22f1b20f174d99 /src/lib/libssl/doc/SSL_CTX_set_generate_session_id.3 | |
parent | ba7c6bac5d2c870a4d1c1ce9f08db5e57c660625 (diff) | |
download | openbsd-5af30545c000c195ca6e44f207da004e5780ddb5.tar.gz openbsd-5af30545c000c195ca6e44f207da004e5780ddb5.tar.bz2 openbsd-5af30545c000c195ca6e44f207da004e5780ddb5.zip |
move manual pages from doc/ to man/ for consistency with other
libraries, in particular considering that there are unrelated
files in doc/; requested by jsing@ and beck@
Diffstat (limited to 'src/lib/libssl/doc/SSL_CTX_set_generate_session_id.3')
-rw-r--r-- | src/lib/libssl/doc/SSL_CTX_set_generate_session_id.3 | 196 |
1 files changed, 0 insertions, 196 deletions
diff --git a/src/lib/libssl/doc/SSL_CTX_set_generate_session_id.3 b/src/lib/libssl/doc/SSL_CTX_set_generate_session_id.3 deleted file mode 100644 index 0bea48904e..0000000000 --- a/src/lib/libssl/doc/SSL_CTX_set_generate_session_id.3 +++ /dev/null | |||
@@ -1,196 +0,0 @@ | |||
1 | .\" | ||
2 | .\" $OpenBSD: SSL_CTX_set_generate_session_id.3,v 1.2 2014/12/02 14:11:01 jmc Exp $ | ||
3 | .\" | ||
4 | .Dd $Mdocdate: December 2 2014 $ | ||
5 | .Dt SSL_CTX_SET_GENERATE_SESSION_ID 3 | ||
6 | .Os | ||
7 | .Sh NAME | ||
8 | .Nm SSL_CTX_set_generate_session_id , | ||
9 | .Nm SSL_set_generate_session_id , | ||
10 | .Nm SSL_has_matching_session_id | ||
11 | .Nd manipulate generation of SSL session IDs (server only) | ||
12 | .Sh SYNOPSIS | ||
13 | .In openssl/ssl.h | ||
14 | .Bd -literal | ||
15 | typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id, | ||
16 | unsigned int *id_len); | ||
17 | .Ed | ||
18 | .Ft int | ||
19 | .Fn SSL_CTX_set_generate_session_id "SSL_CTX *ctx" "GEN_SESSION_CB cb" | ||
20 | .Ft int | ||
21 | .Fn SSL_set_generate_session_id "SSL *ssl" "GEN_SESSION_CB" "cb);" | ||
22 | .Ft int | ||
23 | .Fo SSL_has_matching_session_id | ||
24 | .Fa "const SSL *ssl" "const unsigned char *id" "unsigned int id_len" | ||
25 | .Fc | ||
26 | .Sh DESCRIPTION | ||
27 | .Fn SSL_CTX_set_generate_session_id | ||
28 | sets the callback function for generating new session ids for SSL/TLS sessions | ||
29 | for | ||
30 | .Fa ctx | ||
31 | to be | ||
32 | .Fa cb . | ||
33 | .Pp | ||
34 | .Fn SSL_set_generate_session_id | ||
35 | sets the callback function for generating new session ids for SSL/TLS sessions | ||
36 | for | ||
37 | .Fa ssl | ||
38 | to be | ||
39 | .Fa cb . | ||
40 | .Pp | ||
41 | .Fn SSL_has_matching_session_id | ||
42 | checks, whether a session with id | ||
43 | .Fa id | ||
44 | (of length | ||
45 | .Fa id_len ) | ||
46 | is already contained in the internal session cache | ||
47 | of the parent context of | ||
48 | .Fa ssl . | ||
49 | .Sh NOTES | ||
50 | When a new session is established between client and server, | ||
51 | the server generates a session id. | ||
52 | The session id is an arbitrary sequence of bytes. | ||
53 | The length of the session id is 16 bytes for SSLv2 sessions and between 1 and | ||
54 | 32 bytes for SSLv3/TLSv1. | ||
55 | The session id is not security critical but must be unique for the server. | ||
56 | Additionally, the session id is transmitted in the clear when reusing the | ||
57 | session so it must not contain sensitive information. | ||
58 | .Pp | ||
59 | Without a callback being set, an OpenSSL server will generate a unique session | ||
60 | id from pseudo random numbers of the maximum possible length. | ||
61 | Using the callback function, the session id can be changed to contain | ||
62 | additional information like, e.g., a host id in order to improve load balancing | ||
63 | or external caching techniques. | ||
64 | .Pp | ||
65 | The callback function receives a pointer to the memory location to put | ||
66 | .Fa id | ||
67 | into and a pointer to the maximum allowed length | ||
68 | .Fa id_len . | ||
69 | The buffer at location | ||
70 | .Fa id | ||
71 | is only guaranteed to have the size | ||
72 | .Fa id_len . | ||
73 | The callback is only allowed to generate a shorter id and reduce | ||
74 | .Fa id_len ; | ||
75 | the callback | ||
76 | .Em must never | ||
77 | increase | ||
78 | .Fa id_len | ||
79 | or write to the location | ||
80 | .Fa id | ||
81 | exceeding the given limit. | ||
82 | .Pp | ||
83 | If a SSLv2 session id is generated and | ||
84 | .Fa id_len | ||
85 | is reduced, it will be restored after the callback has finished and the session | ||
86 | id will be padded with 0x00. | ||
87 | It is not recommended to change the | ||
88 | .Fa id_len | ||
89 | for SSLv2 sessions. | ||
90 | The callback can use the | ||
91 | .Xr SSL_get_version 3 | ||
92 | function to check whether the session is of type SSLv2. | ||
93 | .Pp | ||
94 | The location | ||
95 | .Fa id | ||
96 | is filled with 0x00 before the callback is called, | ||
97 | so the callback may only fill part of the possible length and leave | ||
98 | .Fa id_len | ||
99 | untouched while maintaining reproducibility. | ||
100 | .Pp | ||
101 | Since the sessions must be distinguished, session ids must be unique. | ||
102 | Without the callback a random number is used, | ||
103 | so that the probability of generating the same session id is extremely small | ||
104 | (2^128 possible ids for an SSLv2 session, 2^256 for SSLv3/TLSv1). | ||
105 | In order to ensure the uniqueness of the generated session id, | ||
106 | the callback must call | ||
107 | .Fn SSL_has_matching_session_id | ||
108 | and generate another id if a conflict occurs. | ||
109 | If an id conflict is not resolved, the handshake will fail. | ||
110 | If the application codes, e.g., a unique host id, a unique process number, and | ||
111 | a unique sequence number into the session id, uniqueness could easily be | ||
112 | achieved without randomness added (it should however be taken care that | ||
113 | no confidential information is leaked this way). | ||
114 | If the application cannot guarantee uniqueness, | ||
115 | it is recommended to use the maximum | ||
116 | .Fa id_len | ||
117 | and fill in the bytes not used to code special information with random data to | ||
118 | avoid collisions. | ||
119 | .Pp | ||
120 | .Fn SSL_has_matching_session_id | ||
121 | will only query the internal session cache, not the external one. | ||
122 | Since the session id is generated before the handshake is completed, | ||
123 | it is not immediately added to the cache. | ||
124 | If another thread is using the same internal session cache, | ||
125 | a race condition can occur in that another thread generates the same session id. | ||
126 | Collisions can also occur when using an external session cache, | ||
127 | since the external cache is not tested with | ||
128 | .Fn SSL_has_matching_session_id | ||
129 | and the same race condition applies. | ||
130 | .Pp | ||
131 | When calling | ||
132 | .Fn SSL_has_matching_session_id | ||
133 | for an SSLv2 session with reduced | ||
134 | .Fa id_len Ns , | ||
135 | the match operation will be performed using the fixed length required and with | ||
136 | a 0x00 padded id. | ||
137 | .Pp | ||
138 | The callback must return 0 if it cannot generate a session id for whatever | ||
139 | reason and return 1 on success. | ||
140 | .Sh RETURN VALUES | ||
141 | .Fn SSL_CTX_set_generate_session_id | ||
142 | and | ||
143 | .Fn SSL_set_generate_session_id | ||
144 | always return 1. | ||
145 | .Pp | ||
146 | .Fn SSL_has_matching_session_id | ||
147 | returns 1 if another session with the same id is already in the cache. | ||
148 | .Sh EXAMPLES | ||
149 | The callback function listed will generate a session id with the server id | ||
150 | given, and will fill the rest with pseudo random bytes: | ||
151 | .Bd -literal | ||
152 | const char session_id_prefix = "www-18"; | ||
153 | |||
154 | #define MAX_SESSION_ID_ATTEMPTS 10 | ||
155 | static int | ||
156 | generate_session_id(const SSL *ssl, unsigned char *id, | ||
157 | unsigned int *id_len) | ||
158 | { | ||
159 | unsigned int count = 0; | ||
160 | const char *version; | ||
161 | |||
162 | version = SSL_get_version(ssl); | ||
163 | if (!strcmp(version, "SSLv2")) { | ||
164 | /* we must not change id_len */ | ||
165 | ; | ||
166 | } | ||
167 | |||
168 | do { | ||
169 | RAND_pseudo_bytes(id, *id_len); | ||
170 | /* | ||
171 | * Prefix the session_id with the required prefix. NB: If | ||
172 | * our prefix is too long, clip it \(en but there will be | ||
173 | * worse effects anyway, e.g., the server could only | ||
174 | * possibly create one session ID (the prefix!) so all | ||
175 | * future session negotiations will fail due to conflicts. | ||
176 | */ | ||
177 | memcpy(id, session_id_prefix, | ||
178 | (strlen(session_id_prefix) < *id_len) ? | ||
179 | strlen(session_id_prefix) : *id_len); | ||
180 | } while (SSL_has_matching_session_id(ssl, id, *id_len) && | ||
181 | (++count < MAX_SESSION_ID_ATTEMPTS)); | ||
182 | |||
183 | if (count >= MAX_SESSION_ID_ATTEMPTS) | ||
184 | return 0; | ||
185 | return 1; | ||
186 | } | ||
187 | .Ed | ||
188 | .Sh SEE ALSO | ||
189 | .Xr ssl 3 , | ||
190 | .Xr SSL_get_version 3 | ||
191 | .Sh HISTORY | ||
192 | .Fn SSL_CTX_set_generate_session_id , | ||
193 | .Fn SSL_set_generate_session_id | ||
194 | and | ||
195 | .Fn SSL_has_matching_session_id | ||
196 | were introduced in OpenSSL 0.9.7. | ||