OLD | NEW |
1 /* | 1 /* |
2 * This file contains prototypes for the public SSL functions. | 2 * This file contains prototypes for the public SSL functions. |
3 * | 3 * |
4 * ***** BEGIN LICENSE BLOCK ***** | 4 * ***** BEGIN LICENSE BLOCK ***** |
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
6 * | 6 * |
7 * The contents of this file are subject to the Mozilla Public License Version | 7 * The contents of this file are subject to the Mozilla Public License Version |
8 * 1.1 (the "License"); you may not use this file except in compliance with | 8 * 1.1 (the "License"); you may not use this file except in compliance with |
9 * the License. You may obtain a copy of the License at | 9 * the License. You may obtain a copy of the License at |
10 * http://www.mozilla.org/MPL/ | 10 * http://www.mozilla.org/MPL/ |
(...skipping 18 matching lines...) Expand all Loading... |
29 * in which case the provisions of the GPL or the LGPL are applicable instead | 29 * in which case the provisions of the GPL or the LGPL are applicable instead |
30 * of those above. If you wish to allow use of your version of this file only | 30 * of those above. If you wish to allow use of your version of this file only |
31 * under the terms of either the GPL or the LGPL, and not to allow others to | 31 * under the terms of either the GPL or the LGPL, and not to allow others to |
32 * use your version of this file under the terms of the MPL, indicate your | 32 * use your version of this file under the terms of the MPL, indicate your |
33 * decision by deleting the provisions above and replace them with the notice | 33 * decision by deleting the provisions above and replace them with the notice |
34 * and other provisions required by the GPL or the LGPL. If you do not delete | 34 * and other provisions required by the GPL or the LGPL. If you do not delete |
35 * the provisions above, a recipient may use your version of this file under | 35 * the provisions above, a recipient may use your version of this file under |
36 * the terms of any one of the MPL, the GPL or the LGPL. | 36 * the terms of any one of the MPL, the GPL or the LGPL. |
37 * | 37 * |
38 * ***** END LICENSE BLOCK ***** */ | 38 * ***** END LICENSE BLOCK ***** */ |
39 /* $Id: ssl.h,v 1.38.2.1 2010/07/31 04:33:52 wtc%google.com Exp $ */ | 39 /* $Id: ssl.h,v 1.49 2012/02/15 21:52:08 kaie%kuix.de Exp $ */ |
40 | 40 |
41 #ifndef __ssl_h_ | 41 #ifndef __ssl_h_ |
42 #define __ssl_h_ | 42 #define __ssl_h_ |
43 | 43 |
44 #include "prtypes.h" | 44 #include "prtypes.h" |
45 #include "prerror.h" | 45 #include "prerror.h" |
46 #include "prio.h" | 46 #include "prio.h" |
47 #include "seccomon.h" | 47 #include "seccomon.h" |
48 #include "cert.h" | 48 #include "cert.h" |
49 #include "keyt.h" | 49 #include "keyt.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 ** require a certificate during secure connect | 93 ** require a certificate during secure connect |
94 */ | 94 */ |
95 /* options */ | 95 /* options */ |
96 #define SSL_SECURITY 1 /* (on by default) */ | 96 #define SSL_SECURITY 1 /* (on by default) */ |
97 #define SSL_SOCKS 2 /* (off by default) */ | 97 #define SSL_SOCKS 2 /* (off by default) */ |
98 #define SSL_REQUEST_CERTIFICATE 3 /* (off by default) */ | 98 #define SSL_REQUEST_CERTIFICATE 3 /* (off by default) */ |
99 #define SSL_HANDSHAKE_AS_CLIENT 5 /* force accept to hs as client */ | 99 #define SSL_HANDSHAKE_AS_CLIENT 5 /* force accept to hs as client */ |
100 /* (off by default) */ | 100 /* (off by default) */ |
101 #define SSL_HANDSHAKE_AS_SERVER 6 /* force connect to hs as server */ | 101 #define SSL_HANDSHAKE_AS_SERVER 6 /* force connect to hs as server */ |
102 /* (off by default) */ | 102 /* (off by default) */ |
103 #define SSL_ENABLE_SSL2»» » 7 /* enable ssl v2 (on by default) */ | 103 #define SSL_ENABLE_SSL2»» » 7 /* enable ssl v2 (off by default) */ |
104 #define SSL_ENABLE_SSL3 8 /* enable ssl v3 (on by default) */ | 104 #define SSL_ENABLE_SSL3 8 /* enable ssl v3 (on by default) */ |
105 #define SSL_NO_CACHE 9 /* don't use the session cache */ | 105 #define SSL_NO_CACHE 9 /* don't use the session cache */ |
106 /* (off by default) */ | 106 /* (off by default) */ |
107 #define SSL_REQUIRE_CERTIFICATE 10 /* (SSL_REQUIRE_FIRST_HANDSHAKE */ | 107 #define SSL_REQUIRE_CERTIFICATE 10 /* (SSL_REQUIRE_FIRST_HANDSHAKE */ |
108 /* by default) */ | 108 /* by default) */ |
109 #define SSL_ENABLE_FDX 11 /* permit simultaneous read/write */ | 109 #define SSL_ENABLE_FDX 11 /* permit simultaneous read/write */ |
110 /* (off by default) */ | 110 /* (off by default) */ |
111 #define SSL_V2_COMPATIBLE_HELLO 12 /* send v3 client hello in v2 fmt */ | 111 #define SSL_V2_COMPATIBLE_HELLO 12 /* send v3 client hello in v2 fmt */ |
112 /* (on by default) */ | 112 /* (off by default) */ |
113 #define SSL_ENABLE_TLS 13 /* enable TLS (on by default) */ | 113 #define SSL_ENABLE_TLS 13 /* enable TLS (on by default) */ |
114 #define SSL_ROLLBACK_DETECTION 14 /* for compatibility, default: on */ | 114 #define SSL_ROLLBACK_DETECTION 14 /* for compatibility, default: on */ |
115 #define SSL_NO_STEP_DOWN 15 /* Disable export cipher suites */ | 115 #define SSL_NO_STEP_DOWN 15 /* Disable export cipher suites */ |
116 /* if step-down keys are needed. */ | 116 /* if step-down keys are needed. */ |
117 /* default: off, generate */ | 117 /* default: off, generate */ |
118 /* step-down keys if needed. */ | 118 /* step-down keys if needed. */ |
119 #define SSL_BYPASS_PKCS11 16 /* use PKCS#11 for pub key only */ | 119 #define SSL_BYPASS_PKCS11 16 /* use PKCS#11 for pub key only */ |
120 #define SSL_NO_LOCKS 17 /* Don't use locks for protection */ | 120 #define SSL_NO_LOCKS 17 /* Don't use locks for protection */ |
121 #define SSL_ENABLE_SESSION_TICKETS 18 /* Enable TLS SessionTicket */ | 121 #define SSL_ENABLE_SESSION_TICKETS 18 /* Enable TLS SessionTicket */ |
122 /* extension (off by default) */ | 122 /* extension (off by default) */ |
123 #define SSL_ENABLE_DEFLATE 19 /* Enable TLS compression with */ | 123 #define SSL_ENABLE_DEFLATE 19 /* Enable TLS compression with */ |
124 /* DEFLATE (off by default) */ | 124 /* DEFLATE (off by default) */ |
125 #define SSL_ENABLE_RENEGOTIATION 20 /* Values below (default: never) */ | 125 #define SSL_ENABLE_RENEGOTIATION 20 /* Values below (default: never) */ |
126 #define SSL_REQUIRE_SAFE_NEGOTIATION 21 /* Peer must send Signaling */ | 126 #define SSL_REQUIRE_SAFE_NEGOTIATION 21 /* Peer must send Signaling */ |
127 /* Cipher Suite Value (SCSV) or */ | 127 /* Cipher Suite Value (SCSV) or */ |
128 /* Renegotiation Info (RI) */ | 128 /* Renegotiation Info (RI) */ |
129 /* extension in ALL handshakes. */ | 129 /* extension in ALL handshakes. */ |
130 /* default: off */ | 130 /* default: off */ |
131 #define SSL_ENABLE_FALSE_START 22 /* Enable SSL false start (off by */ | 131 #define SSL_ENABLE_FALSE_START 22 /* Enable SSL false start (off by */ |
132 /* default, applies only to */ | 132 /* default, applies only to */ |
133 /* clients). False start is a */ | 133 /* clients). False start is a */ |
134 /* mode where an SSL client will start sending application data before */ | 134 /* mode where an SSL client will start sending application data before */ |
135 /* verifying the server's Finished message. This means that we could end up */ | 135 /* verifying the server's Finished message. This means that we could end up */ |
136 /* sending data to an imposter. However, the data will be encrypted and */ | 136 /* sending data to an imposter. However, the data will be encrypted and */ |
137 /* only the true server can derive the session key. Thus, so long as the */ | 137 /* only the true server can derive the session key. Thus, so long as the */ |
138 /* cipher isn't broken this is safe. Because of this, False Start will only */ | 138 /* cipher isn't broken this is safe. Because of this, False Start will only */ |
139 /* occur on RSA or DH ciphersuites where the cipher's key length is >= 80 */ | 139 /* occur on RSA or DH ciphersuites where the cipher's key length is >= 80 */ |
140 /* bits. The advantage of False Start is that it saves a round trip for */ | 140 /* bits. The advantage of False Start is that it saves a round trip for */ |
141 /* client-speaks-first protocols when performing a full handshake. */ | 141 /* client-speaks-first protocols when performing a full handshake. */ |
142 #define SSL_ENABLE_OCSP_STAPLING 23 /* Request OCSP stapling (client) */ | 142 |
143 #define SSL_ENABLE_CACHED_INFO 24 /* Enable TLS cached information */ | 143 /* For SSL 3.0 and TLS 1.0, by default we prevent chosen plaintext attacks |
144 /* extension, off by default. */ | 144 * on SSL CBC mode cipher suites (see RFC 4346 Section F.3) by splitting |
| 145 * non-empty application_data records into two records; the first record has |
| 146 * only the first byte of plaintext, and the second has the rest. |
| 147 * |
| 148 * This only prevents the attack in the sending direction; the connection may |
| 149 * still be vulnerable to such attacks if the peer does not implement a similar |
| 150 * countermeasure. |
| 151 * |
| 152 * This protection mechanism is on by default; the default can be overridden by |
| 153 * setting NSS_SSL_CBC_RANDOM_IV=0 in the environment prior to execution, |
| 154 * and/or by the application setting the option SSL_CBC_RANDOM_IV to PR_FALSE. |
| 155 * |
| 156 * The per-record IV in TLS 1.1 and later adds one block of overhead per |
| 157 * record, whereas this hack will add at least two blocks of overhead per |
| 158 * record, so TLS 1.1+ will always be more efficient. |
| 159 * |
| 160 * Other implementations (e.g. some versions of OpenSSL, in some |
| 161 * configurations) prevent the same attack by prepending an empty |
| 162 * application_data record to every application_data record they send; we do |
| 163 * not do that because some implementations cannot handle empty |
| 164 * application_data records. Also, we only split application_data records and |
| 165 * not other types of records, because some implementations will not accept |
| 166 * fragmented records of some other types (e.g. some versions of NSS do not |
| 167 * accept fragmented alerts). |
| 168 */ |
| 169 #define SSL_CBC_RANDOM_IV 23 |
| 170 #define SSL_ENABLE_OCSP_STAPLING 24 /* Request OCSP stapling (client) */ |
145 #define SSL_ENABLE_OB_CERTS 25 /* Enable origin bound certs. */ | 171 #define SSL_ENABLE_OB_CERTS 25 /* Enable origin bound certs. */ |
146 #define SSL_ENCRYPT_CLIENT_CERTS 26 /* Enable encrypted client certs. */ | 172 #define SSL_ENCRYPT_CLIENT_CERTS 26 /* Enable encrypted client certs. */ |
147 | 173 |
148 #ifdef SSL_DEPRECATED_FUNCTION | 174 #ifdef SSL_DEPRECATED_FUNCTION |
149 /* Old deprecated function names */ | 175 /* Old deprecated function names */ |
150 SSL_IMPORT SECStatus SSL_Enable(PRFileDesc *fd, int option, PRBool on); | 176 SSL_IMPORT SECStatus SSL_Enable(PRFileDesc *fd, int option, PRBool on); |
151 SSL_IMPORT SECStatus SSL_EnableDefault(int option, PRBool on); | 177 SSL_IMPORT SECStatus SSL_EnableDefault(int option, PRBool on); |
152 #endif | 178 #endif |
153 | 179 |
154 /* New function names */ | 180 /* New function names */ |
155 SSL_IMPORT SECStatus SSL_OptionSet(PRFileDesc *fd, PRInt32 option, PRBool on); | 181 SSL_IMPORT SECStatus SSL_OptionSet(PRFileDesc *fd, PRInt32 option, PRBool on); |
156 SSL_IMPORT SECStatus SSL_OptionGet(PRFileDesc *fd, PRInt32 option, PRBool *on); | 182 SSL_IMPORT SECStatus SSL_OptionGet(PRFileDesc *fd, PRInt32 option, PRBool *on); |
157 SSL_IMPORT SECStatus SSL_OptionSetDefault(PRInt32 option, PRBool on); | 183 SSL_IMPORT SECStatus SSL_OptionSetDefault(PRInt32 option, PRBool on); |
158 SSL_IMPORT SECStatus SSL_OptionGetDefault(PRInt32 option, PRBool *on); | 184 SSL_IMPORT SECStatus SSL_OptionGetDefault(PRInt32 option, PRBool *on); |
159 SSL_IMPORT SECStatus SSL_CertDBHandleSet(PRFileDesc *fd, CERTCertDBHandle *dbHan
dle); | 185 SSL_IMPORT SECStatus SSL_CertDBHandleSet(PRFileDesc *fd, CERTCertDBHandle *dbHan
dle); |
160 | 186 |
161 /* SSLNextProtoCallback is called, during the handshake, when the server has | 187 /* SSLNextProtoCallback is called during the handshake for the client, when a |
162 * sent a Next Protocol Negotiation extension. |protos| and |protosLen| define | 188 * Next Protocol Negotiation (NPN) extension has been received from the server. |
163 * a buffer which contains the server's advertisement. This data is guaranteed | 189 * |protos| and |protosLen| define a buffer which contains the server's |
164 * to be well formed per the NPN spec. |protoOut| is a buffer provided by the | 190 * advertisement. This data is guaranteed to be well formed per the NPN spec. |
165 * caller, of length 255 (the maximum allowed by the protocol). | 191 * |protoOut| is a buffer provided by the caller, of length 255 (the maximum |
166 * On successful return, the protocol to be announced to the server will be in | 192 * allowed by the protocol). On successful return, the protocol to be announced |
167 * |protoOut| and its length in |*protoOutLen|. */ | 193 * to the server will be in |protoOut| and its length in |*protoOutLen|. |
| 194 * |
| 195 * The callback must return SECFailure or SECSuccess (not SECWouldBlock). |
| 196 */ |
168 typedef SECStatus (PR_CALLBACK *SSLNextProtoCallback)( | 197 typedef SECStatus (PR_CALLBACK *SSLNextProtoCallback)( |
169 void *arg, | 198 void *arg, |
170 PRFileDesc *fd, | 199 PRFileDesc *fd, |
171 const unsigned char* protos, | 200 const unsigned char* protos, |
172 unsigned int protosLen, | 201 unsigned int protosLen, |
173 unsigned char* protoOut, | 202 unsigned char* protoOut, |
174 unsigned int* protoOutLen); | 203 unsigned int* protoOutLen, |
| 204 unsigned int protoMaxOut); |
175 | 205 |
176 /* SSL_SetNextProtoCallback sets a callback function to handle Next Protocol | 206 /* SSL_SetNextProtoCallback sets a callback function to handle Next Protocol |
177 * Negotiation. It causes a client to advertise NPN. */ | 207 * Negotiation. It causes a client to advertise NPN. */ |
178 SSL_IMPORT SECStatus SSL_SetNextProtoCallback(PRFileDesc *fd, | 208 SSL_IMPORT SECStatus SSL_SetNextProtoCallback(PRFileDesc *fd, |
179 SSLNextProtoCallback callback, | 209 SSLNextProtoCallback callback, |
180 void *arg); | 210 void *arg); |
181 | 211 |
182 /* SSL_SetNextProtoNego can be used as an alternative to | 212 /* SSL_SetNextProtoNego can be used as an alternative to |
183 * SSL_SetNextProtoCallback. It also causes a client to advertise NPN and | 213 * SSL_SetNextProtoCallback. It also causes a client to advertise NPN and |
184 * installs a default callback function which selects the first supported | 214 * installs a default callback function which selects the first supported |
185 * protocol in server-preference order. If no matching protocol is found it | 215 * protocol in server-preference order. If no matching protocol is found it |
186 * selects the first supported protocol. | 216 * selects the first supported protocol. |
187 * | 217 * |
188 * The supported protocols are specified in |data| in wire-format (8-bit | 218 * The supported protocols are specified in |data| in wire-format (8-bit |
189 * length-prefixed). For example: "\010http/1.1\006spdy/2". */ | 219 * length-prefixed). For example: "\010http/1.1\006spdy/2". */ |
190 SSL_IMPORT SECStatus SSL_SetNextProtoNego(PRFileDesc *fd, | 220 SSL_IMPORT SECStatus SSL_SetNextProtoNego(PRFileDesc *fd, |
191 const unsigned char *data, | 221 const unsigned char *data, |
192 unsigned int length); | 222 unsigned int length); |
193 /* SSL_GetNextProto can be used after a handshake on a socket where | 223 |
194 * SSL_SetNextProtoNego was called to retrieve the result of the Next Protocol | 224 typedef enum SSLNextProtoState { |
195 * negotiation. | 225 SSL_NEXT_PROTO_NO_SUPPORT = 0, /* No peer support */ |
| 226 SSL_NEXT_PROTO_NEGOTIATED = 1, /* Mutual agreement */ |
| 227 SSL_NEXT_PROTO_NO_OVERLAP = 2 /* No protocol overlap found */ |
| 228 } SSLNextProtoState; |
| 229 |
| 230 /* SSL_GetNextProto can be used in the HandshakeCallback or any time after |
| 231 * a handshake to retrieve the result of the Next Protocol negotiation. |
196 * | 232 * |
197 * state is set to one of the SSL_NEXT_PROTO_* constants. The negotiated | 233 * The length of the negotiated protocol, if any, is written into *bufLen. |
198 * protocol, if any, is written into buf, which must be at least buf_len bytes | 234 * If the negotiated protocol is longer than bufLenMax, then SECFailure is |
199 * long. If the negotiated protocol is longer than this, it is truncated. The | 235 * returned. Otherwise, the negotiated protocol, if any, is written into buf, |
200 * number of bytes copied is written into *length. */ | 236 * and SECSuccess is returned. */ |
201 SSL_IMPORT SECStatus SSL_GetNextProto(PRFileDesc *fd, | 237 SSL_IMPORT SECStatus SSL_GetNextProto(PRFileDesc *fd, |
202 » » » » int *state, | 238 » » » » SSLNextProtoState *state, |
203 unsigned char *buf, | 239 unsigned char *buf, |
204 » » » » unsigned int *length, | 240 » » » » unsigned int *bufLen, |
205 » » » » unsigned int buf_len); | 241 » » » » unsigned int bufLenMax); |
206 | |
207 /* TODO(wtc): it may be a good idea to define these as an enum type. */ | |
208 #define SSL_NEXT_PROTO_NO_SUPPORT» 0 /* No peer support */ | |
209 #define SSL_NEXT_PROTO_NEGOTIATED» 1 /* Mutual agreement */ | |
210 #define SSL_NEXT_PROTO_NO_OVERLAP» 2 /* No protocol overlap found */ | |
211 | 242 |
212 /* | 243 /* |
213 ** Control ciphers that SSL uses. If on is non-zero then the named cipher | 244 ** Control ciphers that SSL uses. If on is non-zero then the named cipher |
214 ** is enabled, otherwise it is disabled. | 245 ** is enabled, otherwise it is disabled. |
215 ** The "cipher" values are defined in sslproto.h (the SSL_EN_* values). | 246 ** The "cipher" values are defined in sslproto.h (the SSL_EN_* values). |
216 ** EnableCipher records user preferences. | 247 ** EnableCipher records user preferences. |
217 ** SetPolicy sets the policy according to the policy module. | 248 ** SetPolicy sets the policy according to the policy module. |
218 */ | 249 */ |
219 #ifdef SSL_DEPRECATED_FUNCTION | 250 #ifdef SSL_DEPRECATED_FUNCTION |
220 /* Old deprecated function names */ | 251 /* Old deprecated function names */ |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 char **issuer, char **subject); | 328 char **issuer, char **subject); |
298 | 329 |
299 /* Values for "on" */ | 330 /* Values for "on" */ |
300 #define SSL_SECURITY_STATUS_NOOPT -1 | 331 #define SSL_SECURITY_STATUS_NOOPT -1 |
301 #define SSL_SECURITY_STATUS_OFF 0 | 332 #define SSL_SECURITY_STATUS_OFF 0 |
302 #define SSL_SECURITY_STATUS_ON_HIGH 1 | 333 #define SSL_SECURITY_STATUS_ON_HIGH 1 |
303 #define SSL_SECURITY_STATUS_ON_LOW 2 | 334 #define SSL_SECURITY_STATUS_ON_LOW 2 |
304 #define SSL_SECURITY_STATUS_FORTEZZA 3 /* NO LONGER SUPPORTED */ | 335 #define SSL_SECURITY_STATUS_FORTEZZA 3 /* NO LONGER SUPPORTED */ |
305 | 336 |
306 /* | 337 /* |
307 ** Returns true if the server's Certificate message contained a hash of the | |
308 ** certificate chain due to the TLS cached info extension. | |
309 */ | |
310 SSL_IMPORT PRBool SSL_CertChainDigestReceived(PRFileDesc *fd); | |
311 | |
312 /* | |
313 ** Return the certificate for our SSL peer. If the client calls this | 338 ** Return the certificate for our SSL peer. If the client calls this |
314 ** it will always return the server's certificate. If the server calls | 339 ** it will always return the server's certificate. If the server calls |
315 ** this, it may return NULL if client authentication is not enabled or | 340 ** this, it may return NULL if client authentication is not enabled or |
316 ** if the client had no certificate when asked. | 341 ** if the client had no certificate when asked. |
317 ** "fd" the socket "file" descriptor | 342 ** "fd" the socket "file" descriptor |
318 */ | 343 */ |
319 SSL_IMPORT CERTCertificate *SSL_PeerCertificate(PRFileDesc *fd); | 344 SSL_IMPORT CERTCertificate *SSL_PeerCertificate(PRFileDesc *fd); |
320 | 345 |
321 /* | 346 /* |
322 ** Return references to the certificates presented by the SSL peer. On entry, | 347 ** Return references to the certificates presented by the SSL peer. |
323 ** |*certs_size| must contain the size of the |certs| array. On successful | 348 ** |maxNumCerts| must contain the size of the |certs| array. On successful |
324 ** return, |*certs_size| contains the number of certificates available and | 349 ** return, |*numCerts| contains the number of certificates available and |
325 ** |certs| will contain references to as many certificates as would fit. | 350 ** |certs| will contain references to as many certificates as would fit. |
326 ** Therefore if, on exit, |*certs_size| contains a value less than, or equal to, | 351 ** Therefore if |*numCerts| contains a value less than or equal to |
327 ** the entry value then all certificates were returned. | 352 ** |maxNumCerts|, then all certificates were returned. |
328 */ | 353 */ |
329 SSL_IMPORT SECStatus SSL_PeerCertificateChain( | 354 SSL_IMPORT SECStatus SSL_PeerCertificateChain( |
330 » PRFileDesc *fd, CERTCertificate **certs, unsigned int *certs_size); | 355 » PRFileDesc *fd, CERTCertificate **certs, |
331 | 356 » unsigned int *numCerts, unsigned int maxNumCerts); |
332 /* | |
333 ** Set the predicted cert chain to be used in the cached info extension. | |
334 */ | |
335 SSL_IMPORT SECStatus SSL_SetPredictedPeerCertificates(PRFileDesc *fd, | |
336 » » » » » » CERTCertificate **certs, | |
337 » » » » » » unsigned int len); | |
338 | 357 |
339 /* SSL_GetStapledOCSPResponse returns the OCSP response that was provided by | 358 /* SSL_GetStapledOCSPResponse returns the OCSP response that was provided by |
340 * the TLS server. The resulting data is copied to |out_data|. On entry, |*len| | 359 * the TLS server. The resulting data is copied to |out_data|. On entry, |*len| |
341 * must contain the size of |out_data|. On exit, |*len| will contain the size | 360 * must contain the size of |out_data|. On exit, |*len| will contain the size |
342 * of the OCSP stapled response. If the stapled response is too large to fit in | 361 * of the OCSP stapled response. If the stapled response is too large to fit in |
343 * |out_data| then it will be truncated. If no OCSP response was given by the | 362 * |out_data| then it will be truncated. If no OCSP response was given by the |
344 * server then it has zero length. | 363 * server then it has zero length. |
345 * | 364 * |
346 * You must set the SSL_ENABLE_OCSP_STAPLING option in order for OCSP responses | 365 * You must set the SSL_ENABLE_OCSP_STAPLING option in order for OCSP responses |
347 * to be provided by a server. | 366 * to be provided by a server. |
348 * | 367 * |
349 * You can call this function during the certificate verification callback or | 368 * You can call this function during the certificate verification callback or |
350 * any time afterwards. | 369 * any time afterwards. |
351 */ | 370 */ |
352 SSL_IMPORT SECStatus SSL_GetStapledOCSPResponse(PRFileDesc *fd, | 371 SSL_IMPORT SECStatus SSL_GetStapledOCSPResponse(PRFileDesc *fd, |
353 unsigned char *out_data, | 372 unsigned char *out_data, |
354 unsigned int *len); | 373 unsigned int *len); |
355 | 374 |
356 /* | 375 /* |
357 ** Authenticate certificate hook. Called when a certificate comes in | 376 ** Authenticate certificate hook. Called when a certificate comes in |
358 ** (because of SSL_REQUIRE_CERTIFICATE in SSL_Enable) to authenticate the | 377 ** (because of SSL_REQUIRE_CERTIFICATE in SSL_Enable) to authenticate the |
359 ** certificate. | 378 ** certificate. |
| 379 ** |
| 380 ** The authenticate certificate hook must return SECSuccess to indicate the |
| 381 ** certificate is valid, SECFailure to indicate the certificate is invalid, |
| 382 ** or SECWouldBlock if the application will authenticate the certificate |
| 383 ** asynchronously. SECWouldBlock is only supported for non-blocking sockets. |
| 384 ** |
| 385 ** If the authenticate certificate hook returns SECFailure, then the bad cert |
| 386 ** hook will be called. The bad cert handler is NEVER called if the |
| 387 ** authenticate certificate hook returns SECWouldBlock. If the application |
| 388 ** needs to handle and/or override a bad cert, it should do so before it |
| 389 ** calls SSL_AuthCertificateComplete (modifying the error it passes to |
| 390 ** SSL_AuthCertificateComplete as needed). |
| 391 ** |
| 392 ** See the documentation for SSL_AuthCertificateComplete for more information |
| 393 ** about the asynchronous behavior that occurs when the authenticate |
| 394 ** certificate hook returns SECWouldBlock. |
360 */ | 395 */ |
361 typedef SECStatus (PR_CALLBACK *SSLAuthCertificate)(void *arg, PRFileDesc *fd, | 396 typedef SECStatus (PR_CALLBACK *SSLAuthCertificate)(void *arg, PRFileDesc *fd, |
362 PRBool checkSig, | 397 PRBool checkSig, |
363 PRBool isServer); | 398 PRBool isServer); |
364 | 399 |
365 SSL_IMPORT SECStatus SSL_AuthCertificateHook(PRFileDesc *fd, | 400 SSL_IMPORT SECStatus SSL_AuthCertificateHook(PRFileDesc *fd, |
366 SSLAuthCertificate f, | 401 SSLAuthCertificate f, |
367 void *arg); | 402 void *arg); |
368 | 403 |
369 /* An implementation of the certificate authentication hook */ | 404 /* An implementation of the certificate authentication hook */ |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 * Set the client side argument for SSL to retrieve PKCS #11 pin. | 527 * Set the client side argument for SSL to retrieve PKCS #11 pin. |
493 * fd - the file descriptor for the connection in question | 528 * fd - the file descriptor for the connection in question |
494 * a - pkcs11 application specific data | 529 * a - pkcs11 application specific data |
495 */ | 530 */ |
496 SSL_IMPORT SECStatus SSL_SetPKCS11PinArg(PRFileDesc *fd, void *a); | 531 SSL_IMPORT SECStatus SSL_SetPKCS11PinArg(PRFileDesc *fd, void *a); |
497 | 532 |
498 /* | 533 /* |
499 ** This is a callback for dealing with server certs that are not authenticated | 534 ** This is a callback for dealing with server certs that are not authenticated |
500 ** by the client. The client app can decide that it actually likes the | 535 ** by the client. The client app can decide that it actually likes the |
501 ** cert by some external means and restart the connection. | 536 ** cert by some external means and restart the connection. |
| 537 ** |
| 538 ** The bad cert hook must return SECSuccess to override the result of the |
| 539 ** authenticate certificate hook, SECFailure if the certificate should still be |
| 540 ** considered invalid, or SECWouldBlock if the application will authenticate |
| 541 ** the certificate asynchronously. SECWouldBlock is only supported for |
| 542 ** non-blocking sockets. |
| 543 ** |
| 544 ** See the documentation for SSL_AuthCertificateComplete for more information |
| 545 ** about the asynchronous behavior that occurs when the bad cert hook returns |
| 546 ** SECWouldBlock. |
502 */ | 547 */ |
503 typedef SECStatus (PR_CALLBACK *SSLBadCertHandler)(void *arg, PRFileDesc *fd); | 548 typedef SECStatus (PR_CALLBACK *SSLBadCertHandler)(void *arg, PRFileDesc *fd); |
504 SSL_IMPORT SECStatus SSL_BadCertHook(PRFileDesc *fd, SSLBadCertHandler f, | 549 SSL_IMPORT SECStatus SSL_BadCertHook(PRFileDesc *fd, SSLBadCertHandler f, |
505 void *arg); | 550 void *arg); |
506 | 551 |
507 /* | 552 /* |
508 ** Set the predicted chain of certificates for the peer. This is used for the | |
509 ** TLS Cached Info extension. Note that the SSL_ENABLE_CACHED_INFO option must | |
510 ** be set for this to occur. | |
511 ** | |
512 ** This function takes a reference to each of the given certificates. | |
513 */ | |
514 SSL_IMPORT SECStatus SSL_SetPredictedPeerCertificates( | |
515 PRFileDesc *fd, CERTCertificate **certs, | |
516 unsigned int numCerts); | |
517 | |
518 /* | |
519 ** Configure SSL socket for running a secure server. Needs the | 553 ** Configure SSL socket for running a secure server. Needs the |
520 ** certificate for the server and the servers private key. The arguments | 554 ** certificate for the server and the servers private key. The arguments |
521 ** are copied. | 555 ** are copied. |
522 */ | 556 */ |
523 SSL_IMPORT SECStatus SSL_ConfigSecureServer( | 557 SSL_IMPORT SECStatus SSL_ConfigSecureServer( |
524 PRFileDesc *fd, CERTCertificate *cert, | 558 PRFileDesc *fd, CERTCertificate *cert, |
525 SECKEYPrivateKey *key, SSLKEAType kea); | 559 SECKEYPrivateKey *key, SSLKEAType kea); |
526 | 560 |
527 /* | 561 /* |
| 562 ** Allows SSL socket configuration with caller-supplied certificate chain. |
| 563 ** If certChainOpt is NULL, tries to find one. |
| 564 */ |
| 565 SSL_IMPORT SECStatus |
| 566 SSL_ConfigSecureServerWithCertChain(PRFileDesc *fd, CERTCertificate *cert, |
| 567 const CERTCertificateList *certChainOpt, |
| 568 SECKEYPrivateKey *key, SSLKEAType kea); |
| 569 |
| 570 /* |
528 ** Configure a secure server's session-id cache. Define the maximum number | 571 ** Configure a secure server's session-id cache. Define the maximum number |
529 ** of entries in the cache, the longevity of the entires, and the directory | 572 ** of entries in the cache, the longevity of the entires, and the directory |
530 ** where the cache files will be placed. These values can be zero, and | 573 ** where the cache files will be placed. These values can be zero, and |
531 ** if so, the implementation will choose defaults. | 574 ** if so, the implementation will choose defaults. |
532 ** This version of the function is for use in applications that have only one | 575 ** This version of the function is for use in applications that have only one |
533 ** process that uses the cache (even if that process has multiple threads). | 576 ** process that uses the cache (even if that process has multiple threads). |
534 */ | 577 */ |
535 SSL_IMPORT SECStatus SSL_ConfigServerSessionIDCache(int maxCacheEntries, | 578 SSL_IMPORT SECStatus SSL_ConfigServerSessionIDCache(int maxCacheEntries, |
536 PRUint32 timeout, | 579 PRUint32 timeout, |
537 PRUint32 ssl3_timeout, | 580 PRUint32 ssl3_timeout, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 */ | 647 */ |
605 SSL_IMPORT SECStatus SSL_ReHandshake(PRFileDesc *fd, PRBool flushCache); | 648 SSL_IMPORT SECStatus SSL_ReHandshake(PRFileDesc *fd, PRBool flushCache); |
606 | 649 |
607 /* | 650 /* |
608 ** Same as above, but with an I/O timeout. | 651 ** Same as above, but with an I/O timeout. |
609 */ | 652 */ |
610 SSL_IMPORT SECStatus SSL_ReHandshakeWithTimeout(PRFileDesc *fd, | 653 SSL_IMPORT SECStatus SSL_ReHandshakeWithTimeout(PRFileDesc *fd, |
611 PRBool flushCache, | 654 PRBool flushCache, |
612 PRIntervalTime timeout); | 655 PRIntervalTime timeout); |
613 | 656 |
| 657 /* Returns a SECItem containing the certificate_types field of the |
| 658 ** CertificateRequest message. Each byte of the data is a TLS |
| 659 ** ClientCertificateType value, and they are ordered from most preferred to |
| 660 ** least. This function should only be called from the |
| 661 ** SSL_GetClientAuthDataHook callback, and will return NULL if called at any |
| 662 ** other time. The returned value is valid only until the callback returns, and |
| 663 ** should not be freed. |
| 664 */ |
| 665 SSL_IMPORT const SECItem * |
| 666 SSL_GetRequestedClientCertificateTypes(PRFileDesc *fd); |
614 | 667 |
615 #ifdef SSL_DEPRECATED_FUNCTION | 668 #ifdef SSL_DEPRECATED_FUNCTION |
616 /* deprecated! | 669 /* deprecated! |
617 ** For the server, request a new handshake. For the client, begin a new | 670 ** For the server, request a new handshake. For the client, begin a new |
618 ** handshake. Flushes SSL3 session cache entry first, ensuring that a | 671 ** handshake. Flushes SSL3 session cache entry first, ensuring that a |
619 ** full handshake will be done. | 672 ** full handshake will be done. |
620 ** This call is equivalent to SSL_ReHandshake(fd, PR_TRUE) | 673 ** This call is equivalent to SSL_ReHandshake(fd, PR_TRUE) |
621 */ | 674 */ |
622 SSL_IMPORT SECStatus SSL_RedoHandshake(PRFileDesc *fd); | 675 SSL_IMPORT SECStatus SSL_RedoHandshake(PRFileDesc *fd); |
623 #endif | 676 #endif |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 ** Did the handshake with the peer negotiate the given extension? | 844 ** Did the handshake with the peer negotiate the given extension? |
792 ** Output parameter valid only if function returns SECSuccess | 845 ** Output parameter valid only if function returns SECSuccess |
793 */ | 846 */ |
794 SSL_IMPORT SECStatus SSL_HandshakeNegotiatedExtension(PRFileDesc * socket, | 847 SSL_IMPORT SECStatus SSL_HandshakeNegotiatedExtension(PRFileDesc * socket, |
795 SSLExtensionType extId, | 848 SSLExtensionType extId, |
796 PRBool *yes); | 849 PRBool *yes); |
797 | 850 |
798 SSL_IMPORT SECStatus SSL_HandshakeResumedSession(PRFileDesc *fd, | 851 SSL_IMPORT SECStatus SSL_HandshakeResumedSession(PRFileDesc *fd, |
799 PRBool *last_handshake_resumed)
; | 852 PRBool *last_handshake_resumed)
; |
800 | 853 |
801 /* Returns a SECItem containing the certificate_types field of the | 854 /* |
802 ** CertificateRequest message. Each byte of the data is a TLS | 855 * Return a boolean that indicates whether the underlying library |
803 ** ClientCertificateType value, and they are ordered from most preferred to | 856 * will perform as the caller expects. |
804 ** least. This function should only be called from the | 857 * |
805 ** SSL_GetClientAuthDataHook callback, and will return NULL if called at any | 858 * The only argument is a string, which should be the version |
806 ** other time. The returned value is valid only until the callback returns, and | 859 * identifier of the NSS library. That string will be compared |
807 ** should not be freed. | 860 * against a string that represents the actual build version of |
808 */ | 861 * the SSL library. It also invokes the version checking functions |
809 SSL_IMPORT const SECItem * | 862 * of the dependent libraries such as NSPR. |
810 SSL_GetRequestedClientCertificateTypes(PRFileDesc *fd); | 863 */ |
| 864 extern PRBool NSSSSL_VersionCheck(const char *importedVersion); |
811 | 865 |
| 866 /* |
| 867 * Returns a const string of the SSL library version. |
| 868 */ |
| 869 extern const char *NSSSSL_GetVersion(void); |
| 870 |
| 871 /* Restart an SSL connection that was paused to do asynchronous certificate |
| 872 * chain validation (when the auth certificate hook or bad cert handler |
| 873 * returned SECWouldBlock). |
| 874 * |
| 875 * This function only works for non-blocking sockets; Do not use it for |
| 876 * blocking sockets. Currently, this function works only for the client role of |
| 877 * a connection; it does not work for the server role. |
| 878 * |
| 879 * The application must call SSL_AuthCertificateComplete with 0 as the value of |
| 880 * the error parameter after it has successfully validated the peer's |
| 881 * certificate, in order to continue the SSL handshake. |
| 882 * |
| 883 * The application may call SSL_AuthCertificateComplete with a non-zero value |
| 884 * for error (e.g. SEC_ERROR_REVOKED_CERTIFICATE) when certificate validation |
| 885 * fails, before it closes the connection. If the application does so, an |
| 886 * alert corresponding to the error (e.g. certificate_revoked) will be sent to |
| 887 * the peer. See the source code of the internal function |
| 888 * ssl3_SendAlertForCertError for the current mapping of error to alert. This |
| 889 * mapping may change in future versions of libssl. |
| 890 * |
| 891 * This function will not complete the entire handshake. The application must |
| 892 * call SSL_ForceHandshake, PR_Recv, PR_Send, etc. after calling this function |
| 893 * to force the handshake to complete. |
| 894 * |
| 895 * On the first handshake of a connection, libssl will wait for the peer's |
| 896 * certificate to be authenticated before calling the handshake callback, |
| 897 * sending a client certificate, sending any application data, or returning |
| 898 * any application data to the application. On subsequent (renegotiation) |
| 899 * handshakes, libssl will block the handshake unconditionally while the |
| 900 * certificate is being validated. |
| 901 * |
| 902 * libssl may send and receive handshake messages while waiting for the |
| 903 * application to call SSL_AuthCertificateComplete, and it may call other |
| 904 * callbacks (e.g, the client auth data hook) before |
| 905 * SSL_AuthCertificateComplete has been called. |
| 906 * |
| 907 * An application that uses this asynchronous mechanism will usually have lower |
| 908 * handshake latency if it has to do public key operations on the certificate |
| 909 * chain and/or CRL/OCSP/cert fetching during the authentication, especially if |
| 910 * it does so in parallel on another thread. However, if the application can |
| 911 * authenticate the peer's certificate quickly then it may be more efficient |
| 912 * to use the synchronous mechanism (i.e. returning SECFailure/SECSuccess |
| 913 * instead of SECWouldBlock from the authenticate certificate hook). |
| 914 * |
| 915 * Be careful about converting an application from synchronous cert validation |
| 916 * to asynchronous certificate validation. A naive conversion is likely to |
| 917 * result in deadlocks; e.g. the application will wait in PR_Poll for network |
| 918 * I/O on the connection while all network I/O on the connection is blocked |
| 919 * waiting for this function to be called. |
| 920 * |
| 921 * Returns SECFailure on failure, SECSuccess on success. Never returns |
| 922 * SECWouldBlock. Note that SSL_AuthCertificateComplete will (usually) return |
| 923 * SECSuccess; do not interpret the return value of SSL_AuthCertificateComplete |
| 924 * as an indicator of whether it is OK to continue using the connection. For |
| 925 * example, SSL_AuthCertificateComplete(fd, SEC_ERROR_REVOKED_CERTIFICATE) will |
| 926 * return SECSuccess (normally), but that does not mean that the application |
| 927 * should continue using the connection. If the application passes a non-zero |
| 928 * value for second argument (error), or if SSL_AuthCertificateComplete returns |
| 929 * anything other than SECSuccess, then the application should close the |
| 930 * connection. |
| 931 */ |
| 932 SSL_IMPORT SECStatus SSL_AuthCertificateComplete(PRFileDesc *fd, |
| 933 PRErrorCode error); |
812 SEC_END_PROTOS | 934 SEC_END_PROTOS |
813 | 935 |
814 #endif /* __ssl_h_ */ | 936 #endif /* __ssl_h_ */ |
OLD | NEW |