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