| 1 |
// Copyright (C) 1995-1998 Eric Young ([email protected]) |
| 2 |
// Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. |
| 3 |
// Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
| 4 |
// Copyright 2005 Nokia. All rights reserved. |
| 5 |
// |
| 6 |
// ECC cipher suite support in OpenSSL originally developed by |
| 7 |
// SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. |
| 8 |
// |
| 9 |
// The Contribution, originally written by Mika Kousa and Pasi Eronen of |
| 10 |
// Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites |
| 11 |
// support (see RFC 4279) to OpenSSL. |
| 12 |
// |
| 13 |
// SPDX-License-Identifier: Apache-2.0 |
| 14 |
|
| 15 |
#ifndef OPENSSL_HEADER_SSL_H |
| 16 |
#define OPENSSL_HEADER_SSL_H |
| 17 |
|
| 18 |
#include <openssl/base.h> |
| 19 |
|
| 20 |
#include <openssl/bio.h> |
| 21 |
#include <openssl/buf.h> |
| 22 |
#include <openssl/pem.h> |
| 23 |
#include <openssl/span.h> |
| 24 |
#include <openssl/ssl3.h> |
| 25 |
#include <openssl/thread.h> |
| 26 |
#include <openssl/tls1.h> |
| 27 |
#include <openssl/x509.h> |
| 28 |
|
| 29 |
#if !defined(OPENSSL_WINDOWS) |
| 30 |
#include <sys/time.h> |
| 31 |
#endif |
| 32 |
|
| 33 |
// Forward-declare struct timeval. On Windows, it is defined in winsock2.h and |
| 34 |
// Windows headers define too many macros to be included in public headers. |
| 35 |
// However, only a forward declaration is needed. |
| 36 |
struct timeval; |
| 37 |
|
| 38 |
#if defined(__cplusplus) |
| 39 |
extern "C" { |
| 40 |
#endif |
| 41 |
|
| 42 |
|
| 43 |
// SSL implementation. |
| 44 |
|
| 45 |
|
| 46 |
// SSL contexts. |
| 47 |
// |
| 48 |
// |SSL_CTX| objects manage shared state and configuration between multiple TLS |
| 49 |
// or DTLS connections. Whether the connections are TLS or DTLS is selected by |
| 50 |
// an |SSL_METHOD| on creation. |
| 51 |
// |
| 52 |
// |SSL_CTX| are reference-counted and may be shared by connections across |
| 53 |
// multiple threads. Once shared, functions which change the |SSL_CTX|'s |
| 54 |
// configuration may not be used. |
| 55 |
|
| 56 |
// TLS_method is the |SSL_METHOD| used for TLS connections. |
| 57 |
OPENSSL_EXPORT const SSL_METHOD *TLS_method(void); |
| 58 |
|
| 59 |
// DTLS_method is the |SSL_METHOD| used for DTLS connections. |
| 60 |
OPENSSL_EXPORT const SSL_METHOD *DTLS_method(void); |
| 61 |
|
| 62 |
// TLS_with_buffers_method is like |TLS_method|, but avoids all use of |
| 63 |
// crypto/x509. All client connections created with |TLS_with_buffers_method| |
| 64 |
// will fail unless a certificate verifier is installed with |
| 65 |
// |SSL_set_custom_verify| or |SSL_CTX_set_custom_verify|. |
| 66 |
OPENSSL_EXPORT const SSL_METHOD *TLS_with_buffers_method(void); |
| 67 |
|
| 68 |
// DTLS_with_buffers_method is like |DTLS_method|, but avoids all use of |
| 69 |
// crypto/x509. |
| 70 |
OPENSSL_EXPORT const SSL_METHOD *DTLS_with_buffers_method(void); |
| 71 |
|
| 72 |
// SSL_CTX_new returns a newly-allocated |SSL_CTX| with default settings or NULL |
| 73 |
// on error. |
| 74 |
OPENSSL_EXPORT SSL_CTX *SSL_CTX_new(const SSL_METHOD *method); |
| 75 |
|
| 76 |
// SSL_CTX_up_ref increments the reference count of |ctx|. It returns one. |
| 77 |
OPENSSL_EXPORT int SSL_CTX_up_ref(SSL_CTX *ctx); |
| 78 |
|
| 79 |
// SSL_CTX_free releases memory associated with |ctx|. |
| 80 |
OPENSSL_EXPORT void SSL_CTX_free(SSL_CTX *ctx); |
| 81 |
|
| 82 |
|
| 83 |
// SSL connections. |
| 84 |
// |
| 85 |
// An |SSL| object represents a single TLS or DTLS connection. Although the |
| 86 |
// shared |SSL_CTX| is thread-safe, an |SSL| is not thread-safe and may only be |
| 87 |
// used on one thread at a time. |
| 88 |
|
| 89 |
// SSL_new returns a newly-allocated |SSL| using |ctx| or NULL on error. The new |
| 90 |
// connection inherits settings from |ctx| at the time of creation. Settings may |
| 91 |
// also be individually configured on the connection. |
| 92 |
// |
| 93 |
// On creation, an |SSL| is not configured to be either a client or server. Call |
| 94 |
// |SSL_set_connect_state| or |SSL_set_accept_state| to set this. |
| 95 |
OPENSSL_EXPORT SSL *SSL_new(SSL_CTX *ctx); |
| 96 |
|
| 97 |
// SSL_free releases memory associated with |ssl|. |
| 98 |
OPENSSL_EXPORT void SSL_free(SSL *ssl); |
| 99 |
|
| 100 |
// SSL_get_SSL_CTX returns the |SSL_CTX| associated with |ssl|. If |
| 101 |
// |SSL_set_SSL_CTX| is called, it returns the new |SSL_CTX|, not the initial |
| 102 |
// one. |
| 103 |
OPENSSL_EXPORT SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); |
| 104 |
|
| 105 |
// SSL_set_connect_state configures |ssl| to be a client. |
| 106 |
OPENSSL_EXPORT void SSL_set_connect_state(SSL *ssl); |
| 107 |
|
| 108 |
// SSL_set_accept_state configures |ssl| to be a server. |
| 109 |
OPENSSL_EXPORT void SSL_set_accept_state(SSL *ssl); |
| 110 |
|
| 111 |
// SSL_is_server returns one if |ssl| is configured as a server and zero |
| 112 |
// otherwise. |
| 113 |
OPENSSL_EXPORT int SSL_is_server(const SSL *ssl); |
| 114 |
|
| 115 |
// SSL_is_dtls returns one if |ssl| is a DTLS connection and zero otherwise. |
| 116 |
OPENSSL_EXPORT int SSL_is_dtls(const SSL *ssl); |
| 117 |
|
| 118 |
// SSL_set_bio configures |ssl| to read from |rbio| and write to |wbio|. |ssl| |
| 119 |
// takes ownership of the two |BIO|s. If |rbio| and |wbio| are the same, |ssl| |
| 120 |
// only takes ownership of one reference. |
| 121 |
// |
| 122 |
// In DTLS, |rbio| must be non-blocking to properly handle timeouts and |
| 123 |
// retransmits. |
| 124 |
// |
| 125 |
// If |rbio| is the same as the currently configured |BIO| for reading, that |
| 126 |
// side is left untouched and is not freed. |
| 127 |
// |
| 128 |
// If |wbio| is the same as the currently configured |BIO| for writing AND |ssl| |
| 129 |
// is not currently configured to read from and write to the same |BIO|, that |
| 130 |
// side is left untouched and is not freed. This asymmetry is present for |
| 131 |
// historical reasons. |
| 132 |
// |
| 133 |
// Due to the very complex historical behavior of this function, calling this |
| 134 |
// function if |ssl| already has |BIO|s configured is deprecated. Prefer |
| 135 |
// |SSL_set0_rbio| and |SSL_set0_wbio| instead. |
| 136 |
OPENSSL_EXPORT void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio); |
| 137 |
|
| 138 |
// SSL_set0_rbio configures |ssl| to read from |rbio|. It takes ownership of |
| 139 |
// |rbio|. |
| 140 |
// |
| 141 |
// Note that, although this function and |SSL_set0_wbio| may be called on the |
| 142 |
// same |BIO|, each call takes a reference. Use |BIO_up_ref| to balance this. |
| 143 |
OPENSSL_EXPORT void SSL_set0_rbio(SSL *ssl, BIO *rbio); |
| 144 |
|
| 145 |
// SSL_set0_wbio configures |ssl| to write to |wbio|. It takes ownership of |
| 146 |
// |wbio|. |
| 147 |
// |
| 148 |
// Note that, although this function and |SSL_set0_rbio| may be called on the |
| 149 |
// same |BIO|, each call takes a reference. Use |BIO_up_ref| to balance this. |
| 150 |
OPENSSL_EXPORT void SSL_set0_wbio(SSL *ssl, BIO *wbio); |
| 151 |
|
| 152 |
// SSL_get_rbio returns the |BIO| that |ssl| reads from. |
| 153 |
OPENSSL_EXPORT BIO *SSL_get_rbio(const SSL *ssl); |
| 154 |
|
| 155 |
// SSL_get_wbio returns the |BIO| that |ssl| writes to. |
| 156 |
OPENSSL_EXPORT BIO *SSL_get_wbio(const SSL *ssl); |
| 157 |
|
| 158 |
// SSL_get_fd calls |SSL_get_rfd|. |
| 159 |
OPENSSL_EXPORT int SSL_get_fd(const SSL *ssl); |
| 160 |
|
| 161 |
// SSL_get_rfd returns the file descriptor that |ssl| is configured to read |
| 162 |
// from. If |ssl|'s read |BIO| is not configured or doesn't wrap a file |
| 163 |
// descriptor then it returns -1. |
| 164 |
// |
| 165 |
// Note: On Windows, this may return either a file descriptor or a socket (cast |
| 166 |
// to int), depending on whether |ssl| was configured with a file descriptor or |
| 167 |
// socket |BIO|. |
| 168 |
OPENSSL_EXPORT int SSL_get_rfd(const SSL *ssl); |
| 169 |
|
| 170 |
// SSL_get_wfd returns the file descriptor that |ssl| is configured to write |
| 171 |
// to. If |ssl|'s write |BIO| is not configured or doesn't wrap a file |
| 172 |
// descriptor then it returns -1. |
| 173 |
// |
| 174 |
// Note: On Windows, this may return either a file descriptor or a socket (cast |
| 175 |
// to int), depending on whether |ssl| was configured with a file descriptor or |
| 176 |
// socket |BIO|. |
| 177 |
OPENSSL_EXPORT int SSL_get_wfd(const SSL *ssl); |
| 178 |
|
| 179 |
#if !defined(OPENSSL_NO_SOCK) |
| 180 |
// SSL_set_fd configures |ssl| to read from and write to |fd|. It returns one |
| 181 |
// on success and zero on allocation error. The caller retains ownership of |
| 182 |
// |fd|. |
| 183 |
// |
| 184 |
// On Windows, |fd| is cast to a |SOCKET| and used with Winsock APIs. |
| 185 |
OPENSSL_EXPORT int SSL_set_fd(SSL *ssl, int fd); |
| 186 |
|
| 187 |
// SSL_set_rfd configures |ssl| to read from |fd|. It returns one on success and |
| 188 |
// zero on allocation error. The caller retains ownership of |fd|. |
| 189 |
// |
| 190 |
// On Windows, |fd| is cast to a |SOCKET| and used with Winsock APIs. |
| 191 |
OPENSSL_EXPORT int SSL_set_rfd(SSL *ssl, int fd); |
| 192 |
|
| 193 |
// SSL_set_wfd configures |ssl| to write to |fd|. It returns one on success and |
| 194 |
// zero on allocation error. The caller retains ownership of |fd|. |
| 195 |
// |
| 196 |
// On Windows, |fd| is cast to a |SOCKET| and used with Winsock APIs. |
| 197 |
OPENSSL_EXPORT int SSL_set_wfd(SSL *ssl, int fd); |
| 198 |
#endif // !OPENSSL_NO_SOCK |
| 199 |
|
| 200 |
// SSL_do_handshake continues the current handshake. If there is none or the |
| 201 |
// handshake has completed or False Started, it returns one. Otherwise, it |
| 202 |
// returns <= 0. The caller should pass the value into |SSL_get_error| to |
| 203 |
// determine how to proceed. |
| 204 |
// |
| 205 |
// In DTLS, the caller must drive retransmissions. Whenever |SSL_get_error| |
| 206 |
// signals |SSL_ERROR_WANT_READ|, use |DTLSv1_get_timeout| to determine the |
| 207 |
// current timeout. If it expires before the next retry, call |
| 208 |
// |DTLSv1_handle_timeout|. Note that DTLS handshake retransmissions use fresh |
| 209 |
// sequence numbers, so it is not sufficient to replay packets at the transport. |
| 210 |
// |
| 211 |
// TODO(davidben): Ensure 0 is only returned on transport EOF. |
| 212 |
// https://crbug.com/466303. |
| 213 |
OPENSSL_EXPORT int SSL_do_handshake(SSL *ssl); |
| 214 |
|
| 215 |
// SSL_connect configures |ssl| as a client, if unconfigured, and calls |
| 216 |
// |SSL_do_handshake|. |
| 217 |
OPENSSL_EXPORT int SSL_connect(SSL *ssl); |
| 218 |
|
| 219 |
// SSL_accept configures |ssl| as a server, if unconfigured, and calls |
| 220 |
// |SSL_do_handshake|. |
| 221 |
OPENSSL_EXPORT int SSL_accept(SSL *ssl); |
| 222 |
|
| 223 |
// SSL_read reads up to |num| bytes from |ssl| into |buf|. It implicitly runs |
| 224 |
// any pending handshakes, including renegotiations when enabled. On success, it |
| 225 |
// returns the number of bytes read. Otherwise, it returns <= 0. The caller |
| 226 |
// should pass the value into |SSL_get_error| to determine how to proceed. |
| 227 |
// |
| 228 |
// TODO(davidben): Ensure 0 is only returned on transport EOF. |
| 229 |
// https://crbug.com/466303. |
| 230 |
OPENSSL_EXPORT int SSL_read(SSL *ssl, void *buf, int num); |
| 231 |
|
| 232 |
// SSL_read_ex reads up to |num| bytes from |ssl| into |buf|. It is similar to |
| 233 |
// |SSL_read|, but instead of returning the number of bytes read, it returns |
| 234 |
// 1 on success or 0 for failure. The number of bytes actually read is stored in |
| 235 |
// |read_bytes|. |
| 236 |
// |
| 237 |
// This is only maintained for OpenSSL compatibility. Use |SSL_read| instead. |
| 238 |
OPENSSL_EXPORT int SSL_read_ex(SSL *ssl, void *buf, size_t num, |
| 239 |
size_t *read_bytes); |
| 240 |
|
| 241 |
// SSL_peek behaves like |SSL_read| but does not consume any bytes returned. |
| 242 |
OPENSSL_EXPORT int SSL_peek(SSL *ssl, void *buf, int num); |
| 243 |
|
| 244 |
// SSL_peek_ex reads up to |num| bytes from |ssl| into |buf|. It is similar to |
| 245 |
// |SSL_peek|, but instead of returning the number of bytes read, it returns |
| 246 |
// 1 on success or 0 for failure. The number of bytes actually read is stored in |
| 247 |
// |read_bytes|. |
| 248 |
// |
| 249 |
// This is only maintained for OpenSSL compatibility. Use |SSL_peek| instead. |
| 250 |
OPENSSL_EXPORT int SSL_peek_ex(SSL *ssl, void *buf, size_t num, |
| 251 |
size_t *read_bytes); |
| 252 |
|
| 253 |
// SSL_pending returns the number of buffered, decrypted bytes available for |
| 254 |
// read in |ssl|. It does not read from the transport. |
| 255 |
// |
| 256 |
// In DTLS, it is possible for this function to return zero while there is |
| 257 |
// buffered, undecrypted data from the transport in |ssl|. For example, |
| 258 |
// |SSL_read| may read a datagram with two records, decrypt the first, and leave |
| 259 |
// the second buffered for a subsequent call to |SSL_read|. Callers that wish to |
| 260 |
// detect this case can use |SSL_has_pending|. |
| 261 |
OPENSSL_EXPORT int SSL_pending(const SSL *ssl); |
| 262 |
|
| 263 |
// SSL_has_pending returns one if |ssl| has buffered, decrypted bytes available |
| 264 |
// for read, or if |ssl| has buffered data from the transport that has not yet |
| 265 |
// been decrypted. If |ssl| has neither, this function returns zero. |
| 266 |
// |
| 267 |
// If read-ahead has been enabled with |SSL_CTX_set_read_ahead| or |
| 268 |
// |SSL_set_read_ahead|, the behavior of |SSL_pending| will change, it may return |
| 269 |
// 1 and a call to |SSL_read| to return no data. This can happen when a partial |
| 270 |
// record has been read but can not be decrypted without more data from the read |
| 271 |
// BIO. |
| 272 |
// |
| 273 |
// In DTLS, it is possible for this function to return one while |SSL_pending| |
| 274 |
// returns zero. For example, |SSL_read| may read a datagram with two records, |
| 275 |
// decrypt the first, and leave the second buffered for a subsequent call to |
| 276 |
// |SSL_read|. |
| 277 |
// |
| 278 |
// As a result, if this function returns one, the next call to |SSL_read| may |
| 279 |
// still fail, read from the transport, or both. The buffered, undecrypted data |
| 280 |
// may be invalid or incomplete. |
| 281 |
OPENSSL_EXPORT int SSL_has_pending(const SSL *ssl); |
| 282 |
|
| 283 |
// SSL_write writes up to |num| bytes from |buf| into |ssl|. It implicitly runs |
| 284 |
// any pending handshakes, including renegotiations when enabled. On success, it |
| 285 |
// returns the number of bytes written. Otherwise, it returns <= 0. The caller |
| 286 |
// should pass the value into |SSL_get_error| to determine how to proceed. |
| 287 |
// |
| 288 |
// In TLS, a non-blocking |SSL_write| differs from non-blocking |write| in that |
| 289 |
// a failed |SSL_write| still commits to the data passed in. When retrying, the |
| 290 |
// caller must supply the original write buffer (or a larger one containing the |
| 291 |
// original as a prefix). By default, retries will fail if they also do not |
| 292 |
// reuse the same |buf| pointer. This may be relaxed with |
| 293 |
// |SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER|, but the buffer contents still must be |
| 294 |
// unchanged. |
| 295 |
// |
| 296 |
// By default, in TLS, |SSL_write| will not return success until all |num| bytes |
| 297 |
// are written. This may be relaxed with |SSL_MODE_ENABLE_PARTIAL_WRITE|. It |
| 298 |
// allows |SSL_write| to complete with a partial result when only part of the |
| 299 |
// input was written in a single record. |
| 300 |
// |
| 301 |
// In DTLS, neither |SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER| and |
| 302 |
// |SSL_MODE_ENABLE_PARTIAL_WRITE| do anything. The caller may retry with a |
| 303 |
// different buffer freely. A single call to |SSL_write| only ever writes a |
| 304 |
// single record in a single packet, so |num| must be at most |
| 305 |
// |SSL3_RT_MAX_PLAIN_LENGTH|. |
| 306 |
// |
| 307 |
// TODO(davidben): Ensure 0 is only returned on transport EOF. |
| 308 |
// https://crbug.com/466303. |
| 309 |
OPENSSL_EXPORT int SSL_write(SSL *ssl, const void *buf, int num); |
| 310 |
|
| 311 |
// SSL_write_ex writes up to |num| bytes from |buf| into |ssl|. It is similar to |
| 312 |
// |SSL_write|, but instead of returning the number of bytes written, it returns |
| 313 |
// 1 on success or 0 for failure. The number bytes actually written is stored in |
| 314 |
// |written|. |
| 315 |
// |
| 316 |
// This is only maintained for OpenSSL compatibility. Use |SSL_write| instead. |
| 317 |
OPENSSL_EXPORT int SSL_write_ex(SSL *s, const void *buf, size_t num, |
| 318 |
size_t *written); |
| 319 |
|
| 320 |
// SSL_KEY_UPDATE_REQUESTED indicates that the peer should reply to a KeyUpdate |
| 321 |
// message with its own, thus updating traffic secrets for both directions on |
| 322 |
// the connection. |
| 323 |
#define SSL_KEY_UPDATE_REQUESTED 1 |
| 324 |
|
| 325 |
// SSL_KEY_UPDATE_NOT_REQUESTED indicates that the peer should not reply with |
| 326 |
// its own KeyUpdate message. |
| 327 |
#define SSL_KEY_UPDATE_NOT_REQUESTED 0 |
| 328 |
|
| 329 |
// SSL_KEY_UPDATE_NONE should not be set by the user and is only used to |
| 330 |
// indicate that there isn't a pending key operation. OpenSSL indicates that -1 |
| 331 |
// is used, so that it will be an invalid value for the on-the-wire protocol |
| 332 |
// when calling |SSL_key_update|. |
| 333 |
#define SSL_KEY_UPDATE_NONE -1 |
| 334 |
|
| 335 |
// SSL_key_update queues a TLS 1.3 KeyUpdate message to be sent on |ssl| |
| 336 |
// if one is not already queued. The |request_type| argument must be either |
| 337 |
// |SSL_KEY_UPDATE_REQUESTED| or |SSL_KEY_UPDATE_NOT_REQUESTED|. This function |
| 338 |
// requires that |ssl| have completed a TLS >= 1.3 handshake. It returns one on |
| 339 |
// success or zero on error. |
| 340 |
// |
| 341 |
// If |request_type| is set to |SSL_KEY_UPDATE_NOT_REQUESTED|, then the sending |
| 342 |
// keys for this connection will be updated and the peer will be informed of the |
| 343 |
// change. |
| 344 |
// If |request_type| is set to |SSL_KEY_UPDATE_REQUESTED|, then the sending keys |
| 345 |
// for this connection will be updated and the peer will be informed of the |
| 346 |
// change along with a request for the peer to additionally update its sending |
| 347 |
// keys. RFC: https://datatracker.ietf.org/doc/html/rfc8446#section-4.6.3 |
| 348 |
// |
| 349 |
// Note that this function does not _send_ the message itself. The next call to |
| 350 |
// |SSL_write| will cause the message to be sent. |SSL_write| may be called with |
| 351 |
// a zero length to flush a KeyUpdate message when no application data is |
| 352 |
// pending. |
| 353 |
OPENSSL_EXPORT int SSL_key_update(SSL *ssl, int request_type); |
| 354 |
|
| 355 |
// SSL_get_key_update_type returns the state of the pending key operation in |
| 356 |
// |ssl|. The type of pending key operation will be either |
| 357 |
// |SSL_KEY_UPDATE_REQUESTED| or |SSL_KEY_UPDATE_NOT_REQUESTED| if there is one, |
| 358 |
// and |SSL_KEY_UPDATE_NONE| otherwise. This can be used to indicate whether |
| 359 |
// a key update operation has been scheduled but not yet performed. |
| 360 |
OPENSSL_EXPORT int SSL_get_key_update_type(const SSL *ssl); |
| 361 |
|
| 362 |
// SSL_shutdown shuts down |ssl|. It runs in two stages. First, it sends |
| 363 |
// close_notify and returns zero or one on success or -1 on failure. Zero |
| 364 |
// indicates that close_notify was sent, but not received, and one additionally |
| 365 |
// indicates that the peer's close_notify had already been received. |
| 366 |
// |
| 367 |
// To then wait for the peer's close_notify, run |SSL_shutdown| to completion a |
| 368 |
// second time. This returns 1 on success and -1 on failure. Application data |
| 369 |
// is considered a fatal error at this point. To process or discard it, read |
| 370 |
// until close_notify with |SSL_read| instead. |
| 371 |
// |
| 372 |
// In both cases, on failure, pass the return value into |SSL_get_error| to |
| 373 |
// determine how to proceed. |
| 374 |
// |
| 375 |
// Most callers should stop at the first stage. Reading for close_notify is |
| 376 |
// primarily used for uncommon protocols where the underlying transport is |
| 377 |
// reused after TLS completes. Additionally, DTLS uses an unordered transport |
| 378 |
// and is unordered, so the second stage is a no-op in DTLS. |
| 379 |
OPENSSL_EXPORT int SSL_shutdown(SSL *ssl); |
| 380 |
|
| 381 |
// SSL_CTX_set_quiet_shutdown sets quiet shutdown on |ctx| to |mode|. If |
| 382 |
// enabled, |SSL_shutdown| will not send a close_notify alert or wait for one |
| 383 |
// from the peer. It will instead synchronously return one. |
| 384 |
OPENSSL_EXPORT void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode); |
| 385 |
|
| 386 |
// SSL_CTX_get_quiet_shutdown returns whether quiet shutdown is enabled for |
| 387 |
// |ctx|. |
| 388 |
OPENSSL_EXPORT int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); |
| 389 |
|
| 390 |
// SSL_set_quiet_shutdown sets quiet shutdown on |ssl| to |mode|. If enabled, |
| 391 |
// |SSL_shutdown| will not send a close_notify alert or wait for one from the |
| 392 |
// peer. It will instead synchronously return one. |
| 393 |
OPENSSL_EXPORT void SSL_set_quiet_shutdown(SSL *ssl, int mode); |
| 394 |
|
| 395 |
// SSL_get_quiet_shutdown returns whether quiet shutdown is enabled for |
| 396 |
// |ssl|. |
| 397 |
OPENSSL_EXPORT int SSL_get_quiet_shutdown(const SSL *ssl); |
| 398 |
|
| 399 |
// SSL_get_error returns a |SSL_ERROR_*| value for the most recent operation on |
| 400 |
// |ssl|. It should be called after an operation failed to determine whether the |
| 401 |
// error was fatal and, if not, when to retry. |
| 402 |
OPENSSL_EXPORT int SSL_get_error(const SSL *ssl, int ret_code); |
| 403 |
|
| 404 |
// SSL_ERROR_NONE indicates the operation succeeded. |
| 405 |
#define SSL_ERROR_NONE 0 |
| 406 |
|
| 407 |
// SSL_ERROR_SSL indicates the operation failed within the library. The caller |
| 408 |
// may inspect the error queue for more information. |
| 409 |
#define SSL_ERROR_SSL 1 |
| 410 |
|
| 411 |
// SSL_ERROR_WANT_READ indicates the operation failed attempting to read from |
| 412 |
// the transport. The caller may retry the operation when the transport is ready |
| 413 |
// for reading. |
| 414 |
// |
| 415 |
// If signaled by a DTLS handshake, the caller must also call |
| 416 |
// |DTLSv1_get_timeout| and |DTLSv1_handle_timeout| as appropriate. See |
| 417 |
// |SSL_do_handshake|. |
| 418 |
#define SSL_ERROR_WANT_READ 2 |
| 419 |
|
| 420 |
// SSL_ERROR_WANT_WRITE indicates the operation failed attempting to write to |
| 421 |
// the transport. The caller may retry the operation when the transport is ready |
| 422 |
// for writing. |
| 423 |
#define SSL_ERROR_WANT_WRITE 3 |
| 424 |
|
| 425 |
// SSL_ERROR_WANT_X509_LOOKUP indicates the operation failed in calling the |
| 426 |
// |cert_cb| or |client_cert_cb|. The caller may retry the operation when the |
| 427 |
// callback is ready to return a certificate or one has been configured |
| 428 |
// externally. |
| 429 |
// |
| 430 |
// See also |SSL_CTX_set_cert_cb| and |SSL_CTX_set_client_cert_cb|. |
| 431 |
#define SSL_ERROR_WANT_X509_LOOKUP 4 |
| 432 |
|
| 433 |
// SSL_ERROR_SYSCALL indicates the operation failed externally to the library. |
| 434 |
// The caller should consult the system-specific error mechanism. This is |
| 435 |
// typically |errno| but may be something custom if using a custom |BIO|. It |
| 436 |
// may also be signaled if the transport returned EOF, in which case the |
| 437 |
// operation's return value will be zero. |
| 438 |
#define SSL_ERROR_SYSCALL 5 |
| 439 |
|
| 440 |
// SSL_ERROR_ZERO_RETURN indicates the operation failed because the connection |
| 441 |
// was cleanly shut down with a close_notify alert. |
| 442 |
#define SSL_ERROR_ZERO_RETURN 6 |
| 443 |
|
| 444 |
// SSL_ERROR_WANT_CONNECT indicates the operation failed attempting to connect |
| 445 |
// the transport (the |BIO| signaled |BIO_RR_CONNECT|). The caller may retry the |
| 446 |
// operation when the transport is ready. |
| 447 |
#define SSL_ERROR_WANT_CONNECT 7 |
| 448 |
|
| 449 |
// SSL_ERROR_WANT_ACCEPT indicates the operation failed attempting to accept a |
| 450 |
// connection from the transport (the |BIO| signaled |BIO_RR_ACCEPT|). The |
| 451 |
// caller may retry the operation when the transport is ready. |
| 452 |
// |
| 453 |
// TODO(davidben): Remove this. It's used by accept BIOs which are bizarre. |
| 454 |
#define SSL_ERROR_WANT_ACCEPT 8 |
| 455 |
|
| 456 |
// SSL_ERROR_WANT_CHANNEL_ID_LOOKUP is never used. |
| 457 |
// |
| 458 |
// TODO(davidben): Remove this. Some callers reference it when stringifying |
| 459 |
// errors. They should use |SSL_error_description| instead. |
| 460 |
#define SSL_ERROR_WANT_CHANNEL_ID_LOOKUP 9 |
| 461 |
|
| 462 |
// SSL_ERROR_PENDING_SESSION indicates the operation failed because the session |
| 463 |
// lookup callback indicated the session was unavailable. The caller may retry |
| 464 |
// the operation when lookup has completed. |
| 465 |
// |
| 466 |
// See also |SSL_CTX_sess_set_get_cb| and |SSL_magic_pending_session_ptr|. |
| 467 |
#define SSL_ERROR_PENDING_SESSION 11 |
| 468 |
|
| 469 |
// SSL_ERROR_PENDING_CERTIFICATE indicates the operation failed because the |
| 470 |
// early callback indicated certificate lookup was incomplete. The caller may |
| 471 |
// retry the operation when lookup has completed. |
| 472 |
// |
| 473 |
// See also |SSL_CTX_set_select_certificate_cb|. |
| 474 |
#define SSL_ERROR_PENDING_CERTIFICATE 12 |
| 475 |
|
| 476 |
// SSL_ERROR_WANT_PRIVATE_KEY_OPERATION indicates the operation failed because |
| 477 |
// a private key operation was unfinished. The caller may retry the operation |
| 478 |
// when the private key operation is complete. |
| 479 |
// |
| 480 |
// See also |SSL_set_private_key_method| and |
| 481 |
// |SSL_CTX_set_private_key_method|. |
| 482 |
#define SSL_ERROR_WANT_PRIVATE_KEY_OPERATION 13 |
| 483 |
|
| 484 |
// SSL_ERROR_PENDING_TICKET indicates that a ticket decryption is pending. The |
| 485 |
// caller may retry the operation when the decryption is ready. |
| 486 |
// |
| 487 |
// See also |SSL_CTX_set_ticket_aead_method|. |
| 488 |
#define SSL_ERROR_PENDING_TICKET 14 |
| 489 |
|
| 490 |
// SSL_ERROR_EARLY_DATA_REJECTED indicates that early data was rejected. The |
| 491 |
// caller should treat this as a connection failure and retry any operations |
| 492 |
// associated with the rejected early data. |SSL_reset_early_data_reject| may be |
| 493 |
// used to reuse the underlying connection for the retry. |
| 494 |
#define SSL_ERROR_EARLY_DATA_REJECTED 15 |
| 495 |
|
| 496 |
// SSL_ERROR_WANT_CERTIFICATE_VERIFY indicates the operation failed because |
| 497 |
// certificate verification was incomplete. The caller may retry the operation |
| 498 |
// when certificate verification is complete. |
| 499 |
// |
| 500 |
// See also |SSL_CTX_set_custom_verify|. |
| 501 |
#define SSL_ERROR_WANT_CERTIFICATE_VERIFY 16 |
| 502 |
|
| 503 |
#define SSL_ERROR_HANDOFF 17 |
| 504 |
#define SSL_ERROR_HANDBACK 18 |
| 505 |
|
| 506 |
// SSL_ERROR_WANT_RENEGOTIATE indicates the operation is pending a response to |
| 507 |
// a renegotiation request from the server. The caller may call |
| 508 |
// |SSL_renegotiate| to schedule a renegotiation and retry the operation. |
| 509 |
// |
| 510 |
// See also |ssl_renegotiate_explicit|. |
| 511 |
#define SSL_ERROR_WANT_RENEGOTIATE 19 |
| 512 |
|
| 513 |
// SSL_ERROR_HANDSHAKE_HINTS_READY indicates the handshake has progressed enough |
| 514 |
// for |SSL_serialize_handshake_hints| to be called. See also |
| 515 |
// |SSL_request_handshake_hints|. |
| 516 |
#define SSL_ERROR_HANDSHAKE_HINTS_READY 20 |
| 517 |
|
| 518 |
// SSL_error_description returns a string representation of |err|, where |err| |
| 519 |
// is one of the |SSL_ERROR_*| constants returned by |SSL_get_error|, or NULL |
| 520 |
// if the value is unrecognized. |
| 521 |
OPENSSL_EXPORT const char *SSL_error_description(int err); |
| 522 |
|
| 523 |
// SSL_set_mtu sets the |ssl|'s MTU in DTLS to |mtu|. It returns one on success |
| 524 |
// and zero on failure. |
| 525 |
OPENSSL_EXPORT int SSL_set_mtu(SSL *ssl, unsigned mtu); |
| 526 |
|
| 527 |
// DTLSv1_set_initial_timeout_duration sets the initial duration for a DTLS |
| 528 |
// handshake timeout. |
| 529 |
// |
| 530 |
// This duration overrides the default of 1 second, which is the strong |
| 531 |
// recommendation of RFC 6347 (see section 4.2.4.1). However, there may exist |
| 532 |
// situations where a shorter timeout would be beneficial, such as for |
| 533 |
// time-sensitive applications. |
| 534 |
OPENSSL_EXPORT void DTLSv1_set_initial_timeout_duration(SSL *ssl, |
| 535 |
unsigned duration_ms); |
| 536 |
|
| 537 |
// DTLSv1_get_timeout queries the next DTLS handshake timeout. If there is a |
| 538 |
// timeout in progress, it sets |*out| to the time remaining and returns one. |
| 539 |
// Otherwise, it returns zero. |
| 540 |
// |
| 541 |
// When the timeout expires, call |DTLSv1_handle_timeout| to handle the |
| 542 |
// retransmit behavior. |
| 543 |
// |
| 544 |
// NOTE: This function must be queried again whenever the handshake state |
| 545 |
// machine changes, including when |DTLSv1_handle_timeout| is called. |
| 546 |
OPENSSL_EXPORT int DTLSv1_get_timeout(const SSL *ssl, struct timeval *out); |
| 547 |
|
| 548 |
// DTLSv1_handle_timeout is called when a DTLS handshake timeout expires. If no |
| 549 |
// timeout had expired, it returns 0. Otherwise, it retransmits the previous |
| 550 |
// flight of handshake messages and returns 1. If too many timeouts had expired |
| 551 |
// without progress or an error occurs, it returns -1. |
| 552 |
// |
| 553 |
// The caller's external timer should be compatible with the one |ssl| queries |
| 554 |
// within some fudge factor. Otherwise, the call will be a no-op, but |
| 555 |
// |DTLSv1_get_timeout| will return an updated timeout. |
| 556 |
// |
| 557 |
// If the function returns -1, checking if |SSL_get_error| returns |
| 558 |
// |SSL_ERROR_WANT_WRITE| may be used to determine if the retransmit failed due |
| 559 |
// to a non-fatal error at the write |BIO|. However, the operation may not be |
| 560 |
// retried until the next timeout fires. |
| 561 |
// |
| 562 |
// WARNING: This function breaks the usual return value convention. |
| 563 |
// |
| 564 |
// TODO(davidben): This |SSL_ERROR_WANT_WRITE| behavior is kind of bizarre. |
| 565 |
OPENSSL_EXPORT int DTLSv1_handle_timeout(SSL *ssl); |
| 566 |
|
| 567 |
|
| 568 |
// Protocol versions. |
| 569 |
|
| 570 |
#define DTLS1_VERSION_MAJOR 0xfe |
| 571 |
#define SSL3_VERSION_MAJOR 0x03 |
| 572 |
|
| 573 |
#define SSL3_VERSION 0x0300 |
| 574 |
#define TLS1_VERSION 0x0301 |
| 575 |
#define TLS1_1_VERSION 0x0302 |
| 576 |
#define TLS1_2_VERSION 0x0303 |
| 577 |
#define TLS1_3_VERSION 0x0304 |
| 578 |
|
| 579 |
#define DTLS1_VERSION 0xfeff |
| 580 |
#define DTLS1_2_VERSION 0xfefd |
| 581 |
|
| 582 |
// SSL_CTX_set_min_proto_version sets the minimum protocol version for |ctx| to |
| 583 |
// |version|. If |version| is zero, the default minimum version is used. It |
| 584 |
// returns one on success and zero if |version| is invalid. |
| 585 |
OPENSSL_EXPORT int SSL_CTX_set_min_proto_version(SSL_CTX *ctx, |
| 586 |
uint16_t version); |
| 587 |
|
| 588 |
// SSL_CTX_set_max_proto_version sets the maximum protocol version for |ctx| to |
| 589 |
// |version|. If |version| is zero, the default maximum version is used. It |
| 590 |
// returns one on success and zero if |version| is invalid. |
| 591 |
OPENSSL_EXPORT int SSL_CTX_set_max_proto_version(SSL_CTX *ctx, |
| 592 |
uint16_t version); |
| 593 |
|
| 594 |
// SSL_CTX_get_min_proto_version returns the minimum protocol version for |ctx|. |
| 595 |
// If |ctx| is configured to use the default minimum version, 0 is returned. |
| 596 |
OPENSSL_EXPORT uint16_t SSL_CTX_get_min_proto_version(const SSL_CTX *ctx); |
| 597 |
|
| 598 |
// SSL_CTX_get_max_proto_version returns the maximum protocol version for |ctx|. |
| 599 |
// If |ctx| is configured to use the default maximum version, 0 is returned. |
| 600 |
OPENSSL_EXPORT uint16_t SSL_CTX_get_max_proto_version(const SSL_CTX *ctx); |
| 601 |
|
| 602 |
// SSL_set_min_proto_version sets the minimum protocol version for |ssl| to |
| 603 |
// |version|. If |version| is zero, the default minimum version is used. It |
| 604 |
// returns one on success and zero if |version| is invalid. |
| 605 |
OPENSSL_EXPORT int SSL_set_min_proto_version(SSL *ssl, uint16_t version); |
| 606 |
|
| 607 |
// SSL_set_max_proto_version sets the maximum protocol version for |ssl| to |
| 608 |
// |version|. If |version| is zero, the default maximum version is used. It |
| 609 |
// returns one on success and zero if |version| is invalid. |
| 610 |
OPENSSL_EXPORT int SSL_set_max_proto_version(SSL *ssl, uint16_t version); |
| 611 |
|
| 612 |
// SSL_get_min_proto_version returns the minimum protocol version for |ssl|. If |
| 613 |
// the connection's configuration has been shed or |ssl| is configured to use |
| 614 |
// the default min version, 0 is returned. |
| 615 |
OPENSSL_EXPORT uint16_t SSL_get_min_proto_version(const SSL *ssl); |
| 616 |
|
| 617 |
// SSL_get_max_proto_version returns the maximum protocol version for |ssl|. If |
| 618 |
// the connection's configuration has been shed or |ssl| is configured to use |
| 619 |
// the default max version, 0 is returned. |
| 620 |
OPENSSL_EXPORT uint16_t SSL_get_max_proto_version(const SSL *ssl); |
| 621 |
|
| 622 |
// SSL_version returns the TLS or DTLS protocol version used by |ssl|, which is |
| 623 |
// one of the |*_VERSION| values. (E.g. |TLS1_2_VERSION|.) Before the version |
| 624 |
// is negotiated, the result is undefined. |
| 625 |
OPENSSL_EXPORT int SSL_version(const SSL *ssl); |
| 626 |
|
| 627 |
|
| 628 |
// Options. |
| 629 |
// |
| 630 |
// Options configure protocol behavior. |
| 631 |
|
| 632 |
// SSL_OP_NO_QUERY_MTU, in DTLS, disables querying the MTU from the underlying |
| 633 |
// |BIO|. Instead, the MTU is configured with |SSL_set_mtu|. |
| 634 |
#define SSL_OP_NO_QUERY_MTU 0x00001000L |
| 635 |
|
| 636 |
// SSL_OP_NO_TICKET disables session ticket support (RFC 5077). |
| 637 |
#define SSL_OP_NO_TICKET 0x00004000L |
| 638 |
|
| 639 |
// SSL_OP_CIPHER_SERVER_PREFERENCE configures servers to select ciphers and |
| 640 |
// ECDHE curves according to the server's preferences instead of the |
| 641 |
// client's. |
| 642 |
#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L |
| 643 |
|
| 644 |
// The following flags toggle individual protocol versions. This is deprecated. |
| 645 |
// Use |SSL_CTX_set_min_proto_version| and |SSL_CTX_set_max_proto_version| |
| 646 |
// instead. |
| 647 |
#define SSL_OP_NO_TLSv1 0x04000000L |
| 648 |
#define SSL_OP_NO_TLSv1_2 0x08000000L |
| 649 |
#define SSL_OP_NO_TLSv1_1 0x10000000L |
| 650 |
#define SSL_OP_NO_TLSv1_3 0x20000000L |
| 651 |
#define SSL_OP_NO_DTLSv1 SSL_OP_NO_TLSv1 |
| 652 |
#define SSL_OP_NO_DTLSv1_2 SSL_OP_NO_TLSv1_2 |
| 653 |
|
| 654 |
// SSL_CTX_set_options enables all options set in |options| (which should be one |
| 655 |
// or more of the |SSL_OP_*| values, ORed together) in |ctx|. It returns a |
| 656 |
// bitmask representing the resulting enabled options. |
| 657 |
OPENSSL_EXPORT uint32_t SSL_CTX_set_options(SSL_CTX *ctx, uint32_t options); |
| 658 |
|
| 659 |
// SSL_CTX_clear_options disables all options set in |options| (which should be |
| 660 |
// one or more of the |SSL_OP_*| values, ORed together) in |ctx|. It returns a |
| 661 |
// bitmask representing the resulting enabled options. |
| 662 |
OPENSSL_EXPORT uint32_t SSL_CTX_clear_options(SSL_CTX *ctx, uint32_t options); |
| 663 |
|
| 664 |
// SSL_CTX_get_options returns a bitmask of |SSL_OP_*| values that represent all |
| 665 |
// the options enabled for |ctx|. |
| 666 |
OPENSSL_EXPORT uint32_t SSL_CTX_get_options(const SSL_CTX *ctx); |
| 667 |
|
| 668 |
// SSL_set_options enables all options set in |options| (which should be one or |
| 669 |
// more of the |SSL_OP_*| values, ORed together) in |ssl|. It returns a bitmask |
| 670 |
// representing the resulting enabled options. |
| 671 |
OPENSSL_EXPORT uint32_t SSL_set_options(SSL *ssl, uint32_t options); |
| 672 |
|
| 673 |
// SSL_clear_options disables all options set in |options| (which should be one |
| 674 |
// or more of the |SSL_OP_*| values, ORed together) in |ssl|. It returns a |
| 675 |
// bitmask representing the resulting enabled options. |
| 676 |
OPENSSL_EXPORT uint32_t SSL_clear_options(SSL *ssl, uint32_t options); |
| 677 |
|
| 678 |
// SSL_get_options returns a bitmask of |SSL_OP_*| values that represent all the |
| 679 |
// options enabled for |ssl|. |
| 680 |
OPENSSL_EXPORT uint32_t SSL_get_options(const SSL *ssl); |
| 681 |
|
| 682 |
|
| 683 |
// Modes. |
| 684 |
// |
| 685 |
// Modes configure API behavior. |
| 686 |
|
| 687 |
// SSL_MODE_ENABLE_PARTIAL_WRITE, in TLS, allows |SSL_write| to complete with a |
| 688 |
// partial result when the only part of the input was written in a single |
| 689 |
// record. In DTLS, it does nothing. |
| 690 |
#define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001L |
| 691 |
|
| 692 |
// SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER, in TLS, allows retrying an incomplete |
| 693 |
// |SSL_write| with a different buffer. However, |SSL_write| still assumes the |
| 694 |
// buffer contents are unchanged. This is not the default to avoid the |
| 695 |
// misconception that non-blocking |SSL_write| behaves like non-blocking |
| 696 |
// |write|. In DTLS, it does nothing. |
| 697 |
#define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L |
| 698 |
|
| 699 |
// SSL_MODE_NO_AUTO_CHAIN disables automatically building a certificate chain |
| 700 |
// before sending certificates to the peer. This flag is set (and the feature |
| 701 |
// disabled) by default. |
| 702 |
// By default, OpenSSL automatically builds a certificate chain on the fly if |
| 703 |
// there is no certificate chain explicitly provided. This feature is called |
| 704 |
// Auto-Chaining. Auto-Chaining can be turned off in OpenSSL by setting the |
| 705 |
// |SSL_MODE_NO_AUTO_CHAIN| flag for the SSL connection. AWS-LC has this flag |
| 706 |
// turned on (auto-chaining off) by default. This forces the certificate chain |
| 707 |
// to be explicit, and no longer results in unexpected certificate chains being |
| 708 |
// sent back to clients. This may cause issues for services migrating to AWS-LC, |
| 709 |
// if the service had been reliant on the default behavior. Services should |
| 710 |
// restructure their certificate chains to not use the default auto-chaining |
| 711 |
// behavior from OpenSSL when porting to AWS-LC. We highly recommend not to |
| 712 |
// re-enable Auto-Chaining, but if a consumer had been relying on this default |
| 713 |
// behavior, they can temporarily revert back with |SSL_[CTX_]clear_mode|. |
| 714 |
// However, it is generally expected of AWS-LC consumers to structure their |
| 715 |
// certificate chains to not rely on auto-chaining. |
| 716 |
#define SSL_MODE_NO_AUTO_CHAIN 0x00000008L |
| 717 |
|
| 718 |
// SSL_MODE_ENABLE_FALSE_START allows clients to send application data before |
| 719 |
// receipt of ChangeCipherSpec and Finished. This mode enables full handshakes |
| 720 |
// to 'complete' in one RTT. See RFC 7918. |
| 721 |
// |
| 722 |
// When False Start is enabled, |SSL_do_handshake| may succeed before the |
| 723 |
// handshake has completely finished. |SSL_write| will function at this point, |
| 724 |
// and |SSL_read| will transparently wait for the final handshake leg before |
| 725 |
// returning application data. To determine if False Start occurred or when the |
| 726 |
// handshake is completely finished, see |SSL_in_false_start|, |SSL_in_init|, |
| 727 |
// and |SSL_CB_HANDSHAKE_DONE| from |SSL_CTX_set_info_callback|. |
| 728 |
#define SSL_MODE_ENABLE_FALSE_START 0x00000080L |
| 729 |
|
| 730 |
// SSL_MODE_CBC_RECORD_SPLITTING causes multi-byte CBC records in TLS 1.0 to be |
| 731 |
// split in two: the first record will contain a single byte and the second will |
| 732 |
// contain the remainder. This effectively randomises the IV and prevents BEAST |
| 733 |
// attacks. |
| 734 |
#define SSL_MODE_CBC_RECORD_SPLITTING 0x00000100L |
| 735 |
|
| 736 |
// SSL_MODE_NO_SESSION_CREATION will cause any attempts to create a session to |
| 737 |
// fail with SSL_R_SESSION_MAY_NOT_BE_CREATED. This can be used to enforce that |
| 738 |
// session resumption is used for a given SSL*. |
| 739 |
#define SSL_MODE_NO_SESSION_CREATION 0x00000200L |
| 740 |
|
| 741 |
// SSL_MODE_SEND_FALLBACK_SCSV sends TLS_FALLBACK_SCSV in the ClientHello. |
| 742 |
// To be set only by applications that reconnect with a downgraded protocol |
| 743 |
// version; see RFC 7507 for details. |
| 744 |
// |
| 745 |
// DO NOT ENABLE THIS if your application attempts a normal handshake. Only use |
| 746 |
// this in explicit fallback retries, following the guidance in RFC 7507. |
| 747 |
#define SSL_MODE_SEND_FALLBACK_SCSV 0x00000400L |
| 748 |
|
| 749 |
// SSL_CTX_set_mode enables all modes set in |mode| (which should be one or more |
| 750 |
// of the |SSL_MODE_*| values, ORed together) in |ctx|. It returns a bitmask |
| 751 |
// representing the resulting enabled modes. |
| 752 |
OPENSSL_EXPORT uint32_t SSL_CTX_set_mode(SSL_CTX *ctx, uint32_t mode); |
| 753 |
|
| 754 |
// SSL_CTX_clear_mode disables all modes set in |mode| (which should be one or |
| 755 |
// more of the |SSL_MODE_*| values, ORed together) in |ctx|. It returns a |
| 756 |
// bitmask representing the resulting enabled modes. |
| 757 |
OPENSSL_EXPORT uint32_t SSL_CTX_clear_mode(SSL_CTX *ctx, uint32_t mode); |
| 758 |
|
| 759 |
// SSL_CTX_get_mode returns a bitmask of |SSL_MODE_*| values that represent all |
| 760 |
// the modes enabled for |ssl|. |
| 761 |
OPENSSL_EXPORT uint32_t SSL_CTX_get_mode(const SSL_CTX *ctx); |
| 762 |
|
| 763 |
// SSL_set_mode enables all modes set in |mode| (which should be one or more of |
| 764 |
// the |SSL_MODE_*| values, ORed together) in |ssl|. It returns a bitmask |
| 765 |
// representing the resulting enabled modes. |
| 766 |
OPENSSL_EXPORT uint32_t SSL_set_mode(SSL *ssl, uint32_t mode); |
| 767 |
|
| 768 |
// SSL_clear_mode disables all modes set in |mode| (which should be one or more |
| 769 |
// of the |SSL_MODE_*| values, ORed together) in |ssl|. It returns a bitmask |
| 770 |
// representing the resulting enabled modes. |
| 771 |
OPENSSL_EXPORT uint32_t SSL_clear_mode(SSL *ssl, uint32_t mode); |
| 772 |
|
| 773 |
// SSL_get_mode returns a bitmask of |SSL_MODE_*| values that represent all the |
| 774 |
// modes enabled for |ssl|. |
| 775 |
OPENSSL_EXPORT uint32_t SSL_get_mode(const SSL *ssl); |
| 776 |
|
| 777 |
// SSL_CTX_set0_buffer_pool sets a |CRYPTO_BUFFER_POOL| that will be used to |
| 778 |
// store certificates. This can allow multiple connections to share |
| 779 |
// certificates and thus save memory. |
| 780 |
// |
| 781 |
// The SSL_CTX does not take ownership of |pool| and the caller must ensure |
| 782 |
// that |pool| outlives |ctx| and all objects linked to it, including |SSL|, |
| 783 |
// |X509| and |SSL_SESSION| objects. Basically, don't ever free |pool|. |
| 784 |
OPENSSL_EXPORT void SSL_CTX_set0_buffer_pool(SSL_CTX *ctx, |
| 785 |
CRYPTO_BUFFER_POOL *pool); |
| 786 |
|
| 787 |
|
| 788 |
// Configuring certificates and private keys. |
| 789 |
// |
| 790 |
// These functions configure the connection's leaf certificate, private key, and |
| 791 |
// certificate chain. The certificate chain is ordered leaf to root (as sent on |
| 792 |
// the wire) but does not include the leaf. Both client and server certificates |
| 793 |
// use these functions. |
| 794 |
// |
| 795 |
// Certificates and keys may be configured before the handshake or dynamically |
| 796 |
// in the early callback and certificate callback. |
| 797 |
|
| 798 |
// SSL_CTX_use_certificate sets |ctx|'s leaf certificate to |x509|. It returns |
| 799 |
// one on success and zero on failure. |
| 800 |
OPENSSL_EXPORT int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x509); |
| 801 |
|
| 802 |
// SSL_use_certificate sets |ssl|'s leaf certificate to |x509|. It returns one |
| 803 |
// on success and zero on failure. |
| 804 |
OPENSSL_EXPORT int SSL_use_certificate(SSL *ssl, X509 *x509); |
| 805 |
|
| 806 |
// SSL_CTX_use_PrivateKey sets |ctx|'s private key to |pkey|. It returns one on |
| 807 |
// success and zero on failure. |
| 808 |
OPENSSL_EXPORT int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); |
| 809 |
|
| 810 |
// SSL_use_PrivateKey sets |ssl|'s private key to |pkey|. It returns one on |
| 811 |
// success and zero on failure. |
| 812 |
OPENSSL_EXPORT int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); |
| 813 |
|
| 814 |
// SSL_CTX_set0_chain sets |ctx|'s certificate chain, excluding the leaf, to |
| 815 |
// |chain|. On success, it returns one and takes ownership of |chain|. |
| 816 |
// Otherwise, it returns zero. |
| 817 |
OPENSSL_EXPORT int SSL_CTX_set0_chain(SSL_CTX *ctx, STACK_OF(X509) *chain); |
| 818 |
|
| 819 |
// SSL_CTX_set1_chain sets |ctx|'s certificate chain, excluding the leaf, to |
| 820 |
// |chain|. It returns one on success and zero on failure. The caller retains |
| 821 |
// ownership of |chain| and may release it freely. |
| 822 |
OPENSSL_EXPORT int SSL_CTX_set1_chain(SSL_CTX *ctx, STACK_OF(X509) *chain); |
| 823 |
|
| 824 |
// SSL_set0_chain sets |ssl|'s certificate chain, excluding the leaf, to |
| 825 |
// |chain|. On success, it returns one and takes ownership of |chain|. |
| 826 |
// Otherwise, it returns zero. |
| 827 |
OPENSSL_EXPORT int SSL_set0_chain(SSL *ssl, STACK_OF(X509) *chain); |
| 828 |
|
| 829 |
// SSL_set1_chain sets |ssl|'s certificate chain, excluding the leaf, to |
| 830 |
// |chain|. It returns one on success and zero on failure. The caller retains |
| 831 |
// ownership of |chain| and may release it freely. |
| 832 |
OPENSSL_EXPORT int SSL_set1_chain(SSL *ssl, STACK_OF(X509) *chain); |
| 833 |
|
| 834 |
// SSL_CTX_add0_chain_cert appends |x509| to |ctx|'s certificate chain. On |
| 835 |
// success, it returns one and takes ownership of |x509|. Otherwise, it returns |
| 836 |
// zero. |
| 837 |
OPENSSL_EXPORT int SSL_CTX_add0_chain_cert(SSL_CTX *ctx, X509 *x509); |
| 838 |
|
| 839 |
// SSL_CTX_add1_chain_cert appends |x509| to |ctx|'s certificate chain. It |
| 840 |
// returns one on success and zero on failure. The caller retains ownership of |
| 841 |
// |x509| and may release it freely. |
| 842 |
OPENSSL_EXPORT int SSL_CTX_add1_chain_cert(SSL_CTX *ctx, X509 *x509); |
| 843 |
|
| 844 |
// SSL_add0_chain_cert appends |x509| to |ctx|'s certificate chain. On success, |
| 845 |
// it returns one and takes ownership of |x509|. Otherwise, it returns zero. |
| 846 |
OPENSSL_EXPORT int SSL_add0_chain_cert(SSL *ssl, X509 *x509); |
| 847 |
|
| 848 |
// SSL_CTX_add_extra_chain_cert calls |SSL_CTX_add0_chain_cert|. |
| 849 |
OPENSSL_EXPORT int SSL_CTX_add_extra_chain_cert(SSL_CTX *ctx, X509 *x509); |
| 850 |
|
| 851 |
// SSL_add1_chain_cert appends |x509| to |ctx|'s certificate chain. It returns |
| 852 |
// one on success and zero on failure. The caller retains ownership of |x509| |
| 853 |
// and may release it freely. |
| 854 |
OPENSSL_EXPORT int SSL_add1_chain_cert(SSL *ssl, X509 *x509); |
| 855 |
|
| 856 |
|
| 857 |
// The following flags are used for configuring |SSL_CTX_build_cert_chain| and |
| 858 |
// |SSL_build_cert_chain|. |
| 859 |
|
| 860 |
// SSL_BUILD_CHAIN_FLAG_UNTRUSTED treats any existing certificates as untrusted |
| 861 |
// CAs. This is mutually exclusive to |SSL_BUILD_CHAIN_FLAG_CHECK| and |
| 862 |
// |SSL_BUILD_CHAIN_FLAG_CHECK| will be prioritized to use the existing chain |
| 863 |
// certificates instead. |
| 864 |
#define SSL_BUILD_CHAIN_FLAG_UNTRUSTED 0x1 |
| 865 |
|
| 866 |
// SSL_BUILD_CHAIN_FLAG_NO_ROOT omits the root CA from the built chain. |
| 867 |
#define SSL_BUILD_CHAIN_FLAG_NO_ROOT 0x2 |
| 868 |
|
| 869 |
// SSL_BUILD_CHAIN_FLAG_CHECK uses only existing chain certificates to build the |
| 870 |
// chain (effectively sanity checking and rearranging them if necessary). This |
| 871 |
// is mutually exclusive to |SSL_BUILD_CHAIN_FLAG_UNTRUSTED| and |
| 872 |
// |SSL_BUILD_CHAIN_FLAG_CHECK| will be prioritized. |
| 873 |
#define SSL_BUILD_CHAIN_FLAG_CHECK 0x4 |
| 874 |
|
| 875 |
// SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR ignores errors during certificate |
| 876 |
// verification, but still pushes the error onto the error queue. |
| 877 |
#define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR 0x8 |
| 878 |
|
| 879 |
// SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR is only used when |
| 880 |
// |SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR| is defined. It clears the error from the |
| 881 |
// error queue if certificate verification has failed. |
| 882 |
#define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR 0x10 |
| 883 |
|
| 884 |
// SSL_CTX_build_cert_chain builds the certificate chain for |ctx|. |
| 885 |
// Normally this uses the chain store or the verify store if the chain store is |
| 886 |
// not set. If the function is successful, the built chain will replace any |
| 887 |
// existing chain in |ctx|. |
| 888 |
// This function returns 1 on success and -1 on failure, unless |
| 889 |
// |SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR| is set. If |
| 890 |
// |SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR| is set, then this function returns 1 on |
| 891 |
// success, 2 if certificate verification has failed, and -1 on all other types |
| 892 |
// of failures. |
| 893 |
OPENSSL_EXPORT int SSL_CTX_build_cert_chain(SSL_CTX *ctx, int flags); |
| 894 |
|
| 895 |
// SSL_build_cert_chain is similar to |SSL_CTX_build_cert_chain|, but the |
| 896 |
// certificate chain is built for |ssl| instead. |
| 897 |
OPENSSL_EXPORT int SSL_build_cert_chain(SSL *ssl, int flags); |
| 898 |
|
| 899 |
// SSL_CTX_clear_chain_certs clears |ctx|'s certificate chain and returns |
| 900 |
// one. |
| 901 |
OPENSSL_EXPORT int SSL_CTX_clear_chain_certs(SSL_CTX *ctx); |
| 902 |
|
| 903 |
// SSL_CTX_clear_extra_chain_certs calls |SSL_CTX_clear_chain_certs|. |
| 904 |
OPENSSL_EXPORT int SSL_CTX_clear_extra_chain_certs(SSL_CTX *ctx); |
| 905 |
|
| 906 |
// SSL_clear_chain_certs clears |ssl|'s certificate chain and returns one. |
| 907 |
OPENSSL_EXPORT int SSL_clear_chain_certs(SSL *ssl); |
| 908 |
|
| 909 |
// SSL_CTX_set_cert_cb sets a callback that is called to select a certificate. |
| 910 |
// The callback returns one on success, zero on internal error, and a negative |
| 911 |
// number on failure or to pause the handshake. If the handshake is paused, |
| 912 |
// |SSL_get_error| will return |SSL_ERROR_WANT_X509_LOOKUP|. |
| 913 |
// |
| 914 |
// On the client, the callback may call |SSL_get0_certificate_types| and |
| 915 |
// |SSL_get_client_CA_list| for information on the server's certificate |
| 916 |
// request. |
| 917 |
// |
| 918 |
// On the server, the callback will be called after extensions have been |
| 919 |
// processed, but before the resumption decision has been made. This differs |
| 920 |
// from OpenSSL which handles resumption before selecting the certificate. |
| 921 |
OPENSSL_EXPORT void SSL_CTX_set_cert_cb(SSL_CTX *ctx, |
| 922 |
int (*cb)(SSL *ssl, void *arg), |
| 923 |
void *arg); |
| 924 |
|
| 925 |
// SSL_set_cert_cb sets a callback that is called to select a certificate. The |
| 926 |
// callback returns one on success, zero on internal error, and a negative |
| 927 |
// number on failure or to pause the handshake. If the handshake is paused, |
| 928 |
// |SSL_get_error| will return |SSL_ERROR_WANT_X509_LOOKUP|. |
| 929 |
// |
| 930 |
// On the client, the callback may call |SSL_get0_certificate_types| and |
| 931 |
// |SSL_get_client_CA_list| for information on the server's certificate |
| 932 |
// request. |
| 933 |
// |
| 934 |
// On the server, the callback will be called after extensions have been |
| 935 |
// processed, but before the resumption decision has been made. This differs |
| 936 |
// from OpenSSL which handles resumption before selecting the certificate. |
| 937 |
OPENSSL_EXPORT void SSL_set_cert_cb(SSL *ssl, int (*cb)(SSL *ssl, void *arg), |
| 938 |
void *arg); |
| 939 |
|
| 940 |
// SSL_get0_certificate_types, for a client, sets |*out_types| to an array |
| 941 |
// containing the client certificate types requested by a server. It returns the |
| 942 |
// length of the array. Note this list is always empty in TLS 1.3. The server |
| 943 |
// will instead send signature algorithms. See |
| 944 |
// |SSL_get0_peer_verify_algorithms|. |
| 945 |
// |
| 946 |
// The behavior of this function is undefined except during the callbacks set by |
| 947 |
// by |SSL_CTX_set_cert_cb| and |SSL_CTX_set_client_cert_cb| or when the |
| 948 |
// handshake is paused because of them. |
| 949 |
OPENSSL_EXPORT size_t SSL_get0_certificate_types(const SSL *ssl, |
| 950 |
const uint8_t **out_types); |
| 951 |
|
| 952 |
// SSL_get0_peer_verify_algorithms sets |*out_sigalgs| to an array containing |
| 953 |
// the signature algorithms the peer is able to verify. It returns the length of |
| 954 |
// the array. Note these values are only sent starting TLS 1.2 and only |
| 955 |
// mandatory starting TLS 1.3. If not sent, the empty array is returned. For the |
| 956 |
// historical client certificate types list, see |SSL_get0_certificate_types|. |
| 957 |
// |
| 958 |
// The behavior of this function is undefined except during the callbacks set by |
| 959 |
// by |SSL_CTX_set_cert_cb| and |SSL_CTX_set_client_cert_cb| or when the |
| 960 |
// handshake is paused because of them. |
| 961 |
OPENSSL_EXPORT size_t |
| 962 |
SSL_get0_peer_verify_algorithms(const SSL *ssl, const uint16_t **out_sigalgs); |
| 963 |
|
| 964 |
// SSL_get0_peer_delegation_algorithms sets |*out_sigalgs| to an array |
| 965 |
// containing the signature algorithms the peer is willing to use with delegated |
| 966 |
// credentials. It returns the length of the array. If not sent, the empty |
| 967 |
// array is returned. |
| 968 |
// |
| 969 |
// The behavior of this function is undefined except during the callbacks set by |
| 970 |
// by |SSL_CTX_set_cert_cb| and |SSL_CTX_set_client_cert_cb| or when the |
| 971 |
// handshake is paused because of them. |
| 972 |
OPENSSL_EXPORT size_t SSL_get0_peer_delegation_algorithms( |
| 973 |
const SSL *ssl, const uint16_t **out_sigalgs); |
| 974 |
|
| 975 |
// SSL_CLIENT_HELLO_SUCCESS indicates that the ClientHello processing was |
| 976 |
// successful. The handshake will continue normally. |
| 977 |
# define SSL_CLIENT_HELLO_SUCCESS 1 |
| 978 |
// SSL_CLIENT_HELLO_ERROR indicates that a fatal error occurred while processing |
| 979 |
// the ClientHello. The callback should set |*al| to a TLS alert value to return |
| 980 |
// to the client. The handshake will be aborted. |
| 981 |
# define SSL_CLIENT_HELLO_ERROR 0 |
| 982 |
// SSL_CLIENT_HELLO_RETRY indicates that the handshake should be paused and the |
| 983 |
// server should retry when it can continue. |
| 984 |
// |
| 985 |
// WARNING: The current implementation does not properly support |
| 986 |
// SSL_CLIENT_HELLO_RETRY and attempting to use it will result in handshake |
| 987 |
// failure. |
| 988 |
# define SSL_CLIENT_HELLO_RETRY (-1) |
| 989 |
|
| 990 |
// SSL_client_hello_cb_fn is a callback function that is called when a ClientHello |
| 991 |
// is received. The callback may inspect the ClientHello and make decisions |
| 992 |
// about the connection based on its contents. |
| 993 |
// |
| 994 |
// The callback should return one of: |
| 995 |
// - SSL_CLIENT_HELLO_SUCCESS to continue the handshake |
| 996 |
// - SSL_CLIENT_HELLO_ERROR to abort the handshake with alert |*al| |
| 997 |
// - SSL_CLIENT_HELLO_RETRY (not supported) is handled like SSL_CLIENT_HELLO_ERROR |
| 998 |
typedef int (*SSL_client_hello_cb_fn)(SSL *s, int *al, void *arg); |
| 999 |
|
| 1000 |
// SSL_client_hello_get1_extensions_present iterates over the extensions in the |
| 1001 |
// ClientHello. If any are found, it allocates an array of int and sets |*out| |
| 1002 |
// to point to this array and |*outlen| to the number of extensions. The ints |
| 1003 |
// in the array correspond to the type of each extension. The caller is |
| 1004 |
// responsible for releasing the array with OPENSSL_free. If no extensions are |
| 1005 |
// found, it sets |*out| to NULL and |*outlen| to 0. The function returns 1 on |
| 1006 |
// success and returns 0 on error. |
| 1007 |
// |
| 1008 |
// This function can only be called from within a client hello callback (see |
| 1009 |
// |SSL_CTX_set_client_hello_cb|) or during server certificate selection (see |
| 1010 |
// |SSL_CTX_set_select_certificate_cb|). |
| 1011 |
OPENSSL_EXPORT int SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen); |
| 1012 |
|
| 1013 |
// SSL_client_hello_get_extension_order iterates over the extensions in the |
| 1014 |
// ClientHello. If |exts| is not null, the type for each extension will be |
| 1015 |
// stored in |exts| and |*num_exts| should be the size of storage |
| 1016 |
// allocated for |exts|; the function will return an error if |*num_exts| is |
| 1017 |
// too small. On success, the function will return 1 and will set |*num_exts| to |
| 1018 |
// the number of extensions. The caller may pass |exts| as null to obtain the |
| 1019 |
// number of extensions. If no ClientHello extensions are found, the |
| 1020 |
// function returns 1 and sets |*num_exts| to 0. The functions returns 0 on |
| 1021 |
// error. |
| 1022 |
// |
| 1023 |
// This function can only be called from within a client hello callback (see |
| 1024 |
// |SSL_CTX_set_client_hello_cb|) or during server certificate selection (see |
| 1025 |
// |SSL_CTX_set_select_certificate_cb|). |
| 1026 |
OPENSSL_EXPORT int SSL_client_hello_get_extension_order(SSL *s, uint16_t *exts, size_t *num_exts); |
| 1027 |
|
| 1028 |
// SSL_CTX_set_client_hello_cb configures a callback that is called when a |
| 1029 |
// ClientHello message is received. This can be used to select certificates, |
| 1030 |
// adjust settings, or otherwise make decisions about the connection before |
| 1031 |
// the handshake proceeds. |
| 1032 |
// |
| 1033 |
// The callback is invoked before most ClientHello processing and before the |
| 1034 |
// decision whether to resume a session is made. It may inspect the ClientHello |
| 1035 |
// and configure the connection accordingly. |
| 1036 |
// |
| 1037 |
// The callback function is passed the |SSL| object, a pointer to an alert value, |
| 1038 |
// and the argument provided when the callback was set. It should return either |
| 1039 |
// SSL_CLIENT_HELLO_SUCCESS, SSL_CLIENT_HELLO_ERROR, or SSL_CLIENT_HELLO_RETRY. |
| 1040 |
// Note that SSL_CLIENT_HELLO_RETRY is not fully supported; it is treated the |
| 1041 |
// same as SSL_CLIENT_HELLO_ERROR. |
| 1042 |
OPENSSL_EXPORT void SSL_CTX_set_client_hello_cb(SSL_CTX *c, SSL_client_hello_cb_fn cb, |
| 1043 |
void *arg); |
| 1044 |
|
| 1045 |
// SSL_client_hello_isv2 always returns zero as SSLv2 is not supported. |
| 1046 |
OPENSSL_EXPORT int SSL_client_hello_isv2(SSL *s); |
| 1047 |
|
| 1048 |
|
| 1049 |
// SSL_client_hello_get0_legacy_version provides the value of the |
| 1050 |
// "legacy_version" field in the client hello. |
| 1051 |
// |
| 1052 |
// This function can only be called from within a client hello callback (see |
| 1053 |
// |SSL_CTX_set_client_hello_cb|) or during server certificate selection (see |
| 1054 |
// |SSL_CTX_set_select_certificate_cb|). |
| 1055 |
OPENSSL_EXPORT unsigned int SSL_client_hello_get0_legacy_version(SSL *s); |
| 1056 |
|
| 1057 |
// SSL_client_hello_get0_ext searches the extensions in the ClientHello for an |
| 1058 |
// extension of the given type. If found, it sets |*out| to point to the |
| 1059 |
// extension contents (not including the type and length bytes) and |*outlen| |
| 1060 |
// to the length of the extension contents. If not found, it returns zero. |
| 1061 |
// |
| 1062 |
// This function can only be called from within a client hello callback (see |
| 1063 |
// |SSL_CTX_set_client_hello_cb|) or during server certificate selection (see |
| 1064 |
// |SSL_CTX_set_select_certificate_cb|). |
| 1065 |
OPENSSL_EXPORT int SSL_client_hello_get0_ext(SSL *s, unsigned int type, const unsigned char **out, |
| 1066 |
size_t *outlen); |
| 1067 |
|
| 1068 |
// SSL_certs_clear resets the private key, leaf certificate, and certificate |
| 1069 |
// chain of |ssl|. |
| 1070 |
OPENSSL_EXPORT void SSL_certs_clear(SSL *ssl); |
| 1071 |
|
| 1072 |
// SSL_CTX_check_private_key returns one if the certificate and private key |
| 1073 |
// configured in |ctx| are consistent and zero otherwise. |
| 1074 |
OPENSSL_EXPORT int SSL_CTX_check_private_key(const SSL_CTX *ctx); |
| 1075 |
|
| 1076 |
// SSL_check_private_key returns one if the certificate and private key |
| 1077 |
// configured in |ssl| are consistent and zero otherwise. |
| 1078 |
OPENSSL_EXPORT int SSL_check_private_key(const SSL *ssl); |
| 1079 |
|
| 1080 |
// SSL_CTX_get0_certificate returns |ctx|'s leaf certificate. |
| 1081 |
OPENSSL_EXPORT X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx); |
| 1082 |
|
| 1083 |
// SSL_get_certificate returns |ssl|'s leaf certificate. |
| 1084 |
OPENSSL_EXPORT X509 *SSL_get_certificate(const SSL *ssl); |
| 1085 |
|
| 1086 |
// SSL_CTX_get0_privatekey returns |ctx|'s private key. |
| 1087 |
OPENSSL_EXPORT EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx); |
| 1088 |
|
| 1089 |
// SSL_get_privatekey returns |ssl|'s private key. |
| 1090 |
OPENSSL_EXPORT EVP_PKEY *SSL_get_privatekey(const SSL *ssl); |
| 1091 |
|
| 1092 |
// SSL_CTX_get0_chain_certs sets |*out_chain| to |ctx|'s certificate chain and |
| 1093 |
// returns one. |
| 1094 |
OPENSSL_EXPORT int SSL_CTX_get0_chain_certs(const SSL_CTX *ctx, |
| 1095 |
STACK_OF(X509) **out_chain); |
| 1096 |
|
| 1097 |
// SSL_CTX_get_extra_chain_certs calls |SSL_CTX_get0_chain_certs|. |
| 1098 |
OPENSSL_EXPORT int SSL_CTX_get_extra_chain_certs(const SSL_CTX *ctx, |
| 1099 |
STACK_OF(X509) **out_chain); |
| 1100 |
|
| 1101 |
// SSL_get0_chain_certs sets |*out_chain| to |ssl|'s certificate chain and |
| 1102 |
// returns one. |
| 1103 |
OPENSSL_EXPORT int SSL_get0_chain_certs(const SSL *ssl, |
| 1104 |
STACK_OF(X509) **out_chain); |
| 1105 |
|
| 1106 |
// SSL_CTX_set_signed_cert_timestamp_list sets the list of signed certificate |
| 1107 |
// timestamps that is sent to clients that request it. The |list| argument must |
| 1108 |
// contain one or more SCT structures serialised as a SignedCertificateTimestamp |
| 1109 |
// List (see https://tools.ietf.org/html/rfc6962#section-3.3) – i.e. each SCT |
| 1110 |
// is prefixed by a big-endian, uint16 length and the concatenation of one or |
| 1111 |
// more such prefixed SCTs are themselves also prefixed by a uint16 length. It |
| 1112 |
// returns one on success and zero on error. The caller retains ownership of |
| 1113 |
// |list|. |
| 1114 |
OPENSSL_EXPORT int SSL_CTX_set_signed_cert_timestamp_list(SSL_CTX *ctx, |
| 1115 |
const uint8_t *list, |
| 1116 |
size_t list_len); |
| 1117 |
|
| 1118 |
// SSL_set_signed_cert_timestamp_list sets the list of signed certificate |
| 1119 |
// timestamps that is sent to clients that request is. The same format as the |
| 1120 |
// one used for |SSL_CTX_set_signed_cert_timestamp_list| applies. The caller |
| 1121 |
// retains ownership of |list|. |
| 1122 |
OPENSSL_EXPORT int SSL_set_signed_cert_timestamp_list(SSL *ctx, |
| 1123 |
const uint8_t *list, |
| 1124 |
size_t list_len); |
| 1125 |
|
| 1126 |
// SSL_CTX_set_ocsp_response sets the OCSP response that is sent to clients |
| 1127 |
// which request it. It returns one on success and zero on error. The caller |
| 1128 |
// retains ownership of |response|. |
| 1129 |
OPENSSL_EXPORT int SSL_CTX_set_ocsp_response(SSL_CTX *ctx, |
| 1130 |
const uint8_t *response, |
| 1131 |
size_t response_len); |
| 1132 |
|
| 1133 |
// SSL_set_ocsp_response sets the OCSP response that is sent to clients which |
| 1134 |
// request it. It returns one on success and zero on error. The caller retains |
| 1135 |
// ownership of |response|. |
| 1136 |
OPENSSL_EXPORT int SSL_set_ocsp_response(SSL *ssl, const uint8_t *response, |
| 1137 |
size_t response_len); |
| 1138 |
|
| 1139 |
// SSL_SIGN_* are signature algorithm values as defined in TLS 1.3. |
| 1140 |
#define SSL_SIGN_RSA_PKCS1_SHA1 0x0201 |
| 1141 |
#define SSL_SIGN_RSA_PKCS1_SHA256 0x0401 |
| 1142 |
#define SSL_SIGN_RSA_PKCS1_SHA384 0x0501 |
| 1143 |
#define SSL_SIGN_RSA_PKCS1_SHA512 0x0601 |
| 1144 |
#define SSL_SIGN_ECDSA_SHA1 0x0203 |
| 1145 |
#define SSL_SIGN_ECDSA_SECP256R1_SHA256 0x0403 |
| 1146 |
#define SSL_SIGN_ECDSA_SECP384R1_SHA384 0x0503 |
| 1147 |
#define SSL_SIGN_ECDSA_SECP521R1_SHA512 0x0603 |
| 1148 |
#define SSL_SIGN_RSA_PSS_RSAE_SHA256 0x0804 |
| 1149 |
#define SSL_SIGN_RSA_PSS_RSAE_SHA384 0x0805 |
| 1150 |
#define SSL_SIGN_RSA_PSS_RSAE_SHA512 0x0806 |
| 1151 |
#define SSL_SIGN_ED25519 0x0807 |
| 1152 |
|
| 1153 |
// SSL_SIGN_RSA_PKCS1_MD5_SHA1 is an internal signature algorithm used to |
| 1154 |
// specify raw RSASSA-PKCS1-v1_5 with an MD5/SHA-1 concatenation, as used in TLS |
| 1155 |
// before TLS 1.2. |
| 1156 |
#define SSL_SIGN_RSA_PKCS1_MD5_SHA1 0xff01 |
| 1157 |
|
| 1158 |
// SSL_get_signature_algorithm_name returns a human-readable name for |sigalg|, |
| 1159 |
// or NULL if unknown. If |include_curve| is one, the curve for ECDSA algorithms |
| 1160 |
// is included as in TLS 1.3. Otherwise, it is excluded as in TLS 1.2. |
| 1161 |
OPENSSL_EXPORT const char *SSL_get_signature_algorithm_name(uint16_t sigalg, |
| 1162 |
int include_curve); |
| 1163 |
|
| 1164 |
// SSL_get_all_signature_algorithm_names outputs a list of possible strings |
| 1165 |
// |SSL_get_signature_algorithm_name| may return in this version of BoringSSL. |
| 1166 |
// It writes at most |max_out| entries to |out| and returns the total number it |
| 1167 |
// would have written, if |max_out| had been large enough. |max_out| may be |
| 1168 |
// initially set to zero to size the output. |
| 1169 |
// |
| 1170 |
// This function is only intended to help initialize tables in callers that want |
| 1171 |
// possible strings pre-declared. This list would not be suitable to set a list |
| 1172 |
// of supported features. It is in no particular order, and may contain |
| 1173 |
// placeholder, experimental, or deprecated values that do not apply to every |
| 1174 |
// caller. Future versions of BoringSSL may also return strings not in this |
| 1175 |
// list, so this does not apply if, say, sending strings across services. |
| 1176 |
OPENSSL_EXPORT size_t SSL_get_all_signature_algorithm_names(const char **out, |
| 1177 |
size_t max_out); |
| 1178 |
|
| 1179 |
// SSL_get_signature_algorithm_key_type returns the key type associated with |
| 1180 |
// |sigalg| as an |EVP_PKEY_*| constant or |EVP_PKEY_NONE| if unknown. |
| 1181 |
OPENSSL_EXPORT int SSL_get_signature_algorithm_key_type(uint16_t sigalg); |
| 1182 |
|
| 1183 |
// SSL_get_signature_algorithm_digest returns the digest function associated |
| 1184 |
// with |sigalg| or |NULL| if |sigalg| has no prehash (Ed25519) or is unknown. |
| 1185 |
OPENSSL_EXPORT const EVP_MD *SSL_get_signature_algorithm_digest( |
| 1186 |
uint16_t sigalg); |
| 1187 |
|
| 1188 |
// SSL_is_signature_algorithm_rsa_pss returns one if |sigalg| is an RSA-PSS |
| 1189 |
// signature algorithm and zero otherwise. |
| 1190 |
OPENSSL_EXPORT int SSL_is_signature_algorithm_rsa_pss(uint16_t sigalg); |
| 1191 |
|
| 1192 |
// SSL_CTX_set_signing_algorithm_prefs configures |ctx| to use |prefs| as the |
| 1193 |
// preference list when signing with |ctx|'s private key. It returns one on |
| 1194 |
// success and zero on error. |prefs| should not include the internal-only value |
| 1195 |
// |SSL_SIGN_RSA_PKCS1_MD5_SHA1|. |
| 1196 |
OPENSSL_EXPORT int SSL_CTX_set_signing_algorithm_prefs(SSL_CTX *ctx, |
| 1197 |
const uint16_t *prefs, |
| 1198 |
size_t num_prefs); |
| 1199 |
|
| 1200 |
// SSL_set_signing_algorithm_prefs configures |ssl| to use |prefs| as the |
| 1201 |
// preference list when signing with |ssl|'s private key. It returns one on |
| 1202 |
// success and zero on error. |prefs| should not include the internal-only value |
| 1203 |
// |SSL_SIGN_RSA_PKCS1_MD5_SHA1|. |
| 1204 |
OPENSSL_EXPORT int SSL_set_signing_algorithm_prefs(SSL *ssl, |
| 1205 |
const uint16_t *prefs, |
| 1206 |
size_t num_prefs); |
| 1207 |
|
| 1208 |
// SSL_CTX_use_cert_and_key sets |x509|, |privatekey|, and |chain| on |ctx|. |
| 1209 |
// The |privatekey| argument must be the private key of the certificate |x509|. |
| 1210 |
// If the override argument is 0, then |x509|, |privatekey|, and |chain| are |
| 1211 |
// set only if all were not previously set. If override is non-0, then the |
| 1212 |
// certificate, private key and chain certs are always set. |privatekey| and |
| 1213 |
// |x509| are not copied or duplicated, their reference counts are incremented. |
| 1214 |
// In OpenSSL, a shallow copy of |chain| is stored with a reference count |
| 1215 |
// increment for all |X509| objects in the chain. In AWS-LC, |
| 1216 |
// we represent X509 chains as a CRYPTO_BUFFER stack. Therefore, we create a |
| 1217 |
// an internal copy and leave the |chain| parameter untouched. This means, |
| 1218 |
// changes to |chain| after this function is called will not update in |ctx|. |
| 1219 |
// This is different from OpenSSL which stores a reference to the X509 |
| 1220 |
// certificates in the |chain| object. |
| 1221 |
// |
| 1222 |
// Returns one on success and zero on error. |
| 1223 |
OPENSSL_EXPORT int SSL_CTX_use_cert_and_key(SSL_CTX *ctx, X509 *x509, |
| 1224 |
EVP_PKEY *privatekey, |
| 1225 |
STACK_OF(X509) *chain, int override); |
| 1226 |
|
| 1227 |
// SSL_use_cert_and_key sets |x509|, |privatekey|, and |chain| on |ssl|. |
| 1228 |
// The |privatekey| argument must be the private key of the certificate |x509|. |
| 1229 |
// If the override argument is 0, then |x509|, |privatekey|, and |chain| are |
| 1230 |
// set only if all were not previously set. If override is non-0, then the |
| 1231 |
// certificate, private key and chain certs are always set. |privatekey| and |
| 1232 |
// |x509| are not copied or duplicated, their reference counts are incremented. |
| 1233 |
// In OpenSSL, a shallow copy of |chain| is stored with a reference count |
| 1234 |
// increment for all |X509| objects in the chain. In AWS-LC, |
| 1235 |
// we represent X509 chains as a CRYPTO_BUFFER stack. Therefore, we create a |
| 1236 |
// an internal copy and leave the |chain| parameter untouched. This means, |
| 1237 |
// changes to |chain| after this function is called will not update in |ssl|. |
| 1238 |
// This is different from OpenSSL which stores a reference to the X509 |
| 1239 |
// certificates in the |chain| object. |
| 1240 |
// |
| 1241 |
// Returns one on success and zero on error. |
| 1242 |
OPENSSL_EXPORT int SSL_use_cert_and_key(SSL *ssl, X509 *x509, |
| 1243 |
EVP_PKEY *privatekey, |
| 1244 |
STACK_OF(X509) *chain, int override); |
| 1245 |
|
| 1246 |
// Certificate and private key convenience functions. |
| 1247 |
|
| 1248 |
// SSL_CTX_set_chain_and_key sets the certificate chain and private key for a |
| 1249 |
// TLS client or server. References to the given |CRYPTO_BUFFER| and |EVP_PKEY| |
| 1250 |
// objects are added as needed. Exactly one of |privkey| or |privkey_method| |
| 1251 |
// may be non-NULL. Returns one on success and zero on error. |
| 1252 |
OPENSSL_EXPORT int SSL_CTX_set_chain_and_key( |
| 1253 |
SSL_CTX *ctx, CRYPTO_BUFFER *const *certs, size_t num_certs, |
| 1254 |
EVP_PKEY *privkey, const SSL_PRIVATE_KEY_METHOD *privkey_method); |
| 1255 |
|
| 1256 |
// SSL_set_chain_and_key sets the certificate chain and private key for a TLS |
| 1257 |
// client or server. References to the given |CRYPTO_BUFFER| and |EVP_PKEY| |
| 1258 |
// objects are added as needed. Exactly one of |privkey| or |privkey_method| |
| 1259 |
// may be non-NULL. Returns one on success and zero on error. |
| 1260 |
OPENSSL_EXPORT int SSL_set_chain_and_key( |
| 1261 |
SSL *ssl, CRYPTO_BUFFER *const *certs, size_t num_certs, EVP_PKEY *privkey, |
| 1262 |
const SSL_PRIVATE_KEY_METHOD *privkey_method); |
| 1263 |
|
| 1264 |
// SSL_CTX_get0_chain returns the list of |CRYPTO_BUFFER|s that were set by |
| 1265 |
// |SSL_set_chain_and_key|, unless they have been discarded. Reference counts |
| 1266 |
// are not incremented by this call. The return value may be |NULL| if no chain |
| 1267 |
// has been set. |
| 1268 |
// |
| 1269 |
// (Note: if a chain was configured by non-|CRYPTO_BUFFER|-based functions then |
| 1270 |
// the return value is undefined and, even if not NULL, the stack itself may |
| 1271 |
// contain nullptrs. Thus you shouldn't mix this function with |
| 1272 |
// non-|CRYPTO_BUFFER| functions for manipulating the chain.) |
| 1273 |
// |
| 1274 |
// There is no |SSL*| version of this function because connections discard |
| 1275 |
// configuration after handshaking, thus making it of questionable utility. |
| 1276 |
OPENSSL_EXPORT const STACK_OF(CRYPTO_BUFFER) *SSL_CTX_get0_chain( |
| 1277 |
const SSL_CTX *ctx); |
| 1278 |
|
| 1279 |
// SSL_CTX_use_RSAPrivateKey sets |ctx|'s private key to |rsa|. It returns one |
| 1280 |
// on success and zero on failure. |
| 1281 |
OPENSSL_EXPORT int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); |
| 1282 |
|
| 1283 |
// SSL_use_RSAPrivateKey sets |ctx|'s private key to |rsa|. It returns one on |
| 1284 |
// success and zero on failure. |
| 1285 |
OPENSSL_EXPORT int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); |
| 1286 |
|
| 1287 |
// The following functions configure certificates or private keys but take as |
| 1288 |
// input DER-encoded structures. They return one on success and zero on |
| 1289 |
// failure. |
| 1290 |
|
| 1291 |
OPENSSL_EXPORT int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, size_t der_len, |
| 1292 |
const uint8_t *der); |
| 1293 |
OPENSSL_EXPORT int SSL_use_certificate_ASN1(SSL *ssl, const uint8_t *der, |
| 1294 |
size_t der_len); |
| 1295 |
|
| 1296 |
OPENSSL_EXPORT int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, |
| 1297 |
const uint8_t *der, |
| 1298 |
size_t der_len); |
| 1299 |
OPENSSL_EXPORT int SSL_use_PrivateKey_ASN1(int type, SSL *ssl, |
| 1300 |
const uint8_t *der, size_t der_len); |
| 1301 |
|
| 1302 |
OPENSSL_EXPORT int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, |
| 1303 |
const uint8_t *der, |
| 1304 |
size_t der_len); |
| 1305 |
OPENSSL_EXPORT int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const uint8_t *der, |
| 1306 |
size_t der_len); |
| 1307 |
|
| 1308 |
// The following functions configure certificates or private keys but take as |
| 1309 |
// input files to read from. They return one on success and zero on failure. The |
| 1310 |
// |type| parameter is one of the |SSL_FILETYPE_*| values and determines whether |
| 1311 |
// the file's contents are read as PEM or DER. |
| 1312 |
|
| 1313 |
#define SSL_FILETYPE_PEM 1 |
| 1314 |
#define SSL_FILETYPE_ASN1 2 |
| 1315 |
|
| 1316 |
OPENSSL_EXPORT int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, |
| 1317 |
const char *file, int type); |
| 1318 |
OPENSSL_EXPORT int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, |
| 1319 |
int type); |
| 1320 |
|
| 1321 |
OPENSSL_EXPORT int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, |
| 1322 |
int type); |
| 1323 |
OPENSSL_EXPORT int SSL_use_certificate_file(SSL *ssl, const char *file, |
| 1324 |
int type); |
| 1325 |
|
| 1326 |
OPENSSL_EXPORT int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, |
| 1327 |
int type); |
| 1328 |
OPENSSL_EXPORT int SSL_use_PrivateKey_file(SSL *ssl, const char *file, |
| 1329 |
int type); |
| 1330 |
|
| 1331 |
// SSL_CTX_use_certificate_chain_file configures certificates for |ctx|. It |
| 1332 |
// reads the contents of |file| as a PEM-encoded leaf certificate followed |
| 1333 |
// optionally by the certificate chain to send to the peer. It returns one on |
| 1334 |
// success and zero on failure. |
| 1335 |
// |
| 1336 |
// WARNING: If the input contains "TRUSTED CERTIFICATE" PEM blocks, this |
| 1337 |
// function parses auxiliary properties as in |d2i_X509_AUX|. Passing untrusted |
| 1338 |
// input to this function allows an attacker to influence those properties. See |
| 1339 |
// |d2i_X509_AUX| for details. |
| 1340 |
OPENSSL_EXPORT int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, |
| 1341 |
const char *file); |
| 1342 |
|
| 1343 |
// SSL_use_certificate_chain_file configures certificates for |ssl|. It |
| 1344 |
// reads the contents of |file| as a PEM-encoded leaf certificate followed |
| 1345 |
// optionally by the certificate chain to send to the peer. It returns one on |
| 1346 |
// success and zero on failure. |
| 1347 |
OPENSSL_EXPORT int SSL_use_certificate_chain_file(SSL *ssl, const char *file); |
| 1348 |
|
| 1349 |
// SSL_CTX_set_default_passwd_cb sets the password callback for PEM-based |
| 1350 |
// convenience functions called on |ctx|. |
| 1351 |
OPENSSL_EXPORT void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, |
| 1352 |
pem_password_cb *cb); |
| 1353 |
|
| 1354 |
// SSL_CTX_get_default_passwd_cb returns the callback set by |
| 1355 |
// |SSL_CTX_set_default_passwd_cb|. |
| 1356 |
OPENSSL_EXPORT pem_password_cb *SSL_CTX_get_default_passwd_cb( |
| 1357 |
const SSL_CTX *ctx); |
| 1358 |
|
| 1359 |
// SSL_CTX_set_default_passwd_cb_userdata sets the userdata parameter for |
| 1360 |
// |ctx|'s password callback. |
| 1361 |
OPENSSL_EXPORT void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, |
| 1362 |
void *data); |
| 1363 |
|
| 1364 |
// SSL_CTX_get_default_passwd_cb_userdata returns the userdata parameter set by |
| 1365 |
// |SSL_CTX_set_default_passwd_cb_userdata|. |
| 1366 |
OPENSSL_EXPORT void *SSL_CTX_get_default_passwd_cb_userdata(const SSL_CTX *ctx); |
| 1367 |
|
| 1368 |
|
| 1369 |
// Custom private keys. |
| 1370 |
|
| 1371 |
enum ssl_private_key_result_t { |
| 1372 |
ssl_private_key_success, |
| 1373 |
ssl_private_key_retry, |
| 1374 |
ssl_private_key_failure |
| 1375 |
}; |
| 1376 |
|
| 1377 |
// ssl_private_key_method_st (aka |SSL_PRIVATE_KEY_METHOD|) describes private |
| 1378 |
// key hooks. This is used to off-load signing operations to a custom, |
| 1379 |
// potentially asynchronous, backend. Metadata about the key such as the type |
| 1380 |
// and size are parsed out of the certificate. |
| 1381 |
// |
| 1382 |
// Callers that use this structure should additionally call |
| 1383 |
// |SSL_set_signing_algorithm_prefs| or |SSL_CTX_set_signing_algorithm_prefs| |
| 1384 |
// with the private key's capabilities. This ensures BoringSSL will select a |
| 1385 |
// suitable signature algorithm for the private key. |
| 1386 |
struct ssl_private_key_method_st { |
| 1387 |
// sign signs the message |in| in using the specified signature algorithm. On |
| 1388 |
// success, it returns |ssl_private_key_success| and writes at most |max_out| |
| 1389 |
// bytes of signature data to |out| and sets |*out_len| to the number of bytes |
| 1390 |
// written. On failure, it returns |ssl_private_key_failure|. If the operation |
| 1391 |
// has not completed, it returns |ssl_private_key_retry|. |sign| should |
| 1392 |
// arrange for the high-level operation on |ssl| to be retried when the |
| 1393 |
// operation is completed. This will result in a call to |complete|. |
| 1394 |
// |
| 1395 |
// |signature_algorithm| is one of the |SSL_SIGN_*| values, as defined in TLS |
| 1396 |
// 1.3. Note that, in TLS 1.2, ECDSA algorithms do not require that curve |
| 1397 |
// sizes match hash sizes, so the curve portion of |SSL_SIGN_ECDSA_*| values |
| 1398 |
// must be ignored. BoringSSL will internally handle the curve matching logic |
| 1399 |
// where appropriate. |
| 1400 |
// |
| 1401 |
// It is an error to call |sign| while another private key operation is in |
| 1402 |
// progress on |ssl|. |
| 1403 |
enum ssl_private_key_result_t (*sign)(SSL *ssl, uint8_t *out, size_t *out_len, |
| 1404 |
size_t max_out, |
| 1405 |
uint16_t signature_algorithm, |
| 1406 |
const uint8_t *in, size_t in_len); |
| 1407 |
|
| 1408 |
// decrypt decrypts |in_len| bytes of encrypted data from |in|. On success it |
| 1409 |
// returns |ssl_private_key_success|, writes at most |max_out| bytes of |
| 1410 |
// decrypted data to |out| and sets |*out_len| to the actual number of bytes |
| 1411 |
// written. On failure it returns |ssl_private_key_failure|. If the operation |
| 1412 |
// has not completed, it returns |ssl_private_key_retry|. The caller should |
| 1413 |
// arrange for the high-level operation on |ssl| to be retried when the |
| 1414 |
// operation is completed, which will result in a call to |complete|. This |
| 1415 |
// function only works with RSA keys and should perform a raw RSA decryption |
| 1416 |
// operation with no padding. |
| 1417 |
// |
| 1418 |
// It is an error to call |decrypt| while another private key operation is in |
| 1419 |
// progress on |ssl|. |
| 1420 |
enum ssl_private_key_result_t (*decrypt)(SSL *ssl, uint8_t *out, |
| 1421 |
size_t *out_len, size_t max_out, |
| 1422 |
const uint8_t *in, size_t in_len); |
| 1423 |
|
| 1424 |
// complete completes a pending operation. If the operation has completed, it |
| 1425 |
// returns |ssl_private_key_success| and writes the result to |out| as in |
| 1426 |
// |sign|. Otherwise, it returns |ssl_private_key_failure| on failure and |
| 1427 |
// |ssl_private_key_retry| if the operation is still in progress. |
| 1428 |
// |
| 1429 |
// |complete| may be called arbitrarily many times before completion, but it |
| 1430 |
// is an error to call |complete| if there is no pending operation in progress |
| 1431 |
// on |ssl|. |
| 1432 |
enum ssl_private_key_result_t (*complete)(SSL *ssl, uint8_t *out, |
| 1433 |
size_t *out_len, size_t max_out); |
| 1434 |
}; |
| 1435 |
|
| 1436 |
// SSL_set_private_key_method configures a custom private key on |ssl|. |
| 1437 |
// |key_method| must remain valid for the lifetime of |ssl|. Using custom |
| 1438 |
// keys with the multiple certificate slots feature is not supported. |
| 1439 |
OPENSSL_EXPORT void SSL_set_private_key_method( |
| 1440 |
SSL *ssl, const SSL_PRIVATE_KEY_METHOD *key_method); |
| 1441 |
|
| 1442 |
// SSL_CTX_set_private_key_method configures a custom private key on |ctx|. |
| 1443 |
// |key_method| must remain valid for the lifetime of |ctx|. |
| 1444 |
OPENSSL_EXPORT void SSL_CTX_set_private_key_method( |
| 1445 |
SSL_CTX *ctx, const SSL_PRIVATE_KEY_METHOD *key_method); |
| 1446 |
|
| 1447 |
// SSL_can_release_private_key returns one if |ssl| will no longer call into the |
| 1448 |
// private key and zero otherwise. If the function returns one, the caller can |
| 1449 |
// release state associated with the private key. |
| 1450 |
// |
| 1451 |
// NOTE: This function assumes the caller does not use |SSL_clear| to reuse |
| 1452 |
// |ssl| for a second connection. If |SSL_clear| is used, BoringSSL may still |
| 1453 |
// use the private key on the second connection. |
| 1454 |
OPENSSL_EXPORT int SSL_can_release_private_key(const SSL *ssl); |
| 1455 |
|
| 1456 |
|
| 1457 |
// Cipher suites. |
| 1458 |
// |
| 1459 |
// |SSL_CIPHER| objects represent cipher suites. |
| 1460 |
|
| 1461 |
DEFINE_CONST_STACK_OF(SSL_CIPHER) |
| 1462 |
|
| 1463 |
// SSL_get_cipher_by_value returns the structure representing a TLS cipher |
| 1464 |
// suite based on its assigned number, or NULL if unknown. See |
| 1465 |
// https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4. |
| 1466 |
OPENSSL_EXPORT const SSL_CIPHER *SSL_get_cipher_by_value(uint16_t value); |
| 1467 |
|
| 1468 |
// SSL_CIPHER_find returns a SSL_CIPHER structure which has the cipher ID stored in ptr or |
| 1469 |
// NULL if unknown. The ptr parameter is a two element array of char, which stores the |
| 1470 |
// two-byte TLS cipher ID (as allocated by IANA) in network byte order. SSL_CIPHER_find re-casts |
| 1471 |
// |ptr| to uint16_t and calls |SSL_get_cipher_by_value| to get the SSL_CIPHER structure. |
| 1472 |
OPENSSL_EXPORT const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr); |
| 1473 |
|
| 1474 |
// SSL_CIPHER_get_id returns |cipher|'s non-IANA id. This is not its |
| 1475 |
// IANA-assigned number, which is called the "value" here, although it may be |
| 1476 |
// cast to a |uint16_t| to get it. |
| 1477 |
OPENSSL_EXPORT uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *cipher); |
| 1478 |
|
| 1479 |
// SSL_CIPHER_get_protocol_id returns |cipher|'s IANA-assigned number. |
| 1480 |
OPENSSL_EXPORT uint16_t SSL_CIPHER_get_protocol_id(const SSL_CIPHER *cipher); |
| 1481 |
|
| 1482 |
// SSL_CIPHER_is_aead returns one if |cipher| uses an AEAD cipher. |
| 1483 |
OPENSSL_EXPORT int SSL_CIPHER_is_aead(const SSL_CIPHER *cipher); |
| 1484 |
|
| 1485 |
// SSL_CIPHER_is_block_cipher returns one if |cipher| is a block cipher. |
| 1486 |
OPENSSL_EXPORT int SSL_CIPHER_is_block_cipher(const SSL_CIPHER *cipher); |
| 1487 |
|
| 1488 |
// SSL_CIPHER_get_cipher_nid returns the NID for |cipher|'s bulk |
| 1489 |
// cipher. Possible values are |NID_aes_128_gcm|, |NID_aes_256_gcm|, |
| 1490 |
// |NID_chacha20_poly1305|, |NID_aes_128_cbc|, |NID_aes_256_cbc|, and |
| 1491 |
// |NID_des_ede3_cbc|. |
| 1492 |
OPENSSL_EXPORT int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *cipher); |
| 1493 |
|
| 1494 |
// SSL_CIPHER_get_digest_nid returns the NID for |cipher|'s HMAC if it is a |
| 1495 |
// legacy cipher suite. For modern AEAD-based ciphers (see |
| 1496 |
// |SSL_CIPHER_is_aead|), it returns |NID_undef|. |
| 1497 |
// |
| 1498 |
// Note this function only returns the legacy HMAC digest, not the PRF hash. |
| 1499 |
OPENSSL_EXPORT int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *cipher); |
| 1500 |
|
| 1501 |
// SSL_CIPHER_get_kx_nid returns the NID for |cipher|'s key exchange. This may |
| 1502 |
// be |NID_kx_rsa|, |NID_kx_ecdhe|, or |NID_kx_psk| for TLS 1.2. In TLS 1.3, |
| 1503 |
// cipher suites do not specify the key exchange, so this function returns |
| 1504 |
// |NID_kx_any|. |
| 1505 |
OPENSSL_EXPORT int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *cipher); |
| 1506 |
|
| 1507 |
// SSL_CIPHER_get_auth_nid returns the NID for |cipher|'s authentication |
| 1508 |
// type. This may be |NID_auth_rsa|, |NID_auth_ecdsa|, or |NID_auth_psk| for TLS |
| 1509 |
// 1.2. In TLS 1.3, cipher suites do not specify authentication, so this |
| 1510 |
// function returns |NID_auth_any|. |
| 1511 |
OPENSSL_EXPORT int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *cipher); |
| 1512 |
|
| 1513 |
// SSL_CIPHER_get_handshake_digest returns |cipher|'s PRF hash. If |cipher| |
| 1514 |
// is a pre-TLS-1.2 cipher, it returns |EVP_md5_sha1| but note these ciphers use |
| 1515 |
// SHA-256 in TLS 1.2. Other return values may be treated uniformly in all |
| 1516 |
// applicable versions. |
| 1517 |
OPENSSL_EXPORT const EVP_MD *SSL_CIPHER_get_handshake_digest( |
| 1518 |
const SSL_CIPHER *cipher); |
| 1519 |
|
| 1520 |
// SSL_CIPHER_get_prf_nid behaves like |SSL_CIPHER_get_handshake_digest| but |
| 1521 |
// returns the NID constant. Use |SSL_CIPHER_get_handshake_digest| instead. |
| 1522 |
OPENSSL_EXPORT int SSL_CIPHER_get_prf_nid(const SSL_CIPHER *cipher); |
| 1523 |
|
| 1524 |
// SSL_CIPHER_get_min_version returns the minimum protocol version required |
| 1525 |
// for |cipher|. |
| 1526 |
OPENSSL_EXPORT uint16_t SSL_CIPHER_get_min_version(const SSL_CIPHER *cipher); |
| 1527 |
|
| 1528 |
// SSL_CIPHER_get_max_version returns the maximum protocol version that |
| 1529 |
// supports |cipher|. |
| 1530 |
OPENSSL_EXPORT uint16_t SSL_CIPHER_get_max_version(const SSL_CIPHER *cipher); |
| 1531 |
|
| 1532 |
// SSL_CIPHER_standard_name returns the standard IETF name for |cipher|. For |
| 1533 |
// example, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256". |
| 1534 |
OPENSSL_EXPORT const char *SSL_CIPHER_standard_name(const SSL_CIPHER *cipher); |
| 1535 |
|
| 1536 |
// SSL_CIPHER_get_name returns the OpenSSL name of |cipher|. For example, |
| 1537 |
// "ECDHE-RSA-AES128-GCM-SHA256". Callers are recommended to use |
| 1538 |
// |SSL_CIPHER_standard_name| instead. |
| 1539 |
OPENSSL_EXPORT const char *SSL_CIPHER_get_name(const SSL_CIPHER *cipher); |
| 1540 |
|
| 1541 |
// SSL_CIPHER_get_kx_name returns a string that describes the key-exchange |
| 1542 |
// method used by |cipher|. For example, "ECDHE_ECDSA". TLS 1.3 AEAD-only |
| 1543 |
// ciphers return the string "GENERIC". |
| 1544 |
OPENSSL_EXPORT const char *SSL_CIPHER_get_kx_name(const SSL_CIPHER *cipher); |
| 1545 |
|
| 1546 |
// SSL_CIPHER_get_bits returns the strength, in bits, of |cipher|. If |
| 1547 |
// |out_alg_bits| is not NULL, it writes the number of bits consumed by the |
| 1548 |
// symmetric algorithm to |*out_alg_bits|. |
| 1549 |
OPENSSL_EXPORT int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, |
| 1550 |
int *out_alg_bits); |
| 1551 |
|
| 1552 |
// SSL_get_all_cipher_names outputs a list of possible strings |
| 1553 |
// |SSL_CIPHER_get_name| may return in this version of BoringSSL. It writes at |
| 1554 |
// most |max_out| entries to |out| and returns the total number it would have |
| 1555 |
// written, if |max_out| had been large enough. |max_out| may be initially set |
| 1556 |
// to zero to size the output. |
| 1557 |
// |
| 1558 |
// This function is only intended to help initialize tables in callers that want |
| 1559 |
// possible strings pre-declared. This list would not be suitable to set a list |
| 1560 |
// of supported features. It is in no particular order, and may contain |
| 1561 |
// placeholder, experimental, or deprecated values that do not apply to every |
| 1562 |
// caller. Future versions of BoringSSL may also return strings not in this |
| 1563 |
// list, so this does not apply if, say, sending strings across services. |
| 1564 |
OPENSSL_EXPORT size_t SSL_get_all_cipher_names(const char **out, |
| 1565 |
size_t max_out); |
| 1566 |
|
| 1567 |
|
| 1568 |
// SSL_get_all_standard_cipher_names outputs a list of possible strings |
| 1569 |
// |SSL_CIPHER_standard_name| may return in this version of BoringSSL. It writes |
| 1570 |
// at most |max_out| entries to |out| and returns the total number it would have |
| 1571 |
// written, if |max_out| had been large enough. |max_out| may be initially set |
| 1572 |
// to zero to size the output. |
| 1573 |
// |
| 1574 |
// This function is only intended to help initialize tables in callers that want |
| 1575 |
// possible strings pre-declared. This list would not be suitable to set a list |
| 1576 |
// of supported features. It is in no particular order, and may contain |
| 1577 |
// placeholder, experimental, or deprecated values that do not apply to every |
| 1578 |
// caller. Future versions of BoringSSL may also return strings not in this |
| 1579 |
// list, so this does not apply if, say, sending strings across services. |
| 1580 |
OPENSSL_EXPORT size_t SSL_get_all_standard_cipher_names(const char **out, |
| 1581 |
size_t max_out); |
| 1582 |
|
| 1583 |
|
| 1584 |
// Cipher suite configuration. |
| 1585 |
// |
| 1586 |
// OpenSSL uses a mini-language to configure cipher suites. The language |
| 1587 |
// maintains an ordered list of enabled ciphers, along with an ordered list of |
| 1588 |
// disabled but available ciphers. Initially, all ciphers are disabled with a |
| 1589 |
// default ordering. The cipher string is then interpreted as a sequence of |
| 1590 |
// directives, separated by colons, each of which modifies this state. |
| 1591 |
// |
| 1592 |
// Most directives consist of a one character or empty opcode followed by a |
| 1593 |
// selector which matches a subset of available ciphers. |
| 1594 |
// |
| 1595 |
// Available opcodes are: |
| 1596 |
// |
| 1597 |
// - The empty opcode enables and appends all matching disabled ciphers to the |
| 1598 |
// end of the enabled list. The newly appended ciphers are ordered relative to |
| 1599 |
// each other matching their order in the disabled list. |
| 1600 |
// |
| 1601 |
// - |-| disables all matching enabled ciphers and prepends them to the disabled |
| 1602 |
// list, with relative order from the enabled list preserved. This means the |
| 1603 |
// most recently disabled ciphers get highest preference relative to other |
| 1604 |
// disabled ciphers if re-enabled. |
| 1605 |
// |
| 1606 |
// - |+| moves all matching enabled ciphers to the end of the enabled list, with |
| 1607 |
// relative order preserved. |
| 1608 |
// |
| 1609 |
// - |!| deletes all matching ciphers, enabled or not, from either list. Deleted |
| 1610 |
// ciphers will not matched by future operations. |
| 1611 |
// |
| 1612 |
// A selector may be a specific cipher (using either the standard or OpenSSL |
| 1613 |
// name for the cipher) or one or more rules separated by |+|. The final |
| 1614 |
// selector matches the intersection of each rule. For instance, |AESGCM+aECDSA| |
| 1615 |
// matches ECDSA-authenticated AES-GCM ciphers. |
| 1616 |
// |
| 1617 |
// Available cipher rules are: |
| 1618 |
// |
| 1619 |
// - |ALL| matches all ciphers. |
| 1620 |
// |
| 1621 |
// - |kRSA|, |kDHE|, |kECDHE|, and |kPSK| match ciphers using plain RSA, DHE, |
| 1622 |
// ECDHE, and plain PSK key exchanges, respectively. Note that ECDHE_PSK is |
| 1623 |
// matched by |kECDHE| and not |kPSK|. |
| 1624 |
// |
| 1625 |
// - |aRSA|, |aECDSA|, and |aPSK| match ciphers authenticated by RSA, ECDSA, and |
| 1626 |
// a pre-shared key, respectively. |
| 1627 |
// |
| 1628 |
// - |RSA|, |DHE|, |ECDHE|, |PSK|, |ECDSA|, and |PSK| are aliases for the |
| 1629 |
// corresponding |k*| or |a*| cipher rule. |RSA| is an alias for |kRSA|, not |
| 1630 |
// |aRSA|. |
| 1631 |
// |
| 1632 |
// - |3DES|, |AES128|, |AES256|, |AES|, |AESGCM|, |CHACHA20| match ciphers |
| 1633 |
// whose bulk cipher use the corresponding encryption scheme. Note that |
| 1634 |
// |AES|, |AES128|, and |AES256| match both CBC and GCM ciphers. |
| 1635 |
// |
| 1636 |
// - |SHA1|, and its alias |SHA|, match legacy cipher suites using HMAC-SHA1. |
| 1637 |
// |
| 1638 |
// Although implemented, authentication-only ciphers match no rules and must be |
| 1639 |
// explicitly selected by name. |
| 1640 |
// |
| 1641 |
// Deprecated cipher rules: |
| 1642 |
// |
| 1643 |
// - |kEDH|, |EDH|, |kEECDH|, and |EECDH| are legacy aliases for |kDHE|, |DHE|, |
| 1644 |
// |kECDHE|, and |ECDHE|, respectively. |
| 1645 |
// |
| 1646 |
// - |HIGH| is an alias for |ALL|. |
| 1647 |
// |
| 1648 |
// - |FIPS| is an alias for |HIGH|. |
| 1649 |
// |
| 1650 |
// - |SSLv3| and |TLSv1| match ciphers available in TLS 1.1 or earlier. |
| 1651 |
// |TLSv1_2| matches ciphers new in TLS 1.2. This is confusing and should not |
| 1652 |
// be used. |
| 1653 |
// |
| 1654 |
// Unknown rules are silently ignored by legacy APIs, and rejected by APIs with |
| 1655 |
// "strict" in the name, which should be preferred. Cipher lists can be long |
| 1656 |
// and it's easy to commit typos. Strict functions will also reject the use of |
| 1657 |
// spaces, semi-colons and commas as alternative separators. |
| 1658 |
// |
| 1659 |
// The special |@STRENGTH| directive will sort all enabled ciphers by strength. |
| 1660 |
// |
| 1661 |
// The |DEFAULT| directive, when appearing at the front of the string, expands |
| 1662 |
// to the default ordering of available ciphers. |
| 1663 |
// |
| 1664 |
// For TLS < 1.3, if configuring a server, one may also configure |
| 1665 |
// equal-preference groups to partially respect the client's preferences when |
| 1666 |
// |SSL_OP_CIPHER_SERVER_PREFERENCE| is enabled. Ciphers in an equal-preference |
| 1667 |
// group have equal priority and use the client order. This may be used to |
| 1668 |
// enforce that AEADs are preferred but select AES-GCM vs. ChaCha20-Poly1305 |
| 1669 |
// based on client preferences. An equal-preference is specified with square |
| 1670 |
// brackets, combining multiple selectors separated by |. For example: |
| 1671 |
// |
| 1672 |
// [TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256|TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256] |
| 1673 |
// |
| 1674 |
// Once an equal-preference group is used, future directives must be |
| 1675 |
// opcode-less. Inside an equal-preference group, spaces are not allowed. |
| 1676 |
|
| 1677 |
// SSL_DEFAULT_CIPHER_LIST is the default cipher suite configuration. It is |
| 1678 |
// substituted when a cipher string starts with 'DEFAULT'. |
| 1679 |
#define SSL_DEFAULT_CIPHER_LIST "ALL" |
| 1680 |
|
| 1681 |
|
| 1682 |
// SSL_CTX_set_strict_cipher_list configures the cipher list for |ctx|, |
| 1683 |
// evaluating |str| as a cipher string and returning error if |str| contains |
| 1684 |
// anything meaningless. It updates |ctx->cipher_list| with any values in |
| 1685 |
// |ctx->tls13_cipher_list|. |
| 1686 |
// |
| 1687 |
// It returns one on success and zero on failure. |
| 1688 |
OPENSSL_EXPORT int SSL_CTX_set_strict_cipher_list(SSL_CTX *ctx, |
| 1689 |
const char *str); |
| 1690 |
|
| 1691 |
// SSL_CTX_set_cipher_list configures the cipher list for |ctx|, evaluating |
| 1692 |
// |str| as a cipher string. It updates |ctx->cipher_list| with any values in |
| 1693 |
// |ctx->tls13_cipher_list|. It returns one on success and zero on failure. |
| 1694 |
// |
| 1695 |
// Prefer to use |SSL_CTX_set_strict_cipher_list|. This function tolerates |
| 1696 |
// garbage inputs, unless an empty cipher list results. However, an empty |
| 1697 |
// string which also results in an empty cipher list, is allowed. This |
| 1698 |
// behavior is strongly advised against and only meant for OpenSSL |
| 1699 |
// compatibility. |
| 1700 |
// |
| 1701 |
// Note: this API only sets the TLSv1.2 and below ciphers. |
| 1702 |
// Use |SSL_CTX_set_ciphersuites| to configure TLS 1.3 specific ciphers. |
| 1703 |
OPENSSL_EXPORT int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str); |
| 1704 |
|
| 1705 |
// SSL_set_strict_cipher_list configures the cipher list for |ssl|, evaluating |
| 1706 |
// |str| as a cipher string and returning error if |str| contains anything |
| 1707 |
// meaningless. |
| 1708 |
// It updates the cipher list |ssl->config->cipher_list| with any configured |
| 1709 |
// TLS 1.3 cipher suites by first checking |ssl->config->tls13_cipher_list| and |
| 1710 |
// otherwise falling back to |ssl->ctx->tls13_cipher_list|. |
| 1711 |
// |
| 1712 |
// It returns one on success and zero on failure. |
| 1713 |
OPENSSL_EXPORT int SSL_set_strict_cipher_list(SSL *ssl, const char *str); |
| 1714 |
|
| 1715 |
// SSL_CTX_set_ciphersuites configures the available TLSv1.3 ciphersuites on |
| 1716 |
// |ctx|, evaluating |str| as a cipher string. It updates |ctx->cipher_list| |
| 1717 |
// with any values in |ctx->tls13_cipher_list|. It returns one on success and |
| 1718 |
// zero on failure. |
| 1719 |
OPENSSL_EXPORT int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str); |
| 1720 |
|
| 1721 |
// SSL_set_ciphersuites configures the available TLSv1.3 ciphersuites on |
| 1722 |
// |ssl|, evaluating |str| as a cipher string. It updates |
| 1723 |
// |ssl->config->cipher_list| with any values in |
| 1724 |
// |ssl->config->tls13_cipher_list|. It returns one on success and zero on |
| 1725 |
// failure. |
| 1726 |
OPENSSL_EXPORT int SSL_set_ciphersuites(SSL *ssl, const char *str); |
| 1727 |
|
| 1728 |
// SSL_set_cipher_list configures the cipher list for |ssl|, evaluating |str| as |
| 1729 |
// a cipher string. It updates the cipher list |ssl->config->cipher_list| with |
| 1730 |
// any configured TLS 1.3 cipher suites by first checking |
| 1731 |
// |ssl->config->tls13_cipher_list| and otherwise falling back to |
| 1732 |
// |ssl->ctx->tls13_cipher_list|. |
| 1733 |
// |
| 1734 |
// Equal-preference groups cannot be configured for TLS 1.3 through these APIs. |
| 1735 |
// |
| 1736 |
// It returns one on success and zero on failure. |
| 1737 |
// |
| 1738 |
// Prefer to use |SSL_set_strict_cipher_list|. This function tolerates garbage |
| 1739 |
// inputs, unless an empty cipher list results. However, an empty string which |
| 1740 |
// also results in an empty cipher list, is allowed. This behavior is strongly |
| 1741 |
// advised against and only meant for OpenSSL compatibility. |
| 1742 |
OPENSSL_EXPORT int SSL_set_cipher_list(SSL *ssl, const char *str); |
| 1743 |
|
| 1744 |
// SSL_CTX_get_ciphers returns the cipher list for |ctx|, in order of |
| 1745 |
// preference. This includes TLS 1.3 and 1.2 and below cipher suites. |
| 1746 |
OPENSSL_EXPORT STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx); |
| 1747 |
|
| 1748 |
// SSL_CTX_cipher_in_group returns one if the |i|th cipher (see |
| 1749 |
// |SSL_CTX_get_ciphers|) is in the same equipreference group as the one |
| 1750 |
// following it and zero otherwise. |
| 1751 |
OPENSSL_EXPORT int SSL_CTX_cipher_in_group(const SSL_CTX *ctx, size_t i); |
| 1752 |
|
| 1753 |
// SSL_get_ciphers returns the cipher list for |ssl|, in order of preference. |
| 1754 |
// This includes TLS 1.3 and 1.2 and below cipher suites. |
| 1755 |
OPENSSL_EXPORT STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *ssl); |
| 1756 |
|
| 1757 |
|
| 1758 |
// Connection information. |
| 1759 |
|
| 1760 |
// SSL_in_connect_init returns 1 if |ssl| is a client and has a pending |
| 1761 |
// handshake. Otherwise, it returns 0. |
| 1762 |
OPENSSL_EXPORT int SSL_in_connect_init(const SSL *ssl); |
| 1763 |
|
| 1764 |
// SSL_in_accept_init returns 1 if |ssl| is a server and has a pending |
| 1765 |
// handshake. Otherwise, it returns 0. |
| 1766 |
OPENSSL_EXPORT int SSL_in_accept_init(const SSL *ssl); |
| 1767 |
|
| 1768 |
// SSL_is_init_finished returns one if |ssl| has completed its initial handshake |
| 1769 |
// and has no pending handshake. It returns zero otherwise. |
| 1770 |
OPENSSL_EXPORT int SSL_is_init_finished(const SSL *ssl); |
| 1771 |
|
| 1772 |
// SSL_in_init returns one if |ssl| has a pending handshake and zero |
| 1773 |
// otherwise. |
| 1774 |
OPENSSL_EXPORT int SSL_in_init(const SSL *ssl); |
| 1775 |
|
| 1776 |
// SSL_in_false_start returns one if |ssl| has a pending handshake that is in |
| 1777 |
// False Start. |SSL_write| may be called at this point without waiting for the |
| 1778 |
// peer, but |SSL_read| will complete the handshake before accepting application |
| 1779 |
// data. |
| 1780 |
// |
| 1781 |
// See also |SSL_MODE_ENABLE_FALSE_START|. |
| 1782 |
OPENSSL_EXPORT int SSL_in_false_start(const SSL *ssl); |
| 1783 |
|
| 1784 |
// SSL_get_peer_certificate returns the peer's leaf certificate or NULL if the |
| 1785 |
// peer did not use certificates. The caller must call |X509_free| on the |
| 1786 |
// result to release it. |
| 1787 |
OPENSSL_EXPORT X509 *SSL_get_peer_certificate(const SSL *ssl); |
| 1788 |
|
| 1789 |
// SSL_get_peer_cert_chain returns the peer's certificate chain or NULL if |
| 1790 |
// unavailable or the peer did not use certificates. This is the unverified list |
| 1791 |
// of certificates as sent by the peer, not the final chain built during |
| 1792 |
// verification. The caller does not take ownership of the result. |
| 1793 |
// |
| 1794 |
// WARNING: This function behaves differently between client and server. If |
| 1795 |
// |ssl| is a server, the returned chain does not include the leaf certificate. |
| 1796 |
// If a client, it does. |
| 1797 |
OPENSSL_EXPORT STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *ssl); |
| 1798 |
|
| 1799 |
// SSL_get_peer_full_cert_chain returns the peer's certificate chain, or NULL if |
| 1800 |
// unavailable or the peer did not use certificates. This is the unverified list |
| 1801 |
// of certificates as sent by the peer, not the final chain built during |
| 1802 |
// verification. The caller does not take ownership of the result. |
| 1803 |
// |
| 1804 |
// This is the same as |SSL_get_peer_cert_chain| except that this function |
| 1805 |
// always returns the full chain, i.e. the first element of the return value |
| 1806 |
// (if any) will be the leaf certificate. In contrast, |
| 1807 |
// |SSL_get_peer_cert_chain| returns only the intermediate certificates if the |
| 1808 |
// |ssl| is a server. |
| 1809 |
OPENSSL_EXPORT STACK_OF(X509) *SSL_get_peer_full_cert_chain(const SSL *ssl); |
| 1810 |
|
| 1811 |
// SSL_get0_verified_chain returns the verified certificate chain of the peer |
| 1812 |
// including the peer's end entity certificate. It must be called after a |
| 1813 |
// session has been successfully established. If peer verification was not |
| 1814 |
// successful (as indicated by |SSL_get_verify_result| not returning |
| 1815 |
// |X509_V_OK|) the result will be null. If a verification callback was set with |
| 1816 |
// |SSL_CTX_set_cert_verify_callback| or |SSL_set_custom_verify| |
| 1817 |
// this function's behavior is undefined. |
| 1818 |
OPENSSL_EXPORT STACK_OF(X509) *SSL_get0_verified_chain(const SSL *ssl); |
| 1819 |
|
| 1820 |
// SSL_get0_peer_certificates returns the peer's certificate chain, or NULL if |
| 1821 |
// unavailable or the peer did not use certificates. This is the unverified list |
| 1822 |
// of certificates as sent by the peer, not the final chain built during |
| 1823 |
// verification. The caller does not take ownership of the result. |
| 1824 |
// |
| 1825 |
// This is the |CRYPTO_BUFFER| variant of |SSL_get_peer_full_cert_chain|. |
| 1826 |
OPENSSL_EXPORT const STACK_OF(CRYPTO_BUFFER) *SSL_get0_peer_certificates( |
| 1827 |
const SSL *ssl); |
| 1828 |
|
| 1829 |
// SSL_get0_signed_cert_timestamp_list sets |*out| and |*out_len| to point to |
| 1830 |
// |*out_len| bytes of SCT information from the server. This is only valid if |
| 1831 |
// |ssl| is a client. The SCT information is a SignedCertificateTimestampList |
| 1832 |
// (including the two leading length bytes). |
| 1833 |
// See https://tools.ietf.org/html/rfc6962#section-3.3 |
| 1834 |
// If no SCT was received then |*out_len| will be zero on return. |
| 1835 |
// |
| 1836 |
// WARNING: the returned data is not guaranteed to be well formed. |
| 1837 |
OPENSSL_EXPORT void SSL_get0_signed_cert_timestamp_list(const SSL *ssl, |
| 1838 |
const uint8_t **out, |
| 1839 |
size_t *out_len); |
| 1840 |
|
| 1841 |
// SSL_get0_ocsp_response sets |*out| and |*out_len| to point to |*out_len| |
| 1842 |
// bytes of an OCSP response from the server. This is the DER encoding of an |
| 1843 |
// OCSPResponse type as defined in RFC 2560. |
| 1844 |
// |
| 1845 |
// WARNING: the returned data is not guaranteed to be well formed. |
| 1846 |
OPENSSL_EXPORT void SSL_get0_ocsp_response(const SSL *ssl, const uint8_t **out, |
| 1847 |
size_t *out_len); |
| 1848 |
|
| 1849 |
// SSL_get_tls_unique writes at most |max_out| bytes of the tls-unique value |
| 1850 |
// for |ssl| to |out| and sets |*out_len| to the number of bytes written. It |
| 1851 |
// returns one on success or zero on error. In general |max_out| should be at |
| 1852 |
// least 12. |
| 1853 |
// |
| 1854 |
// This function will always fail if the initial handshake has not completed. |
| 1855 |
// The tls-unique value will change after a renegotiation but, since |
| 1856 |
// renegotiations can be initiated by the server at any point, the higher-level |
| 1857 |
// protocol must either leave them disabled or define states in which the |
| 1858 |
// tls-unique value can be read. |
| 1859 |
// |
| 1860 |
// The tls-unique value is defined by |
| 1861 |
// https://tools.ietf.org/html/rfc5929#section-3.1. Due to a weakness in the |
| 1862 |
// TLS protocol, tls-unique is broken for resumed connections unless the |
| 1863 |
// Extended Master Secret extension is negotiated. Thus this function will |
| 1864 |
// return zero if |ssl| performed session resumption unless EMS was used when |
| 1865 |
// negotiating the original session. |
| 1866 |
OPENSSL_EXPORT int SSL_get_tls_unique(const SSL *ssl, uint8_t *out, |
| 1867 |
size_t *out_len, size_t max_out); |
| 1868 |
|
| 1869 |
// SSL_get_extms_support returns one if the Extended Master Secret extension or |
| 1870 |
// TLS 1.3 was negotiated. Otherwise, it returns zero. |
| 1871 |
OPENSSL_EXPORT int SSL_get_extms_support(const SSL *ssl); |
| 1872 |
|
| 1873 |
// SSL_get_current_cipher returns cipher suite used by |ssl|, or NULL if it has |
| 1874 |
// not been negotiated yet. |
| 1875 |
OPENSSL_EXPORT const SSL_CIPHER *SSL_get_current_cipher(const SSL *ssl); |
| 1876 |
|
| 1877 |
// SSL_get_client_ciphers returns the stack of ciphers offered by the client |
| 1878 |
// during a handshake and that are supported by this library. If |ssl| is a |
| 1879 |
// client or the handshake hasn't occurred yet, NULL is returned. The stack of |
| 1880 |
// ciphers IS NOT de/serialized, so NULL will also be returned for deserialized |
| 1881 |
// or transported |ssl|'s that haven't yet performed a new handshake. |
| 1882 |
OPENSSL_EXPORT STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *ssl); |
| 1883 |
|
| 1884 |
// SSL_client_hello_get0_ciphers provides access to the client ciphers field from the |
| 1885 |
// Client Hello, optionally writing the result to an out pointer. It returns the field |
| 1886 |
// length if successful, or 0 if |ssl| is a client or the handshake hasn't occurred yet. |
| 1887 |
// |out| points to the raw bytes from the client hello message so it may contain invalid |
| 1888 |
// or unsupported Cipher IDs. |
| 1889 |
OPENSSL_EXPORT size_t SSL_client_hello_get0_ciphers(SSL *ssl, const unsigned char **out); |
| 1890 |
|
| 1891 |
// SSL_session_reused returns one if |ssl| performed an abbreviated handshake |
| 1892 |
// and zero otherwise. |
| 1893 |
// |
| 1894 |
// TODO(davidben): Hammer down the semantics of this API while a handshake, |
| 1895 |
// initial or renego, is in progress. |
| 1896 |
OPENSSL_EXPORT int SSL_session_reused(const SSL *ssl); |
| 1897 |
|
| 1898 |
// SSL_get_secure_renegotiation_support returns one if the peer supports secure |
| 1899 |
// renegotiation (RFC 5746) or TLS 1.3. Otherwise, it returns zero. |
| 1900 |
OPENSSL_EXPORT int SSL_get_secure_renegotiation_support(const SSL *ssl); |
| 1901 |
|
| 1902 |
// SSL_export_keying_material exports a value derived from the master secret, as |
| 1903 |
// specified in RFC 5705. It writes |out_len| bytes to |out| given a label and |
| 1904 |
// optional context. (Since a zero length context is allowed, the |use_context| |
| 1905 |
// flag controls whether a context is included.) |
| 1906 |
// |
| 1907 |
// It returns one on success and zero otherwise. |
| 1908 |
OPENSSL_EXPORT int SSL_export_keying_material( |
| 1909 |
SSL *ssl, uint8_t *out, size_t out_len, const char *label, size_t label_len, |
| 1910 |
const uint8_t *context, size_t context_len, int use_context); |
| 1911 |
|
| 1912 |
|
| 1913 |
// Custom extensions. |
| 1914 |
// |
| 1915 |
// The custom extension functions allow TLS extensions to be added to |
| 1916 |
// ClientHello and ServerHello messages. |
| 1917 |
|
| 1918 |
// SSL_custom_ext_add_cb is a callback function that is called when the |
| 1919 |
// ClientHello (for clients) or ServerHello (for servers) is constructed. In |
| 1920 |
// the case of a server, this callback will only be called for a given |
| 1921 |
// extension if the ClientHello contained that extension – it's not possible to |
| 1922 |
// inject extensions into a ServerHello that the client didn't request. |
| 1923 |
// |
| 1924 |
// When called, |extension_value| will contain the extension number that is |
| 1925 |
// being considered for addition (so that a single callback can handle multiple |
| 1926 |
// extensions). If the callback wishes to include the extension, it must set |
| 1927 |
// |*out| to point to |*out_len| bytes of extension contents and return one. In |
| 1928 |
// this case, the corresponding |SSL_custom_ext_free_cb| callback will later be |
| 1929 |
// called with the value of |*out| once that data has been copied. |
| 1930 |
// |
| 1931 |
// If the callback does not wish to add an extension it must return zero. |
| 1932 |
// |
| 1933 |
// Alternatively, the callback can abort the connection by setting |
| 1934 |
// |*out_alert_value| to a TLS alert number and returning -1. |
| 1935 |
typedef int (*SSL_custom_ext_add_cb)(SSL *ssl, unsigned extension_value, |
| 1936 |
const uint8_t **out, size_t *out_len, |
| 1937 |
int *out_alert_value, void *add_arg); |
| 1938 |
|
| 1939 |
// SSL_custom_ext_free_cb is a callback function that is called by AWS-LC iff |
| 1940 |
// an |SSL_custom_ext_add_cb| callback previously returned one. In that case, |
| 1941 |
// this callback is called and passed the |out| pointer that was returned by |
| 1942 |
// the add callback. This is to free any dynamically allocated data created by |
| 1943 |
// the add callback. |
| 1944 |
typedef void (*SSL_custom_ext_free_cb)(SSL *ssl, unsigned extension_value, |
| 1945 |
const uint8_t *out, void *add_arg); |
| 1946 |
|
| 1947 |
// SSL_custom_ext_parse_cb is a callback function that is called by AWS-LC to |
| 1948 |
// parse an extension from the peer: that is from the ServerHello for a client |
| 1949 |
// and from the ClientHello for a server. |
| 1950 |
// |
| 1951 |
// When called, |extension_value| will contain the extension number and the |
| 1952 |
// contents of the extension are |contents_len| bytes at |contents|. |
| 1953 |
// |
| 1954 |
// The callback must return one to continue the handshake. Otherwise, if it |
| 1955 |
// returns zero, a fatal alert with value |*out_alert_value| is sent and the |
| 1956 |
// handshake is aborted. |
| 1957 |
typedef int (*SSL_custom_ext_parse_cb)(SSL *ssl, unsigned extension_value, |
| 1958 |
const uint8_t *contents, |
| 1959 |
size_t contents_len, |
| 1960 |
int *out_alert_value, void *parse_arg); |
| 1961 |
|
| 1962 |
// SSL_extension_supported returns one iff AWS-LC internally handles |
| 1963 |
// extensions of type |extension_value|. This can be used to avoid registering |
| 1964 |
// custom extension handlers for extensions that a future version of AWS-LC |
| 1965 |
// may handle internally. |
| 1966 |
OPENSSL_EXPORT int SSL_extension_supported(unsigned extension_value); |
| 1967 |
|
| 1968 |
// SSL_CTX_add_client_custom_ext registers callback functions for handling |
| 1969 |
// custom TLS extensions for client connections. |
| 1970 |
// |
| 1971 |
// If |add_cb| is NULL then an empty extension will be added in each |
| 1972 |
// ClientHello. Otherwise, see the comment for |SSL_custom_ext_add_cb| about |
| 1973 |
// this callback. |
| 1974 |
// |
| 1975 |
// The |free_cb| may be NULL if |add_cb| doesn't dynamically allocate data that |
| 1976 |
// needs to be freed. |
| 1977 |
// |
| 1978 |
// It returns one on success or zero on error. It's always an error to register |
| 1979 |
// callbacks for the same extension twice, or to register callbacks for an |
| 1980 |
// extension that AWS-LC handles internally. See |SSL_extension_supported| to |
| 1981 |
// discover, at runtime, which extensions AWS-LC handles internally. |
| 1982 |
OPENSSL_EXPORT int SSL_CTX_add_client_custom_ext( |
| 1983 |
SSL_CTX *ctx, unsigned extension_value, SSL_custom_ext_add_cb add_cb, |
| 1984 |
SSL_custom_ext_free_cb free_cb, void *add_arg, |
| 1985 |
SSL_custom_ext_parse_cb parse_cb, void *parse_arg); |
| 1986 |
|
| 1987 |
// SSL_CTX_add_server_custom_ext is the same as |
| 1988 |
// |SSL_CTX_add_client_custom_ext|, but for server connections. |
| 1989 |
// |
| 1990 |
// Unlike on the client side, if |add_cb| is NULL no extension will be added. |
| 1991 |
// The |add_cb|, if any, will only be called if the ClientHello contained a |
| 1992 |
// matching extension. |
| 1993 |
OPENSSL_EXPORT int SSL_CTX_add_server_custom_ext( |
| 1994 |
SSL_CTX *ctx, unsigned extension_value, SSL_custom_ext_add_cb add_cb, |
| 1995 |
SSL_custom_ext_free_cb free_cb, void *add_arg, |
| 1996 |
SSL_custom_ext_parse_cb parse_cb, void *parse_arg); |
| 1997 |
|
| 1998 |
|
| 1999 |
// Sessions. |
| 2000 |
// |
| 2001 |
// An |SSL_SESSION| represents an SSL session that may be resumed in an |
| 2002 |
// abbreviated handshake. It is reference-counted and immutable. Once |
| 2003 |
// established, an |SSL_SESSION| may be shared by multiple |SSL| objects on |
| 2004 |
// different threads and must not be modified. |
| 2005 |
// |
| 2006 |
// Note the TLS notion of "session" is not suitable for application-level |
| 2007 |
// session state. It is an optional caching mechanism for the handshake. Not all |
| 2008 |
// connections within an application-level session will reuse TLS sessions. TLS |
| 2009 |
// sessions may be dropped by the client or ignored by the server at any time. |
| 2010 |
|
| 2011 |
DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) |
| 2012 |
|
| 2013 |
// SSL_SESSION_new returns a newly-allocated blank |SSL_SESSION| or NULL on |
| 2014 |
// error. This may be useful when writing tests but should otherwise not be |
| 2015 |
// used. |
| 2016 |
OPENSSL_EXPORT SSL_SESSION *SSL_SESSION_new(const SSL_CTX *ctx); |
| 2017 |
|
| 2018 |
// SSL_SESSION_up_ref increments the reference count of |session| and returns |
| 2019 |
// one. |
| 2020 |
OPENSSL_EXPORT int SSL_SESSION_up_ref(SSL_SESSION *session); |
| 2021 |
|
| 2022 |
// SSL_SESSION_free decrements the reference count of |session|. If it reaches |
| 2023 |
// zero, all data referenced by |session| and |session| itself are released. |
| 2024 |
OPENSSL_EXPORT void SSL_SESSION_free(SSL_SESSION *session); |
| 2025 |
|
| 2026 |
// SSL_SESSION_to_bytes serializes |in| into a newly allocated buffer and sets |
| 2027 |
// |*out_data| to that buffer and |*out_len| to its length. The caller takes |
| 2028 |
// ownership of the buffer and must call |OPENSSL_free| when done. It returns |
| 2029 |
// one on success and zero on error. |
| 2030 |
OPENSSL_EXPORT int SSL_SESSION_to_bytes(const SSL_SESSION *in, |
| 2031 |
uint8_t **out_data, size_t *out_len); |
| 2032 |
|
| 2033 |
// SSL_SESSION_to_bytes_for_ticket serializes |in|, but excludes the session |
| 2034 |
// identification information, namely the session ID and ticket. |
| 2035 |
OPENSSL_EXPORT int SSL_SESSION_to_bytes_for_ticket(const SSL_SESSION *in, |
| 2036 |
uint8_t **out_data, |
| 2037 |
size_t *out_len); |
| 2038 |
|
| 2039 |
// SSL_SESSION_from_bytes parses |in_len| bytes from |in| as an SSL_SESSION. It |
| 2040 |
// returns a newly-allocated |SSL_SESSION| on success or NULL on error. |
| 2041 |
OPENSSL_EXPORT SSL_SESSION *SSL_SESSION_from_bytes(const uint8_t *in, |
| 2042 |
size_t in_len, |
| 2043 |
const SSL_CTX *ctx); |
| 2044 |
|
| 2045 |
// SSL_SESSION_get_version returns a string describing the TLS or DTLS version |
| 2046 |
// |session| was established at. For example, "TLSv1.2" or "DTLSv1". |
| 2047 |
OPENSSL_EXPORT const char *SSL_SESSION_get_version(const SSL_SESSION *session); |
| 2048 |
|
| 2049 |
// SSL_SESSION_get_protocol_version returns the TLS or DTLS version |session| |
| 2050 |
// was established at. |
| 2051 |
OPENSSL_EXPORT uint16_t |
| 2052 |
SSL_SESSION_get_protocol_version(const SSL_SESSION *session); |
| 2053 |
|
| 2054 |
// SSL_SESSION_set_protocol_version sets |session|'s TLS or DTLS version to |
| 2055 |
// |version|. This may be useful when writing tests but should otherwise not be |
| 2056 |
// used. It returns one on success and zero on error. |
| 2057 |
OPENSSL_EXPORT int SSL_SESSION_set_protocol_version(SSL_SESSION *session, |
| 2058 |
uint16_t version); |
| 2059 |
|
| 2060 |
// SSL_MAX_SSL_SESSION_ID_LENGTH is the maximum length of an SSL session ID. |
| 2061 |
#define SSL_MAX_SSL_SESSION_ID_LENGTH 32 |
| 2062 |
|
| 2063 |
// SSL_SESSION_get_id returns a pointer to a buffer containing |session|'s |
| 2064 |
// session ID and sets |*out_len| to its length. |
| 2065 |
// |
| 2066 |
// This function should only be used for implementing a TLS session cache. TLS |
| 2067 |
// sessions are not suitable for application-level session state, and a session |
| 2068 |
// ID is an implementation detail of the TLS resumption handshake mechanism. Not |
| 2069 |
// all resumption flows use session IDs, and not all connections within an |
| 2070 |
// application-level session will reuse TLS sessions. |
| 2071 |
// |
| 2072 |
// To determine if resumption occurred, use |SSL_session_reused| instead. |
| 2073 |
// Comparing session IDs will not give the right result in all cases. |
| 2074 |
// |
| 2075 |
// As a workaround for some broken applications, BoringSSL sometimes synthesizes |
| 2076 |
// arbitrary session IDs for non-ID-based sessions. This behavior may be |
| 2077 |
// removed in the future. |
| 2078 |
OPENSSL_EXPORT const uint8_t *SSL_SESSION_get_id(const SSL_SESSION *session, |
| 2079 |
unsigned *out_len); |
| 2080 |
|
| 2081 |
// SSL_SESSION_set1_id sets |session|'s session ID to |sid|, It returns one on |
| 2082 |
// success and zero on error. This function may be useful in writing tests but |
| 2083 |
// otherwise should not be used. |
| 2084 |
OPENSSL_EXPORT int SSL_SESSION_set1_id(SSL_SESSION *session, const uint8_t *sid, |
| 2085 |
size_t sid_len); |
| 2086 |
|
| 2087 |
// SSL_SESSION_get_time returns the time at which |session| was established in |
| 2088 |
// seconds since the UNIX epoch. |
| 2089 |
OPENSSL_EXPORT uint64_t SSL_SESSION_get_time(const SSL_SESSION *session); |
| 2090 |
|
| 2091 |
// SSL_SESSION_get_timeout returns the lifetime of |session| in seconds. |
| 2092 |
OPENSSL_EXPORT uint32_t SSL_SESSION_get_timeout(const SSL_SESSION *session); |
| 2093 |
|
| 2094 |
// SSL_SESSION_get0_peer returns the peer leaf certificate stored in |
| 2095 |
// |session|. |
| 2096 |
// |
| 2097 |
// TODO(davidben): This should return a const X509 *. |
| 2098 |
OPENSSL_EXPORT X509 *SSL_SESSION_get0_peer(const SSL_SESSION *session); |
| 2099 |
|
| 2100 |
// SSL_SESSION_get0_peer_certificates returns the peer certificate chain stored |
| 2101 |
// in |session|, or NULL if the peer did not use certificates. This is the |
| 2102 |
// unverified list of certificates as sent by the peer, not the final chain |
| 2103 |
// built during verification. The caller does not take ownership of the result. |
| 2104 |
OPENSSL_EXPORT const STACK_OF(CRYPTO_BUFFER) * |
| 2105 |
SSL_SESSION_get0_peer_certificates(const SSL_SESSION *session); |
| 2106 |
|
| 2107 |
// SSL_SESSION_get0_signed_cert_timestamp_list sets |*out| and |*out_len| to |
| 2108 |
// point to |*out_len| bytes of SCT information stored in |session|. This is |
| 2109 |
// only valid for client sessions. The SCT information is a |
| 2110 |
// SignedCertificateTimestampList (including the two leading length bytes). See |
| 2111 |
// https://tools.ietf.org/html/rfc6962#section-3.3 If no SCT was received then |
| 2112 |
// |*out_len| will be zero on return. |
| 2113 |
// |
| 2114 |
// WARNING: the returned data is not guaranteed to be well formed. |
| 2115 |
OPENSSL_EXPORT void SSL_SESSION_get0_signed_cert_timestamp_list( |
| 2116 |
const SSL_SESSION *session, const uint8_t **out, size_t *out_len); |
| 2117 |
|
| 2118 |
// SSL_SESSION_get0_ocsp_response sets |*out| and |*out_len| to point to |
| 2119 |
// |*out_len| bytes of an OCSP response from the server. This is the DER |
| 2120 |
// encoding of an OCSPResponse type as defined in RFC 2560. |
| 2121 |
// |
| 2122 |
// WARNING: the returned data is not guaranteed to be well formed. |
| 2123 |
OPENSSL_EXPORT void SSL_SESSION_get0_ocsp_response(const SSL_SESSION *session, |
| 2124 |
const uint8_t **out, |
| 2125 |
size_t *out_len); |
| 2126 |
|
| 2127 |
// SSL_MAX_MASTER_KEY_LENGTH is the maximum length of a master secret. |
| 2128 |
#define SSL_MAX_MASTER_KEY_LENGTH 48 |
| 2129 |
|
| 2130 |
// SSL_SESSION_get_master_key writes up to |max_out| bytes of |session|'s secret |
| 2131 |
// to |out| and returns the number of bytes written. If |max_out| is zero, it |
| 2132 |
// returns the size of the secret. |
| 2133 |
OPENSSL_EXPORT size_t SSL_SESSION_get_master_key(const SSL_SESSION *session, |
| 2134 |
uint8_t *out, size_t max_out); |
| 2135 |
|
| 2136 |
// SSL_SESSION_set_time sets |session|'s creation time to |time| and returns |
| 2137 |
// |time|. This function may be useful in writing tests but otherwise should not |
| 2138 |
// be used. |
| 2139 |
OPENSSL_EXPORT uint64_t SSL_SESSION_set_time(SSL_SESSION *session, |
| 2140 |
uint64_t time); |
| 2141 |
|
| 2142 |
// SSL_SESSION_set_timeout sets |session|'s timeout to |timeout| and returns |
| 2143 |
// one. This function may be useful in writing tests but otherwise should not |
| 2144 |
// be used. |
| 2145 |
OPENSSL_EXPORT uint32_t SSL_SESSION_set_timeout(SSL_SESSION *session, |
| 2146 |
uint32_t timeout); |
| 2147 |
|
| 2148 |
// SSL_SESSION_get0_id_context returns a pointer to a buffer containing |
| 2149 |
// |session|'s session ID context (see |SSL_CTX_set_session_id_context|) and |
| 2150 |
// sets |*out_len| to its length. |
| 2151 |
OPENSSL_EXPORT const uint8_t *SSL_SESSION_get0_id_context( |
| 2152 |
const SSL_SESSION *session, unsigned *out_len); |
| 2153 |
|
| 2154 |
// SSL_SESSION_set1_id_context sets |session|'s session ID context (see |
| 2155 |
// |SSL_CTX_set_session_id_context|) to |sid_ctx|. It returns one on success and |
| 2156 |
// zero on error. This function may be useful in writing tests but otherwise |
| 2157 |
// should not be used. |
| 2158 |
OPENSSL_EXPORT int SSL_SESSION_set1_id_context(SSL_SESSION *session, |
| 2159 |
const uint8_t *sid_ctx, |
| 2160 |
size_t sid_ctx_len); |
| 2161 |
|
| 2162 |
// SSL_SESSION_should_be_single_use returns one if |session| should be |
| 2163 |
// single-use (TLS 1.3 and later) and zero otherwise. |
| 2164 |
// |
| 2165 |
// If this function returns one, clients retain multiple sessions and use each |
| 2166 |
// only once. This prevents passive observers from correlating connections with |
| 2167 |
// tickets. See RFC 8446, appendix C.4. If it returns zero, |session| cannot be |
| 2168 |
// used without leaking a correlator. |
| 2169 |
OPENSSL_EXPORT int SSL_SESSION_should_be_single_use(const SSL_SESSION *session); |
| 2170 |
|
| 2171 |
// SSL_SESSION_is_resumable returns one if |session| is complete and contains a |
| 2172 |
// session ID or ticket. It returns zero otherwise. Note this function does not |
| 2173 |
// ensure |session| will be resumed. It may be expired, dropped by the server, |
| 2174 |
// or associated with incompatible parameters. |
| 2175 |
OPENSSL_EXPORT int SSL_SESSION_is_resumable(const SSL_SESSION *session); |
| 2176 |
|
| 2177 |
// SSL_SESSION_has_ticket returns one if |session| has a ticket and zero |
| 2178 |
// otherwise. |
| 2179 |
OPENSSL_EXPORT int SSL_SESSION_has_ticket(const SSL_SESSION *session); |
| 2180 |
|
| 2181 |
// SSL_SESSION_get0_ticket sets |*out_ticket| and |*out_len| to |session|'s |
| 2182 |
// ticket, or NULL and zero if it does not have one. |out_ticket| may be NULL |
| 2183 |
// if only the ticket length is needed. |
| 2184 |
OPENSSL_EXPORT void SSL_SESSION_get0_ticket(const SSL_SESSION *session, |
| 2185 |
const uint8_t **out_ticket, |
| 2186 |
size_t *out_len); |
| 2187 |
|
| 2188 |
// SSL_SESSION_set_ticket sets |session|'s ticket to |ticket|. It returns one on |
| 2189 |
// success and zero on error. This function may be useful in writing tests but |
| 2190 |
// otherwise should not be used. |
| 2191 |
OPENSSL_EXPORT int SSL_SESSION_set_ticket(SSL_SESSION *session, |
| 2192 |
const uint8_t *ticket, |
| 2193 |
size_t ticket_len); |
| 2194 |
|
| 2195 |
// SSL_SESSION_get_ticket_lifetime_hint returns ticket lifetime hint of |
| 2196 |
// |session| in seconds or zero if none was set. |
| 2197 |
OPENSSL_EXPORT uint32_t |
| 2198 |
SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *session); |
| 2199 |
|
| 2200 |
// SSL_SESSION_get0_cipher returns the cipher negotiated by the connection which |
| 2201 |
// established |session|. |
| 2202 |
// |
| 2203 |
// Note that, in TLS 1.3, there is no guarantee that resumptions with |session| |
| 2204 |
// will use that cipher. Prefer calling |SSL_get_current_cipher| on the |SSL| |
| 2205 |
// instead. |
| 2206 |
OPENSSL_EXPORT const SSL_CIPHER *SSL_SESSION_get0_cipher( |
| 2207 |
const SSL_SESSION *session); |
| 2208 |
|
| 2209 |
// SSL_SESSION_has_peer_sha256 returns one if |session| has a SHA-256 hash of |
| 2210 |
// the peer's certificate retained and zero if the peer did not present a |
| 2211 |
// certificate or if this was not enabled when |session| was created. See also |
| 2212 |
// |SSL_CTX_set_retain_only_sha256_of_client_certs|. |
| 2213 |
OPENSSL_EXPORT int SSL_SESSION_has_peer_sha256(const SSL_SESSION *session); |
| 2214 |
|
| 2215 |
// SSL_SESSION_get0_peer_sha256 sets |*out_ptr| and |*out_len| to the SHA-256 |
| 2216 |
// hash of the peer certificate retained in |session|, or NULL and zero if it |
| 2217 |
// does not have one. See also |SSL_CTX_set_retain_only_sha256_of_client_certs|. |
| 2218 |
OPENSSL_EXPORT void SSL_SESSION_get0_peer_sha256(const SSL_SESSION *session, |
| 2219 |
const uint8_t **out_ptr, |
| 2220 |
size_t *out_len); |
| 2221 |
|
| 2222 |
|
| 2223 |
// Session caching. |
| 2224 |
// |
| 2225 |
// Session caching allows connections to be established more efficiently based |
| 2226 |
// on saved parameters from a previous connection, called a session (see |
| 2227 |
// |SSL_SESSION|). The client offers a saved session, using an opaque identifier |
| 2228 |
// from a previous connection. The server may accept the session, if it has the |
| 2229 |
// parameters available. Otherwise, it will decline and continue with a full |
| 2230 |
// handshake. |
| 2231 |
// |
| 2232 |
// This requires both the client and the server to retain session state. A |
| 2233 |
// client does so with a stateful session cache. A server may do the same or, if |
| 2234 |
// supported by both sides, statelessly using session tickets. For more |
| 2235 |
// information on the latter, see the next section. |
| 2236 |
// |
| 2237 |
// For a server, the library implements a built-in internal session cache as an |
| 2238 |
// in-memory hash table. Servers may also use |SSL_CTX_sess_set_get_cb| and |
| 2239 |
// |SSL_CTX_sess_set_new_cb| to implement a custom external session cache. In |
| 2240 |
// particular, this may be used to share a session cache between multiple |
| 2241 |
// servers in a large deployment. An external cache may be used in addition to |
| 2242 |
// or instead of the internal one. Use |SSL_CTX_set_session_cache_mode| to |
| 2243 |
// toggle the internal cache. |
| 2244 |
// |
| 2245 |
// For a client, the only option is an external session cache. Clients may use |
| 2246 |
// |SSL_CTX_sess_set_new_cb| to register a callback for when new sessions are |
| 2247 |
// available. These may be cached and, in subsequent compatible connections, |
| 2248 |
// configured with |SSL_set_session|. |
| 2249 |
// |
| 2250 |
// Note that offering or accepting a session short-circuits certificate |
| 2251 |
// verification and most parameter negotiation. Resuming sessions across |
| 2252 |
// different contexts may result in security failures and surprising |
| 2253 |
// behavior. For a typical client, this means sessions for different hosts must |
| 2254 |
// be cached under different keys. A client that connects to the same host with, |
| 2255 |
// e.g., different cipher suite settings or client certificates should also use |
| 2256 |
// separate session caches between those contexts. Servers should also partition |
| 2257 |
// session caches between SNI hosts with |SSL_CTX_set_session_id_context|. |
| 2258 |
// |
| 2259 |
// Note also, in TLS 1.2 and earlier, offering sessions allows passive observers |
| 2260 |
// to correlate different client connections. TLS 1.3 and later fix this, |
| 2261 |
// provided clients use sessions at most once. Session caches are managed by the |
| 2262 |
// caller in BoringSSL, so this must be implemented externally. See |
| 2263 |
// |SSL_SESSION_should_be_single_use| for details. |
| 2264 |
|
| 2265 |
// SSL_SESS_CACHE_OFF disables all session caching. |
| 2266 |
#define SSL_SESS_CACHE_OFF 0x0000 |
| 2267 |
|
| 2268 |
// SSL_SESS_CACHE_CLIENT enables session caching for a client. The internal |
| 2269 |
// cache is never used on a client, so this only enables the callbacks. |
| 2270 |
#define SSL_SESS_CACHE_CLIENT 0x0001 |
| 2271 |
|
| 2272 |
// SSL_SESS_CACHE_SERVER enables session caching for a server. |
| 2273 |
#define SSL_SESS_CACHE_SERVER 0x0002 |
| 2274 |
|
| 2275 |
// SSL_SESS_CACHE_BOTH enables session caching for both client and server. |
| 2276 |
#define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT | SSL_SESS_CACHE_SERVER) |
| 2277 |
|
| 2278 |
// SSL_SESS_CACHE_NO_AUTO_CLEAR disables automatically calling |
| 2279 |
// |SSL_CTX_flush_sessions| every 255 connections. |
| 2280 |
#define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 |
| 2281 |
|
| 2282 |
// SSL_SESS_CACHE_NO_INTERNAL_LOOKUP, on a server, disables looking up a session |
| 2283 |
// from the internal session cache. |
| 2284 |
#define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 |
| 2285 |
|
| 2286 |
// SSL_SESS_CACHE_NO_INTERNAL_STORE, on a server, disables storing sessions in |
| 2287 |
// the internal session cache. |
| 2288 |
#define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 |
| 2289 |
|
| 2290 |
// SSL_SESS_CACHE_NO_INTERNAL, on a server, disables the internal session |
| 2291 |
// cache. |
| 2292 |
#define SSL_SESS_CACHE_NO_INTERNAL \ |
| 2293 |
(SSL_SESS_CACHE_NO_INTERNAL_LOOKUP | SSL_SESS_CACHE_NO_INTERNAL_STORE) |
| 2294 |
|
| 2295 |
// SSL_CTX_set_session_cache_mode sets the session cache mode bits for |ctx| to |
| 2296 |
// |mode|. It returns the previous value. |
| 2297 |
OPENSSL_EXPORT int SSL_CTX_set_session_cache_mode(SSL_CTX *ctx, int mode); |
| 2298 |
|
| 2299 |
// SSL_CTX_get_session_cache_mode returns the session cache mode bits for |
| 2300 |
// |ctx| |
| 2301 |
OPENSSL_EXPORT int SSL_CTX_get_session_cache_mode(const SSL_CTX *ctx); |
| 2302 |
|
| 2303 |
// SSL_set_session, for a client, configures |ssl| to offer to resume |session| |
| 2304 |
// in the initial handshake and returns one. The caller retains ownership of |
| 2305 |
// |session|. Note that configuring a session assumes the authentication in the |
| 2306 |
// session is valid. For callers that wish to revalidate the session before |
| 2307 |
// offering, see |SSL_SESSION_get0_peer_certificates|, |
| 2308 |
// |SSL_SESSION_get0_signed_cert_timestamp_list|, and |
| 2309 |
// |SSL_SESSION_get0_ocsp_response|. |
| 2310 |
// |
| 2311 |
// It is an error to call this function after the handshake has begun. |
| 2312 |
OPENSSL_EXPORT int SSL_set_session(SSL *ssl, SSL_SESSION *session); |
| 2313 |
|
| 2314 |
// SSL_DEFAULT_SESSION_TIMEOUT is the default lifetime, in seconds, of a |
| 2315 |
// session in TLS 1.2 or earlier. This is how long we are willing to use the |
| 2316 |
// secret to encrypt traffic without fresh key material. |
| 2317 |
#define SSL_DEFAULT_SESSION_TIMEOUT (2 * 60 * 60) |
| 2318 |
|
| 2319 |
// SSL_DEFAULT_SESSION_PSK_DHE_TIMEOUT is the default lifetime, in seconds, of a |
| 2320 |
// session for TLS 1.3 psk_dhe_ke. This is how long we are willing to use the |
| 2321 |
// secret as an authenticator. |
| 2322 |
#define SSL_DEFAULT_SESSION_PSK_DHE_TIMEOUT (2 * 24 * 60 * 60) |
| 2323 |
|
| 2324 |
// SSL_DEFAULT_SESSION_AUTH_TIMEOUT is the default non-renewable lifetime, in |
| 2325 |
// seconds, of a TLS 1.3 session. This is how long we are willing to trust the |
| 2326 |
// signature in the initial handshake. |
| 2327 |
#define SSL_DEFAULT_SESSION_AUTH_TIMEOUT (7 * 24 * 60 * 60) |
| 2328 |
|
| 2329 |
// SSL_CTX_set_timeout sets the lifetime, in seconds, of TLS 1.2 (or earlier) |
| 2330 |
// sessions created in |ctx| to |timeout|. |
| 2331 |
OPENSSL_EXPORT uint32_t SSL_CTX_set_timeout(SSL_CTX *ctx, uint32_t timeout); |
| 2332 |
|
| 2333 |
// SSL_CTX_set_session_psk_dhe_timeout sets the lifetime, in seconds, of TLS 1.3 |
| 2334 |
// sessions created in |ctx| to |timeout|. |
| 2335 |
OPENSSL_EXPORT void SSL_CTX_set_session_psk_dhe_timeout(SSL_CTX *ctx, |
| 2336 |
uint32_t timeout); |
| 2337 |
|
| 2338 |
// SSL_CTX_get_timeout returns the lifetime, in seconds, of TLS 1.2 (or earlier) |
| 2339 |
// sessions created in |ctx|. |
| 2340 |
OPENSSL_EXPORT uint32_t SSL_CTX_get_timeout(const SSL_CTX *ctx); |
| 2341 |
|
| 2342 |
// SSL_MAX_SID_CTX_LENGTH is the maximum length of a session ID context. |
| 2343 |
#define SSL_MAX_SID_CTX_LENGTH 32 |
| 2344 |
|
| 2345 |
// SSL_CTX_set_session_id_context sets |ctx|'s session ID context to |sid_ctx|. |
| 2346 |
// It returns one on success and zero on error. The session ID context is an |
| 2347 |
// application-defined opaque byte string. A session will not be used in a |
| 2348 |
// connection without a matching session ID context. |
| 2349 |
// |
| 2350 |
// For a server, if |SSL_VERIFY_PEER| is enabled, it is an error to not set a |
| 2351 |
// session ID context. |
| 2352 |
OPENSSL_EXPORT int SSL_CTX_set_session_id_context(SSL_CTX *ctx, |
| 2353 |
const uint8_t *sid_ctx, |
| 2354 |
size_t sid_ctx_len); |
| 2355 |
|
| 2356 |
// SSL_set_session_id_context sets |ssl|'s session ID context to |sid_ctx|. It |
| 2357 |
// returns one on success and zero on error. See also |
| 2358 |
// |SSL_CTX_set_session_id_context|. |
| 2359 |
OPENSSL_EXPORT int SSL_set_session_id_context(SSL *ssl, const uint8_t *sid_ctx, |
| 2360 |
size_t sid_ctx_len); |
| 2361 |
|
| 2362 |
// SSL_get0_session_id_context returns a pointer to |ssl|'s session ID context |
| 2363 |
// and sets |*out_len| to its length. It returns NULL on error. |
| 2364 |
OPENSSL_EXPORT const uint8_t *SSL_get0_session_id_context(const SSL *ssl, |
| 2365 |
size_t *out_len); |
| 2366 |
|
| 2367 |
// SSL_SESSION_CACHE_MAX_SIZE_DEFAULT is the default maximum size of a session |
| 2368 |
// cache. |
| 2369 |
#define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024 * 20) |
| 2370 |
|
| 2371 |
// SSL_CTX_sess_set_cache_size sets the maximum size of |ctx|'s internal session |
| 2372 |
// cache to |size|. It returns the previous value. |
| 2373 |
OPENSSL_EXPORT unsigned long SSL_CTX_sess_set_cache_size(SSL_CTX *ctx, |
| 2374 |
unsigned long size); |
| 2375 |
|
| 2376 |
// SSL_CTX_sess_get_cache_size returns the maximum size of |ctx|'s internal |
| 2377 |
// session cache. |
| 2378 |
OPENSSL_EXPORT unsigned long SSL_CTX_sess_get_cache_size(const SSL_CTX *ctx); |
| 2379 |
|
| 2380 |
// SSL_CTX_sess_number returns the number of sessions in |ctx|'s internal |
| 2381 |
// session cache. |
| 2382 |
OPENSSL_EXPORT size_t SSL_CTX_sess_number(const SSL_CTX *ctx); |
| 2383 |
|
| 2384 |
// SSL_CTX_add_session inserts |session| into |ctx|'s internal session cache. It |
| 2385 |
// returns one on success and zero on error or if |session| is already in the |
| 2386 |
// cache. The caller retains its reference to |session|. |
| 2387 |
OPENSSL_EXPORT int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *session); |
| 2388 |
|
| 2389 |
// SSL_CTX_remove_session removes |session| from |ctx|'s internal session cache. |
| 2390 |
// It returns one on success and zero if |session| was not in the cache. |
| 2391 |
OPENSSL_EXPORT int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *session); |
| 2392 |
|
| 2393 |
// SSL_CTX_flush_sessions removes all sessions from |ctx| which have expired as |
| 2394 |
// of time |time|. If |time| is zero, all sessions are removed. |
| 2395 |
OPENSSL_EXPORT void SSL_CTX_flush_sessions(SSL_CTX *ctx, uint64_t time); |
| 2396 |
|
| 2397 |
// SSL_CTX_sess_set_new_cb sets the callback to be called when a new session is |
| 2398 |
// established and ready to be cached. If the session cache is disabled (the |
| 2399 |
// appropriate one of |SSL_SESS_CACHE_CLIENT| or |SSL_SESS_CACHE_SERVER| is |
| 2400 |
// unset), the callback is not called. |
| 2401 |
// |
| 2402 |
// The callback is passed a reference to |session|. It returns one if it takes |
| 2403 |
// ownership (and then calls |SSL_SESSION_free| when done) and zero otherwise. A |
| 2404 |
// consumer which places |session| into an in-memory cache will likely return |
| 2405 |
// one, with the cache calling |SSL_SESSION_free|. A consumer which serializes |
| 2406 |
// |session| with |SSL_SESSION_to_bytes| may not need to retain |session| and |
| 2407 |
// will likely return zero. Returning one is equivalent to calling |
| 2408 |
// |SSL_SESSION_up_ref| and then returning zero. |
| 2409 |
// |
| 2410 |
// Note: For a client, the callback may be called on abbreviated handshakes if a |
| 2411 |
// ticket is renewed. Further, it may not be called until some time after |
| 2412 |
// |SSL_do_handshake| or |SSL_connect| completes if False Start is enabled. Thus |
| 2413 |
// it's recommended to use this callback over calling |SSL_get_session| on |
| 2414 |
// handshake completion. |
| 2415 |
OPENSSL_EXPORT void SSL_CTX_sess_set_new_cb( |
| 2416 |
SSL_CTX *ctx, int (*new_session_cb)(SSL *ssl, SSL_SESSION *session)); |
| 2417 |
|
| 2418 |
// SSL_CTX_sess_get_new_cb returns the callback set by |
| 2419 |
// |SSL_CTX_sess_set_new_cb|. |
| 2420 |
OPENSSL_EXPORT int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))( |
| 2421 |
SSL *ssl, SSL_SESSION *session); |
| 2422 |
|
| 2423 |
// SSL_CTX_sess_set_remove_cb sets a callback which is called when a session is |
| 2424 |
// removed from the internal session cache. |
| 2425 |
// |
| 2426 |
// TODO(davidben): What is the point of this callback? It seems useless since it |
| 2427 |
// only fires on sessions in the internal cache. |
| 2428 |
OPENSSL_EXPORT void SSL_CTX_sess_set_remove_cb( |
| 2429 |
SSL_CTX *ctx, |
| 2430 |
void (*remove_session_cb)(SSL_CTX *ctx, SSL_SESSION *session)); |
| 2431 |
|
| 2432 |
// SSL_CTX_sess_get_remove_cb returns the callback set by |
| 2433 |
// |SSL_CTX_sess_set_remove_cb|. |
| 2434 |
OPENSSL_EXPORT void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))( |
| 2435 |
SSL_CTX *ctx, SSL_SESSION *session); |
| 2436 |
|
| 2437 |
// SSL_CTX_sess_set_get_cb sets a callback to look up a session by ID for a |
| 2438 |
// server. The callback is passed the session ID and should return a matching |
| 2439 |
// |SSL_SESSION| or NULL if not found. It should set |*out_copy| to zero and |
| 2440 |
// return a new reference to the session. This callback is not used for a |
| 2441 |
// client. |
| 2442 |
// |
| 2443 |
// For historical reasons, if |*out_copy| is set to one (default), the SSL |
| 2444 |
// library will take a new reference to the returned |SSL_SESSION|, expecting |
| 2445 |
// the callback to return a non-owning pointer. This is not recommended. If |
| 2446 |
// |ctx| and thus the callback is used on multiple threads, the session may be |
| 2447 |
// removed and invalidated before the SSL library calls |SSL_SESSION_up_ref|, |
| 2448 |
// whereas the callback may synchronize internally. |
| 2449 |
// |
| 2450 |
// To look up a session asynchronously, the callback may return |
| 2451 |
// |SSL_magic_pending_session_ptr|. See the documentation for that function and |
| 2452 |
// |SSL_ERROR_PENDING_SESSION|. |
| 2453 |
// |
| 2454 |
// If the internal session cache is enabled, the callback is only consulted if |
| 2455 |
// the internal cache does not return a match. |
| 2456 |
OPENSSL_EXPORT void SSL_CTX_sess_set_get_cb( |
| 2457 |
SSL_CTX *ctx, SSL_SESSION *(*get_session_cb)(SSL *ssl, const uint8_t *id, |
| 2458 |
int id_len, int *out_copy)); |
| 2459 |
|
| 2460 |
// SSL_CTX_sess_get_get_cb returns the callback set by |
| 2461 |
// |SSL_CTX_sess_set_get_cb|. |
| 2462 |
OPENSSL_EXPORT SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))( |
| 2463 |
SSL *ssl, const uint8_t *id, int id_len, int *out_copy); |
| 2464 |
|
| 2465 |
// SSL_magic_pending_session_ptr returns a magic |SSL_SESSION|* which indicates |
| 2466 |
// that the session isn't currently unavailable. |SSL_get_error| will then |
| 2467 |
// return |SSL_ERROR_PENDING_SESSION| and the handshake can be retried later |
| 2468 |
// when the lookup has completed. |
| 2469 |
OPENSSL_EXPORT SSL_SESSION *SSL_magic_pending_session_ptr(void); |
| 2470 |
|
| 2471 |
|
| 2472 |
// Session tickets. |
| 2473 |
// |
| 2474 |
// Session tickets, from RFC 5077, allow session resumption without server-side |
| 2475 |
// state. The server maintains a secret ticket key and sends the client opaque |
| 2476 |
// encrypted session parameters, called a ticket. When offering the session, the |
| 2477 |
// client sends the ticket which the server decrypts to recover session state. |
| 2478 |
// Session tickets are enabled by default but may be disabled with |
| 2479 |
// |SSL_OP_NO_TICKET|. |
| 2480 |
// |
| 2481 |
// On the client, ticket-based sessions use the same APIs as ID-based tickets. |
| 2482 |
// Callers do not need to handle them differently. |
| 2483 |
// |
| 2484 |
// On the server, tickets are encrypted and authenticated with a secret key. |
| 2485 |
// By default, an |SSL_CTX| will manage session ticket encryption keys by |
| 2486 |
// generating them internally and rotating every 48 hours. Tickets are minted |
| 2487 |
// and processed transparently. The following functions may be used to configure |
| 2488 |
// a persistent key or implement more custom behavior, including key rotation |
| 2489 |
// and sharing keys between multiple servers in a large deployment. There are |
| 2490 |
// three levels of customisation possible: |
| 2491 |
// |
| 2492 |
// 1) One can simply set the keys with |SSL_CTX_set_tlsext_ticket_keys|. |
| 2493 |
// 2) One can configure an |EVP_CIPHER_CTX| and |HMAC_CTX| directly for |
| 2494 |
// encryption and authentication. |
| 2495 |
// 3) One can configure an |SSL_TICKET_AEAD_METHOD| to have more control |
| 2496 |
// and the option of asynchronous decryption. |
| 2497 |
// |
| 2498 |
// An attacker that compromises a server's session ticket key can impersonate |
| 2499 |
// the server and, prior to TLS 1.3, retroactively decrypt all application |
| 2500 |
// traffic from sessions using that ticket key. Thus ticket keys must be |
| 2501 |
// regularly rotated for forward secrecy. Note the default key is rotated |
| 2502 |
// automatically once every 48 hours but manually configured keys are not. |
| 2503 |
|
| 2504 |
// SSL_DEFAULT_TICKET_KEY_ROTATION_INTERVAL is the interval with which the |
| 2505 |
// default session ticket encryption key is rotated, if in use. If any |
| 2506 |
// non-default ticket encryption mechanism is configured, automatic rotation is |
| 2507 |
// disabled. |
| 2508 |
#define SSL_DEFAULT_TICKET_KEY_ROTATION_INTERVAL (2 * 24 * 60 * 60) |
| 2509 |
|
| 2510 |
// SSL_CTX_get_tlsext_ticket_keys writes |ctx|'s session ticket key material to |
| 2511 |
// |len| bytes of |out|. It returns one on success and zero if |len| is not |
| 2512 |
// 48. If |out| is NULL, it returns 48 instead. |
| 2513 |
OPENSSL_EXPORT int SSL_CTX_get_tlsext_ticket_keys(SSL_CTX *ctx, void *out, |
| 2514 |
size_t len); |
| 2515 |
|
| 2516 |
// SSL_CTX_set_tlsext_ticket_keys sets |ctx|'s session ticket key material to |
| 2517 |
// |len| bytes of |in|. It returns one on success and zero if |len| is not |
| 2518 |
// 48. If |in| is NULL, it returns 48 instead. |
| 2519 |
OPENSSL_EXPORT int SSL_CTX_set_tlsext_ticket_keys(SSL_CTX *ctx, const void *in, |
| 2520 |
size_t len); |
| 2521 |
|
| 2522 |
// SSL_TICKET_KEY_NAME_LEN is the length of the key name prefix of a session |
| 2523 |
// ticket. |
| 2524 |
#define SSL_TICKET_KEY_NAME_LEN 16 |
| 2525 |
|
| 2526 |
// SSL_CTX_set_tlsext_ticket_key_cb sets the ticket callback to |callback| and |
| 2527 |
// returns one. |callback| will be called when encrypting a new ticket and when |
| 2528 |
// decrypting a ticket from the client. |
| 2529 |
// |
| 2530 |
// In both modes, |ctx| and |hmac_ctx| will already have been initialized with |
| 2531 |
// |EVP_CIPHER_CTX_init| and |HMAC_CTX_init|, respectively. |callback| |
| 2532 |
// configures |hmac_ctx| with an HMAC digest and key, and configures |ctx| |
| 2533 |
// for encryption or decryption, based on the mode. |
| 2534 |
// |
| 2535 |
// When encrypting a new ticket, |encrypt| will be one. It writes a public |
| 2536 |
// 16-byte key name to |key_name| and a fresh IV to |iv|. The output IV length |
| 2537 |
// must match |EVP_CIPHER_CTX_iv_length| of the cipher selected. In this mode, |
| 2538 |
// |callback| returns 1 on success and -1 on error. |
| 2539 |
// |
| 2540 |
// When decrypting a ticket, |encrypt| will be zero. |key_name| will point to a |
| 2541 |
// 16-byte key name and |iv| points to an IV. The length of the IV consumed must |
| 2542 |
// match |EVP_CIPHER_CTX_iv_length| of the cipher selected. In this mode, |
| 2543 |
// |callback| returns -1 to abort the handshake, 0 if decrypting the ticket |
| 2544 |
// failed, and 1 or 2 on success. If it returns 2, the ticket will be renewed. |
| 2545 |
// This may be used to re-key the ticket. |
| 2546 |
// |
| 2547 |
// WARNING: |callback| wildly breaks the usual return value convention and is |
| 2548 |
// called in two different modes. |
| 2549 |
OPENSSL_EXPORT int SSL_CTX_set_tlsext_ticket_key_cb( |
| 2550 |
SSL_CTX *ctx, |
| 2551 |
int (*callback)(SSL *ssl, uint8_t *key_name, uint8_t *iv, |
| 2552 |
EVP_CIPHER_CTX *ctx, HMAC_CTX *hmac_ctx, int encrypt)); |
| 2553 |
|
| 2554 |
// ssl_ticket_aead_result_t enumerates the possible results from decrypting a |
| 2555 |
// ticket with an |SSL_TICKET_AEAD_METHOD|. |
| 2556 |
enum ssl_ticket_aead_result_t { |
| 2557 |
// ssl_ticket_aead_success indicates that the ticket was successfully |
| 2558 |
// decrypted. |
| 2559 |
ssl_ticket_aead_success, |
| 2560 |
// ssl_ticket_aead_retry indicates that the operation could not be |
| 2561 |
// immediately completed and must be reattempted, via |open|, at a later |
| 2562 |
// point. |
| 2563 |
ssl_ticket_aead_retry, |
| 2564 |
// ssl_ticket_aead_ignore_ticket indicates that the ticket should be ignored |
| 2565 |
// (i.e. is corrupt or otherwise undecryptable). |
| 2566 |
ssl_ticket_aead_ignore_ticket, |
| 2567 |
// ssl_ticket_aead_error indicates that a fatal error occured and the |
| 2568 |
// handshake should be terminated. |
| 2569 |
ssl_ticket_aead_error |
| 2570 |
}; |
| 2571 |
|
| 2572 |
// ssl_ticket_aead_method_st (aka |SSL_TICKET_AEAD_METHOD|) contains methods |
| 2573 |
// for encrypting and decrypting session tickets. |
| 2574 |
struct ssl_ticket_aead_method_st { |
| 2575 |
// max_overhead returns the maximum number of bytes of overhead that |seal| |
| 2576 |
// may add. |
| 2577 |
size_t (*max_overhead)(SSL *ssl); |
| 2578 |
|
| 2579 |
// seal encrypts and authenticates |in_len| bytes from |in|, writes, at most, |
| 2580 |
// |max_out_len| bytes to |out|, and puts the number of bytes written in |
| 2581 |
// |*out_len|. The |in| and |out| buffers may be equal but will not otherwise |
| 2582 |
// alias. It returns one on success or zero on error. |
| 2583 |
int (*seal)(SSL *ssl, uint8_t *out, size_t *out_len, size_t max_out_len, |
| 2584 |
const uint8_t *in, size_t in_len); |
| 2585 |
|
| 2586 |
// open authenticates and decrypts |in_len| bytes from |in|, writes, at most, |
| 2587 |
// |max_out_len| bytes of plaintext to |out|, and puts the number of bytes |
| 2588 |
// written in |*out_len|. The |in| and |out| buffers may be equal but will |
| 2589 |
// not otherwise alias. See |ssl_ticket_aead_result_t| for details of the |
| 2590 |
// return values. In the case that a retry is indicated, the caller should |
| 2591 |
// arrange for the high-level operation on |ssl| to be retried when the |
| 2592 |
// operation is completed, which will result in another call to |open|. |
| 2593 |
enum ssl_ticket_aead_result_t (*open)(SSL *ssl, uint8_t *out, size_t *out_len, |
| 2594 |
size_t max_out_len, const uint8_t *in, |
| 2595 |
size_t in_len); |
| 2596 |
}; |
| 2597 |
|
| 2598 |
// SSL_CTX_set_ticket_aead_method configures a custom ticket AEAD method table |
| 2599 |
// on |ctx|. |aead_method| must remain valid for the lifetime of |ctx|. |
| 2600 |
OPENSSL_EXPORT void SSL_CTX_set_ticket_aead_method( |
| 2601 |
SSL_CTX *ctx, const SSL_TICKET_AEAD_METHOD *aead_method); |
| 2602 |
|
| 2603 |
// SSL_process_tls13_new_session_ticket processes an unencrypted TLS 1.3 |
| 2604 |
// NewSessionTicket message from |buf| and returns a resumable |SSL_SESSION|, |
| 2605 |
// or NULL on error. The caller takes ownership of the returned session and |
| 2606 |
// must call |SSL_SESSION_free| to free it. |
| 2607 |
// |
| 2608 |
// |buf| contains |buf_len| bytes that represents a complete NewSessionTicket |
| 2609 |
// message including its header, i.e., one byte for the type (0x04) and three |
| 2610 |
// bytes for the length. |buf| must contain only one such message. |
| 2611 |
// |
| 2612 |
// This function may be used to process NewSessionTicket messages in TLS 1.3 |
| 2613 |
// clients that are handling the record layer externally. |
| 2614 |
OPENSSL_EXPORT SSL_SESSION *SSL_process_tls13_new_session_ticket( |
| 2615 |
SSL *ssl, const uint8_t *buf, size_t buf_len); |
| 2616 |
|
| 2617 |
// SSL_CTX_set_num_tickets configures |ctx| to send |num_tickets| immediately |
| 2618 |
// after a successful TLS 1.3 handshake as a server. It returns one. Large |
| 2619 |
// values of |num_tickets| will be capped within the library. |
| 2620 |
// |
| 2621 |
// By default, BoringSSL sends two tickets. |
| 2622 |
OPENSSL_EXPORT int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets); |
| 2623 |
|
| 2624 |
// SSL_CTX_get_num_tickets returns the number of tickets |ctx| will send |
| 2625 |
// immediately after a successful TLS 1.3 handshake as a server. |
| 2626 |
OPENSSL_EXPORT size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx); |
| 2627 |
|
| 2628 |
|
| 2629 |
// Diffie-Hellman groups and ephemeral key exchanges. |
| 2630 |
// |
| 2631 |
// Most TLS handshakes (ECDHE cipher suites in TLS 1.2, and all supported TLS |
| 2632 |
// 1.3 modes) incorporate an ephemeral key exchange, most commonly using |
| 2633 |
// Elliptic Curve Diffie-Hellman (ECDH), as described in RFC 8422. The key |
| 2634 |
// exchange algorithm is negotiated separately from the cipher suite, using |
| 2635 |
// NamedGroup values, which define Diffie-Hellman groups. |
| 2636 |
// |
| 2637 |
// Historically, these values were known as "curves", in reference to ECDH, and |
| 2638 |
// some APIs refer to the original name. RFC 7919 renamed them to "groups" in |
| 2639 |
// reference to Diffie-Hellman in general. These values are also used to select |
| 2640 |
// experimental post-quantum KEMs. Though not Diffie-Hellman groups, KEMs can |
| 2641 |
// fill a similar role in TLS, so they use the same codepoints. |
| 2642 |
// |
| 2643 |
// In TLS 1.2, the ECDH values also negotiate elliptic curves used in ECDSA. In |
| 2644 |
// TLS 1.3 and later, ECDSA curves are part of the signature algorithm. See |
| 2645 |
// |SSL_SIGN_*|. |
| 2646 |
|
| 2647 |
// SSL_CTX_set1_groups sets the preferred groups for |ctx| to be |groups|. Each |
| 2648 |
// element of |groups| should be a |NID_*| constant from nid.h. It returns one |
| 2649 |
// on success and zero on failure. |
| 2650 |
// |
| 2651 |
// Note that this API does not use the |SSL_GROUP_*| values defined below. |
| 2652 |
OPENSSL_EXPORT int SSL_CTX_set1_groups(SSL_CTX *ctx, const int *groups, |
| 2653 |
size_t num_groups); |
| 2654 |
|
| 2655 |
// SSL_set1_groups sets the preferred groups for |ssl| to be |groups|. Each |
| 2656 |
// element of |groups| should be a |NID_*| constant from nid.h. It returns one |
| 2657 |
// on success and zero on failure. |
| 2658 |
// |
| 2659 |
// Note that this API does not use the |SSL_GROUP_*| values defined below. |
| 2660 |
OPENSSL_EXPORT int SSL_set1_groups(SSL *ssl, const int *groups, |
| 2661 |
size_t num_groups); |
| 2662 |
|
| 2663 |
// SSL_CTX_set1_groups_list sets the preferred groups for |ctx| to be the |
| 2664 |
// colon-separated list |groups|. Each element of |groups| should be a curve |
| 2665 |
// name (e.g. P-256, X25519, ...). It returns one on success and zero on |
| 2666 |
// failure. |
| 2667 |
OPENSSL_EXPORT int SSL_CTX_set1_groups_list(SSL_CTX *ctx, const char *groups); |
| 2668 |
|
| 2669 |
// SSL_set1_groups_list sets the preferred groups for |ssl| to be the |
| 2670 |
// colon-separated list |groups|. Each element of |groups| should be a curve |
| 2671 |
// name (e.g. P-256, X25519, ...). It returns one on success and zero on |
| 2672 |
// failure. |
| 2673 |
OPENSSL_EXPORT int SSL_set1_groups_list(SSL *ssl, const char *groups); |
| 2674 |
|
| 2675 |
// SSL_get_negotiated_group returns the NID of the group used by |ssl|'s most |
| 2676 |
// recently completed handshake, or |NID_undef| if not applicable. |
| 2677 |
OPENSSL_EXPORT int SSL_get_negotiated_group(const SSL *ssl); |
| 2678 |
|
| 2679 |
// SSL_GROUP_* define TLS group IDs. |
| 2680 |
#define SSL_GROUP_SECP224R1 21 |
| 2681 |
#define SSL_GROUP_SECP256R1 23 |
| 2682 |
#define SSL_GROUP_SECP384R1 24 |
| 2683 |
#define SSL_GROUP_SECP521R1 25 |
| 2684 |
#define SSL_GROUP_X25519 29 |
| 2685 |
|
| 2686 |
// The following are defined at |
| 2687 |
// https://datatracker.ietf.org/doc/html/draft-kwiatkowski-tls-ecdhe-mlkem.html |
| 2688 |
#define SSL_GROUP_SECP256R1_MLKEM768 0x11EB |
| 2689 |
#define SSL_GROUP_X25519_MLKEM768 0x11EC |
| 2690 |
#define SSL_GROUP_SECP384R1_MLKEM1024 0x11ED |
| 2691 |
|
| 2692 |
// The following are defined at |
| 2693 |
// https://datatracker.ietf.org/doc/html/draft-connolly-tls-mlkem-key-agreement.html |
| 2694 |
#define SSL_GROUP_MLKEM512 0x0200 |
| 2695 |
#define SSL_GROUP_MLKEM768 0x0201 |
| 2696 |
#define SSL_GROUP_MLKEM1024 0x0202 |
| 2697 |
|
| 2698 |
// SSL_get_group_id returns the ID of the group used by |ssl|'s most recently |
| 2699 |
// completed handshake, or 0 if not applicable. |
| 2700 |
OPENSSL_EXPORT uint16_t SSL_get_group_id(const SSL *ssl); |
| 2701 |
|
| 2702 |
// SSL_get_group_name returns a human-readable name for the group specified by |
| 2703 |
// the given TLS group ID, or NULL if the group is unknown. |
| 2704 |
OPENSSL_EXPORT const char *SSL_get_group_name(uint16_t group_id); |
| 2705 |
|
| 2706 |
// SSL_get_peer_tmp_key sets |*out_key| to the temporary key provided by the |
| 2707 |
// peer that was during the key exchange. If |ssl| is the server, the client's |
| 2708 |
// temporary key is returned; if |ssl| is the client, the server's temporary key |
| 2709 |
// is returned. It returns 1 on success and 0 if otherwise. |
| 2710 |
OPENSSL_EXPORT int SSL_get_peer_tmp_key(SSL *ssl, EVP_PKEY **out_key); |
| 2711 |
|
| 2712 |
// SSL_get_server_tmp_key is a backwards compatible alias to |
| 2713 |
// |SSL_get_peer_tmp_key| in OpenSSL. Note that this means the client's |
| 2714 |
// temporary key is being set to |*out_key| instead, if |ssl| is the server. |
| 2715 |
OPENSSL_EXPORT int SSL_get_server_tmp_key(SSL *ssl, EVP_PKEY **out_key); |
| 2716 |
|
| 2717 |
// *** EXPERIMENTAL — DO NOT USE WITHOUT CHECKING *** |
| 2718 |
// |
| 2719 |
// |SSL_to_bytes| and |SSL_from_bytes| are developed to support SSL transfer |
| 2720 |
// across processes after handshake finished. |
| 2721 |
// |
| 2722 |
// SSL transfer allows the TLS connection to be used in a different |
| 2723 |
// process (or on a different machine). This only applies to servers. |
| 2724 |
// 1. Before termination, the process 1 encodes the |SSL| by calling |
| 2725 |
// |SSL_to_bytes|. |
| 2726 |
// 2. Another process resumes the |SSL| by calling |SSL_from_bytes|. |
| 2727 |
// |
| 2728 |
// WARNING: The serialisation formats are not yet stable: version skew may be |
| 2729 |
// fatal. |
| 2730 |
// WARNING: The encoded data contains sensitive key material and must be |
| 2731 |
// protected. |
| 2732 |
|
| 2733 |
// SSL_to_bytes serializes |in| into a newly allocated buffer and sets |
| 2734 |
// |*out_data| to that buffer and |*out_len| to its length. The caller takes |
| 2735 |
// ownership of the buffer and must call |OPENSSL_free| when done. It returns |
| 2736 |
// one on success and zero on error. |
| 2737 |
// |
| 2738 |
// CAUTION: This function will serialize an established TLS 1.2/1.3 |
| 2739 |
// connection, which includes sensitive security parameters established during |
| 2740 |
// the connection handshake, and memory buffers that may contain |
| 2741 |
// sensitive in-flight application data. It is the callers responsibility for |
| 2742 |
// ensuring the confidentiality and data integrity of the serialized encoding. |
| 2743 |
// Minimally a caller must encrypt the returned bytes using an AEAD cipher, such |
| 2744 |
// as AES-128-GCM before persisting the bytes to storage. |
| 2745 |
// |
| 2746 |
// WARNING: Currently only works with TLS 1.2 or TLS 1.3 after handshake has |
| 2747 |
// finished. |
| 2748 |
// WARNING: Currently only supports |SSL| as server. |
| 2749 |
// WARNING: CRYPTO_EX_DATA |ssl->ex_data| is not encoded. Remember set |ex_data| |
| 2750 |
// back after decode. |
| 2751 |
// WARNING: BIO |ssl->rbio| and |ssl->wbio| are not encoded. |
| 2752 |
// WARNING: STACK_OF(SSL_CIPHER) |ssl->client_cipher_suites| is not encoded. |
| 2753 |
// |
| 2754 |
// Initial implementation of this API is made by Evgeny Potemkin. |
| 2755 |
OPENSSL_EXPORT int SSL_to_bytes(const SSL *in, uint8_t **out_data, |
| 2756 |
size_t *out_len); |
| 2757 |
|
| 2758 |
// SSL_from_bytes parses |in_len| bytes from |in| as an SSL. It |
| 2759 |
// returns a newly-allocated |SSL| on success or NULL on error. |
| 2760 |
// The |SSL| is marked with handshake finished. |in| and |in_len| should |
| 2761 |
// come from |out_data| and |out_len| of |SSL_to_bytes|. In other words, |
| 2762 |
// |SSL_from_bytes| should be called after |SSL_to_bytes|. |
| 2763 |
// |
| 2764 |
// CAUTION: This function deserializes an encoded TLS 1.2/1.3 established |
| 2765 |
// connection so that the communication may continue on the previously |
| 2766 |
// established channel. It is the callers responsibility for maintaining |
| 2767 |
// confidentiality and integrity of serialized bytes between the time of |
| 2768 |
// serialization and invoking this function. |
| 2769 |
// See |SSL_to_bytes| for more details. |
| 2770 |
// |
| 2771 |
// WARNING: Do not decode the same bytes |in| for different connections. |
| 2772 |
// Otherwise, the connections use the same key material. |
| 2773 |
// WARNING: Remember set |ssl->rbio| and |ssl->wbio| before using |ssl|. |
| 2774 |
// WARNING: Remember set callback functions and |ex_data| back if needed. |
| 2775 |
// WARNING: STACK_OF(SSL_CIPHER) |ssl->client_cipher_suites| is not encoded and |
| 2776 |
// will be repopulated on next handshake. |
| 2777 |
// WARNING: To ensure behavior unchange, |ctx| setting should be the same. |
| 2778 |
// |
| 2779 |
// Initial implementation of this API is made by Evgeny Potemkin. |
| 2780 |
OPENSSL_EXPORT SSL *SSL_from_bytes(const uint8_t *in, size_t in_len, |
| 2781 |
SSL_CTX *ctx); |
| 2782 |
|
| 2783 |
// SSL_get_all_group_names outputs a list of possible strings |
| 2784 |
// |SSL_get_group_name| may return in this version of BoringSSL. It writes at |
| 2785 |
// most |max_out| entries to |out| and returns the total number it would have |
| 2786 |
// written, if |max_out| had been large enough. |max_out| may be initially set |
| 2787 |
// to zero to size the output. |
| 2788 |
// |
| 2789 |
// This function is only intended to help initialize tables in callers that want |
| 2790 |
// possible strings pre-declared. This list would not be suitable to set a list |
| 2791 |
// of supported features. It is in no particular order, and may contain |
| 2792 |
// placeholder, experimental, or deprecated values that do not apply to every |
| 2793 |
// caller. Future versions of BoringSSL may also return strings not in this |
| 2794 |
// list, so this does not apply if, say, sending strings across services. |
| 2795 |
OPENSSL_EXPORT size_t SSL_get_all_group_names(const char **out, size_t max_out); |
| 2796 |
|
| 2797 |
|
| 2798 |
// Certificate verification. |
| 2799 |
// |
| 2800 |
// SSL may authenticate either endpoint with an X.509 certificate. Typically |
| 2801 |
// this is used to authenticate the server to the client. These functions |
| 2802 |
// configure certificate verification. |
| 2803 |
// |
| 2804 |
// WARNING: By default, certificate verification errors on a client are not |
| 2805 |
// fatal. See |SSL_VERIFY_NONE| This may be configured with |
| 2806 |
// |SSL_CTX_set_verify|. |
| 2807 |
// |
| 2808 |
// By default clients are anonymous but a server may request a certificate from |
| 2809 |
// the client by setting |SSL_VERIFY_PEER|. |
| 2810 |
// |
| 2811 |
// Many of these functions use OpenSSL's legacy X.509 stack which is |
| 2812 |
// underdocumented and deprecated, but the replacement isn't ready yet. For |
| 2813 |
// now, consumers may use the existing stack or bypass it by performing |
| 2814 |
// certificate verification externally. This may be done with |
| 2815 |
// |SSL_CTX_set_cert_verify_callback| or by extracting the chain with |
| 2816 |
// |SSL_get_peer_cert_chain| after the handshake. In the future, functions will |
| 2817 |
// be added to use the SSL stack without dependency on any part of the legacy |
| 2818 |
// X.509 and ASN.1 stack. |
| 2819 |
// |
| 2820 |
// To augment certificate verification, a client may also enable OCSP stapling |
| 2821 |
// (RFC 6066) and Certificate Transparency (RFC 6962) extensions. |
| 2822 |
|
| 2823 |
// SSL_VERIFY_NONE, on a client, verifies the server certificate but does not |
| 2824 |
// make errors fatal. The result may be checked with |SSL_get_verify_result|. On |
| 2825 |
// a server it does not request a client certificate. This is the default. |
| 2826 |
#define SSL_VERIFY_NONE 0x00 |
| 2827 |
|
| 2828 |
// SSL_VERIFY_PEER, on a client, makes server certificate errors fatal. On a |
| 2829 |
// server it requests a client certificate and makes errors fatal. However, |
| 2830 |
// anonymous clients are still allowed. See |
| 2831 |
// |SSL_VERIFY_FAIL_IF_NO_PEER_CERT|. |
| 2832 |
#define SSL_VERIFY_PEER 0x01 |
| 2833 |
|
| 2834 |
// SSL_VERIFY_FAIL_IF_NO_PEER_CERT configures a server to reject connections if |
| 2835 |
// the client declines to send a certificate. This flag must be used together |
| 2836 |
// with |SSL_VERIFY_PEER|, otherwise it won't work. |
| 2837 |
#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 |
| 2838 |
|
| 2839 |
// SSL_VERIFY_PEER_IF_NO_OBC configures a server to request a client certificate |
| 2840 |
// if and only if Channel ID is not negotiated. |
| 2841 |
#define SSL_VERIFY_PEER_IF_NO_OBC 0x04 |
| 2842 |
|
| 2843 |
// SSL_CTX_set_verify configures certificate verification behavior. |mode| is |
| 2844 |
// one of the |SSL_VERIFY_*| values defined above. |callback| should be NULL. |
| 2845 |
// |
| 2846 |
// If |callback| is non-NULL, it is called as in |X509_STORE_CTX_set_verify_cb|, |
| 2847 |
// which is a deprecated and fragile mechanism to run the default certificate |
| 2848 |
// verification process, but suppress individual errors in it. See |
| 2849 |
// |X509_STORE_CTX_set_verify_cb| for details, If set, the callback may use |
| 2850 |
// |SSL_get_ex_data_X509_STORE_CTX_idx| with |X509_STORE_CTX_get_ex_data| to |
| 2851 |
// look up the |SSL| from |store_ctx|. |
| 2852 |
// |
| 2853 |
// WARNING: |callback| is not suitable for implementing custom certificate |
| 2854 |
// check, accepting all certificates, or extracting the certificate after |
| 2855 |
// verification. It does not replace the default process and is called multiple |
| 2856 |
// times throughout that process. It is also very difficult to implement this |
| 2857 |
// callback safely, without inadvertently relying on implementation details or |
| 2858 |
// making incorrect assumptions about when the callback is called. |
| 2859 |
// |
| 2860 |
// Instead, use |SSL_CTX_set_custom_verify| or |
| 2861 |
// |SSL_CTX_set_cert_verify_callback| to customize certificate verification. |
| 2862 |
// Those callbacks can inspect the peer-sent chain, call |X509_verify_cert| and |
| 2863 |
// inspect the result, or perform other operations more straightforwardly. |
| 2864 |
OPENSSL_EXPORT void SSL_CTX_set_verify( |
| 2865 |
SSL_CTX *ctx, int mode, int (*callback)(int ok, X509_STORE_CTX *store_ctx)); |
| 2866 |
|
| 2867 |
// SSL_set_verify configures certificate verification behavior. |mode| is one of |
| 2868 |
// the |SSL_VERIFY_*| values defined above. |callback| should be NULL. |
| 2869 |
// |
| 2870 |
// If |callback| is non-NULL, it is called as in |X509_STORE_CTX_set_verify_cb|, |
| 2871 |
// which is a deprecated and fragile mechanism to run the default certificate |
| 2872 |
// verification process, but suppress individual errors in it. See |
| 2873 |
// |X509_STORE_CTX_set_verify_cb| for details, If set, the callback may use |
| 2874 |
// |SSL_get_ex_data_X509_STORE_CTX_idx| with |X509_STORE_CTX_get_ex_data| to |
| 2875 |
// look up the |SSL| from |store_ctx|. |
| 2876 |
// |
| 2877 |
// WARNING: |callback| is not suitable for implementing custom certificate |
| 2878 |
// check, accepting all certificates, or extracting the certificate after |
| 2879 |
// verification. It does not replace the default process and is called multiple |
| 2880 |
// times throughout that process. It is also very difficult to implement this |
| 2881 |
// callback safely, without inadvertently relying on implementation details or |
| 2882 |
// making incorrect assumptions about when the callback is called. |
| 2883 |
// |
| 2884 |
// Instead, use |SSL_set_custom_verify| or |SSL_set_cert_verify_callback| to |
| 2885 |
// customize certificate verification. Those callbacks can inspect the peer-sent |
| 2886 |
// chain, call |X509_verify_cert| and inspect the result, or perform other |
| 2887 |
// operations more straightforwardly. |
| 2888 |
OPENSSL_EXPORT void SSL_set_verify(SSL *ssl, int mode, |
| 2889 |
int (*callback)(int ok, |
| 2890 |
X509_STORE_CTX *store_ctx)); |
| 2891 |
|
| 2892 |
enum ssl_verify_result_t { |
| 2893 |
ssl_verify_ok, |
| 2894 |
ssl_verify_invalid, |
| 2895 |
ssl_verify_retry |
| 2896 |
}; |
| 2897 |
|
| 2898 |
// SSL_CTX_set_custom_verify configures certificate verification. |mode| is one |
| 2899 |
// of the |SSL_VERIFY_*| values defined above. |callback| performs the |
| 2900 |
// certificate verification. |
| 2901 |
// |
| 2902 |
// The callback may call |SSL_get0_peer_certificates| for the certificate chain |
| 2903 |
// to validate. The callback should return |ssl_verify_ok| if the certificate is |
| 2904 |
// valid. If the certificate is invalid, the callback should return |
| 2905 |
// |ssl_verify_invalid| and optionally set |*out_alert| to an alert to send to |
| 2906 |
// the peer. Some useful alerts include |SSL_AD_CERTIFICATE_EXPIRED|, |
| 2907 |
// |SSL_AD_CERTIFICATE_REVOKED|, |SSL_AD_UNKNOWN_CA|, |SSL_AD_BAD_CERTIFICATE|, |
| 2908 |
// |SSL_AD_CERTIFICATE_UNKNOWN|, and |SSL_AD_INTERNAL_ERROR|. See RFC 5246 |
| 2909 |
// section 7.2.2 for their precise meanings. If unspecified, |
| 2910 |
// |SSL_AD_CERTIFICATE_UNKNOWN| will be sent by default. |
| 2911 |
// |
| 2912 |
// To verify a certificate asynchronously, the callback may return |
| 2913 |
// |ssl_verify_retry|. The handshake will then pause with |SSL_get_error| |
| 2914 |
// returning |SSL_ERROR_WANT_CERTIFICATE_VERIFY|. |
| 2915 |
OPENSSL_EXPORT void SSL_CTX_set_custom_verify( |
| 2916 |
SSL_CTX *ctx, int mode, |
| 2917 |
enum ssl_verify_result_t (*callback)(SSL *ssl, uint8_t *out_alert)); |
| 2918 |
|
| 2919 |
// SSL_set_custom_verify behaves like |SSL_CTX_set_custom_verify| but configures |
| 2920 |
// an individual |SSL|. |
| 2921 |
OPENSSL_EXPORT void SSL_set_custom_verify( |
| 2922 |
SSL *ssl, int mode, |
| 2923 |
enum ssl_verify_result_t (*callback)(SSL *ssl, uint8_t *out_alert)); |
| 2924 |
|
| 2925 |
// SSL_CTX_get_verify_mode returns |ctx|'s verify mode, set by |
| 2926 |
// |SSL_CTX_set_verify|. |
| 2927 |
OPENSSL_EXPORT int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); |
| 2928 |
|
| 2929 |
// SSL_get_verify_mode returns |ssl|'s verify mode, set by |SSL_CTX_set_verify| |
| 2930 |
// or |SSL_set_verify|. It returns -1 on error. |
| 2931 |
OPENSSL_EXPORT int SSL_get_verify_mode(const SSL *ssl); |
| 2932 |
|
| 2933 |
// SSL_CTX_get_verify_callback returns the callback set by |
| 2934 |
// |SSL_CTX_set_verify|. |
| 2935 |
OPENSSL_EXPORT int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))( |
| 2936 |
int ok, X509_STORE_CTX *store_ctx); |
| 2937 |
|
| 2938 |
// SSL_get_verify_callback returns the callback set by |SSL_CTX_set_verify| or |
| 2939 |
// |SSL_set_verify|. |
| 2940 |
OPENSSL_EXPORT int (*SSL_get_verify_callback(const SSL *ssl))( |
| 2941 |
int ok, X509_STORE_CTX *store_ctx); |
| 2942 |
|
| 2943 |
// SSL_set1_host sets a DNS name that will be required to be present in the |
| 2944 |
// verified leaf certificate. It returns one on success and zero on error. |
| 2945 |
// |
| 2946 |
// Note: unless _some_ name checking is performed, certificate validation is |
| 2947 |
// ineffective. Simply checking that a host has some certificate from a CA is |
| 2948 |
// rarely meaningful—you have to check that the CA believed that the host was |
| 2949 |
// who you expect to be talking to. |
| 2950 |
// |
| 2951 |
// By default, both subject alternative names and the subject's common name |
| 2952 |
// attribute are checked. The latter has long been deprecated, so callers should |
| 2953 |
// call |SSL_set_hostflags| with |X509_CHECK_FLAG_NEVER_CHECK_SUBJECT| to use |
| 2954 |
// the standard behavior. https://crbug.com/boringssl/464 tracks fixing the |
| 2955 |
// default. |
| 2956 |
OPENSSL_EXPORT int SSL_set1_host(SSL *ssl, const char *hostname); |
| 2957 |
|
| 2958 |
// SSL_set_hostflags calls |X509_VERIFY_PARAM_set_hostflags| on the |
| 2959 |
// |X509_VERIFY_PARAM| associated with this |SSL*|. |flags| should be some |
| 2960 |
// combination of the |X509_CHECK_*| constants. |
| 2961 |
// |
| 2962 |
// |X509_V_FLAG_X509_STRICT| is always ON by default and |
| 2963 |
// |X509_V_FLAG_ALLOW_PROXY_CERTS| is always OFF. Both are non-configurable. |
| 2964 |
// See |x509.h| for more details. |
| 2965 |
OPENSSL_EXPORT void SSL_set_hostflags(SSL *ssl, unsigned flags); |
| 2966 |
|
| 2967 |
// SSL_CTX_set_verify_depth sets the maximum depth of a certificate chain |
| 2968 |
// accepted in verification. This count excludes both the target certificate and |
| 2969 |
// the trust anchor (root certificate). |
| 2970 |
OPENSSL_EXPORT void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth); |
| 2971 |
|
| 2972 |
// SSL_set_verify_depth sets the maximum depth of a certificate chain accepted |
| 2973 |
// in verification. This count excludes both the target certificate and the |
| 2974 |
// trust anchor (root certificate). |
| 2975 |
OPENSSL_EXPORT void SSL_set_verify_depth(SSL *ssl, int depth); |
| 2976 |
|
| 2977 |
// SSL_CTX_get_verify_depth returns the maximum depth of a certificate accepted |
| 2978 |
// in verification. |
| 2979 |
OPENSSL_EXPORT int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); |
| 2980 |
|
| 2981 |
// SSL_get_verify_depth returns the maximum depth of a certificate accepted in |
| 2982 |
// verification. |
| 2983 |
OPENSSL_EXPORT int SSL_get_verify_depth(const SSL *ssl); |
| 2984 |
|
| 2985 |
// SSL_CTX_set1_param sets verification parameters from |param|. It returns one |
| 2986 |
// on success and zero on failure. The caller retains ownership of |param|. |
| 2987 |
OPENSSL_EXPORT int SSL_CTX_set1_param(SSL_CTX *ctx, |
| 2988 |
const X509_VERIFY_PARAM *param); |
| 2989 |
|
| 2990 |
// SSL_set1_param sets verification parameters from |param|. It returns one on |
| 2991 |
// success and zero on failure. The caller retains ownership of |param|. |
| 2992 |
OPENSSL_EXPORT int SSL_set1_param(SSL *ssl, const X509_VERIFY_PARAM *param); |
| 2993 |
|
| 2994 |
// SSL_CTX_get0_param returns |ctx|'s |X509_VERIFY_PARAM| for certificate |
| 2995 |
// verification. The caller must not release the returned pointer but may call |
| 2996 |
// functions on it to configure it. |
| 2997 |
OPENSSL_EXPORT X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx); |
| 2998 |
|
| 2999 |
// SSL_get0_param returns |ssl|'s |X509_VERIFY_PARAM| for certificate |
| 3000 |
// verification. The caller must not release the returned pointer but may call |
| 3001 |
// functions on it to configure it. |
| 3002 |
OPENSSL_EXPORT X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl); |
| 3003 |
|
| 3004 |
// SSL_CTX_set_purpose sets |ctx|'s |X509_VERIFY_PARAM|'s 'purpose' parameter to |
| 3005 |
// |purpose|. It returns one on success and zero on error. |
| 3006 |
OPENSSL_EXPORT int SSL_CTX_set_purpose(SSL_CTX *ctx, int purpose); |
| 3007 |
|
| 3008 |
// SSL_set_purpose sets |ssl|'s |X509_VERIFY_PARAM|'s 'purpose' parameter to |
| 3009 |
// |purpose|. It returns one on success and zero on error. |
| 3010 |
OPENSSL_EXPORT int SSL_set_purpose(SSL *ssl, int purpose); |
| 3011 |
|
| 3012 |
// SSL_CTX_set_trust sets |ctx|'s |X509_VERIFY_PARAM|'s 'trust' parameter to |
| 3013 |
// |trust|. It returns one on success and zero on error. |
| 3014 |
OPENSSL_EXPORT int SSL_CTX_set_trust(SSL_CTX *ctx, int trust); |
| 3015 |
|
| 3016 |
// SSL_set_trust sets |ssl|'s |X509_VERIFY_PARAM|'s 'trust' parameter to |
| 3017 |
// |trust|. It returns one on success and zero on error. |
| 3018 |
OPENSSL_EXPORT int SSL_set_trust(SSL *ssl, int trust); |
| 3019 |
|
| 3020 |
// SSL_CTX_set_cert_store sets |ctx|'s certificate store to |store|. It takes |
| 3021 |
// ownership of |store|. The store is used for certificate verification. |
| 3022 |
// |
| 3023 |
// The store is also used for the auto-chaining feature, but this is deprecated. |
| 3024 |
// See also |SSL_MODE_NO_AUTO_CHAIN|. |
| 3025 |
OPENSSL_EXPORT void SSL_CTX_set_cert_store(SSL_CTX *ctx, X509_STORE *store); |
| 3026 |
|
| 3027 |
// SSL_CTX_set1_cert_store is like |SSL_CTX_set_cert_store|, but does not take |
| 3028 |
// additional ownership of |store|. |
| 3029 |
OPENSSL_EXPORT void SSL_CTX_set1_cert_store(SSL_CTX *ctx, X509_STORE *store); |
| 3030 |
|
| 3031 |
// SSL_CTX_get_cert_store returns |ctx|'s certificate store. |
| 3032 |
OPENSSL_EXPORT X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx); |
| 3033 |
|
| 3034 |
// SSL_CTX_set_default_verify_paths calls |X509_STORE_set_default_paths| on |
| 3035 |
// |ctx|'s store. See that function for details. |
| 3036 |
// |
| 3037 |
// Using this function is not recommended. In OpenSSL, these defaults are |
| 3038 |
// determined by OpenSSL's install prefix. There is no corresponding concept for |
| 3039 |
// BoringSSL. Future versions of BoringSSL may change or remove this |
| 3040 |
// functionality. |
| 3041 |
OPENSSL_EXPORT int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); |
| 3042 |
|
| 3043 |
// SSL_CTX_load_verify_locations calls |X509_STORE_load_locations| on |ctx|'s |
| 3044 |
// store. See that function for details. |
| 3045 |
OPENSSL_EXPORT int SSL_CTX_load_verify_locations(SSL_CTX *ctx, |
| 3046 |
const char *ca_file, |
| 3047 |
const char *ca_dir); |
| 3048 |
|
| 3049 |
// SSL_get_verify_result returns the result of certificate verification. It is |
| 3050 |
// either |X509_V_OK| or a |X509_V_ERR_*| value. |
| 3051 |
OPENSSL_EXPORT long SSL_get_verify_result(const SSL *ssl); |
| 3052 |
|
| 3053 |
// SSL_set_verify_result sets the result of certificate verification. |
| 3054 |
OPENSSL_EXPORT void SSL_set_verify_result(SSL *ssl, long arg); |
| 3055 |
|
| 3056 |
// SSL_alert_from_verify_result returns the SSL alert code, such as |
| 3057 |
// |SSL_AD_CERTIFICATE_EXPIRED|, that corresponds to an |X509_V_ERR_*| value. |
| 3058 |
// The return value is always an alert, even when |result| is |X509_V_OK|. |
| 3059 |
OPENSSL_EXPORT int SSL_alert_from_verify_result(long result); |
| 3060 |
|
| 3061 |
// SSL_get_ex_data_X509_STORE_CTX_idx returns the ex_data index used to look up |
| 3062 |
// the |SSL| associated with an |X509_STORE_CTX| in the verify callback. |
| 3063 |
OPENSSL_EXPORT int SSL_get_ex_data_X509_STORE_CTX_idx(void); |
| 3064 |
|
| 3065 |
// SSL_CTX_set_cert_verify_callback sets a custom callback to be called on |
| 3066 |
// certificate verification rather than |X509_verify_cert|. |store_ctx| contains |
| 3067 |
// the verification parameters. The callback should return one on success and |
| 3068 |
// zero on fatal error. It may use |X509_STORE_CTX_set_error| to set a |
| 3069 |
// verification result. |
| 3070 |
// |
| 3071 |
// The callback may use |SSL_get_ex_data_X509_STORE_CTX_idx| to recover the |
| 3072 |
// |SSL| object from |store_ctx|. |
| 3073 |
OPENSSL_EXPORT void SSL_CTX_set_cert_verify_callback( |
| 3074 |
SSL_CTX *ctx, int (*callback)(X509_STORE_CTX *store_ctx, void *arg), |
| 3075 |
void *arg); |
| 3076 |
|
| 3077 |
// SSL_enable_signed_cert_timestamps causes |ssl| (which must be the client end |
| 3078 |
// of a connection) to request SCTs from the server. See |
| 3079 |
// https://tools.ietf.org/html/rfc6962. |
| 3080 |
// |
| 3081 |
// Call |SSL_get0_signed_cert_timestamp_list| to recover the SCT after the |
| 3082 |
// handshake. |
| 3083 |
OPENSSL_EXPORT void SSL_enable_signed_cert_timestamps(SSL *ssl); |
| 3084 |
|
| 3085 |
// SSL_CTX_enable_signed_cert_timestamps enables SCT requests on all client SSL |
| 3086 |
// objects created from |ctx|. |
| 3087 |
// |
| 3088 |
// Call |SSL_get0_signed_cert_timestamp_list| to recover the SCT after the |
| 3089 |
// handshake. |
| 3090 |
OPENSSL_EXPORT void SSL_CTX_enable_signed_cert_timestamps(SSL_CTX *ctx); |
| 3091 |
|
| 3092 |
// SSL_enable_ocsp_stapling causes |ssl| (which must be the client end of a |
| 3093 |
// connection) to request a stapled OCSP response from the server. |
| 3094 |
// |
| 3095 |
// Call |SSL_get0_ocsp_response| to recover the OCSP response after the |
| 3096 |
// handshake. |
| 3097 |
OPENSSL_EXPORT void SSL_enable_ocsp_stapling(SSL *ssl); |
| 3098 |
|
| 3099 |
// SSL_CTX_enable_ocsp_stapling enables OCSP stapling on all client SSL objects |
| 3100 |
// created from |ctx|. |
| 3101 |
// |
| 3102 |
// Call |SSL_get0_ocsp_response| to recover the OCSP response after the |
| 3103 |
// handshake. |
| 3104 |
OPENSSL_EXPORT void SSL_CTX_enable_ocsp_stapling(SSL_CTX *ctx); |
| 3105 |
|
| 3106 |
// SSL_CTX_set0_verify_cert_store sets an |X509_STORE| that will be used |
| 3107 |
// exclusively for certificate verification and returns one. Ownership of |
| 3108 |
// |store| is transferred to the |SSL_CTX|. |
| 3109 |
OPENSSL_EXPORT int SSL_CTX_set0_verify_cert_store(SSL_CTX *ctx, |
| 3110 |
X509_STORE *store); |
| 3111 |
|
| 3112 |
// SSL_CTX_set1_verify_cert_store sets an |X509_STORE| that will be used |
| 3113 |
// exclusively for certificate verification and returns one. An additional |
| 3114 |
// reference to |store| will be taken. |
| 3115 |
OPENSSL_EXPORT int SSL_CTX_set1_verify_cert_store(SSL_CTX *ctx, |
| 3116 |
X509_STORE *store); |
| 3117 |
|
| 3118 |
// SSL_set0_verify_cert_store sets an |X509_STORE| that will be used |
| 3119 |
// exclusively for certificate verification and returns one. Ownership of |
| 3120 |
// |store| is transferred to the |SSL|. |
| 3121 |
OPENSSL_EXPORT int SSL_set0_verify_cert_store(SSL *ssl, X509_STORE *store); |
| 3122 |
|
| 3123 |
// SSL_set1_verify_cert_store sets an |X509_STORE| that will be used |
| 3124 |
// exclusively for certificate verification and returns one. An additional |
| 3125 |
// reference to |store| will be taken. |
| 3126 |
OPENSSL_EXPORT int SSL_set1_verify_cert_store(SSL *ssl, X509_STORE *store); |
| 3127 |
|
| 3128 |
// SSL_CTX_set_verify_algorithm_prefs configures |ctx| to use |prefs| as the |
| 3129 |
// preference list when verifying signatures from the peer's long-term key. It |
| 3130 |
// returns one on zero on error. |prefs| should not include the internal-only |
| 3131 |
// value |SSL_SIGN_RSA_PKCS1_MD5_SHA1|. |
| 3132 |
OPENSSL_EXPORT int SSL_CTX_set_verify_algorithm_prefs(SSL_CTX *ctx, |
| 3133 |
const uint16_t *prefs, |
| 3134 |
size_t num_prefs); |
| 3135 |
|
| 3136 |
// SSL_set_verify_algorithm_prefs configures |ssl| to use |prefs| as the |
| 3137 |
// preference list when verifying signatures from the peer's long-term key. It |
| 3138 |
// returns one on zero on error. |prefs| should not include the internal-only |
| 3139 |
// value |SSL_SIGN_RSA_PKCS1_MD5_SHA1|. |
| 3140 |
OPENSSL_EXPORT int SSL_set_verify_algorithm_prefs(SSL *ssl, |
| 3141 |
const uint16_t *prefs, |
| 3142 |
size_t num_prefs); |
| 3143 |
|
| 3144 |
// Client certificate CA list. |
| 3145 |
// |
| 3146 |
// When requesting a client certificate, a server may advertise a list of |
| 3147 |
// certificate authorities which are accepted. These functions may be used to |
| 3148 |
// configure this list. |
| 3149 |
|
| 3150 |
// SSL_set_client_CA_list sets |ssl|'s client certificate CA list to |
| 3151 |
// |name_list|. It takes ownership of and frees |name_list|. |
| 3152 |
OPENSSL_EXPORT void SSL_set_client_CA_list(SSL *ssl, |
| 3153 |
STACK_OF(X509_NAME) *name_list); |
| 3154 |
|
| 3155 |
// SSL_CTX_set_client_CA_list sets |ctx|'s client certificate CA list to |
| 3156 |
// |name_list|. It takes ownership of and frees |name_list|. |
| 3157 |
OPENSSL_EXPORT void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, |
| 3158 |
STACK_OF(X509_NAME) *name_list); |
| 3159 |
|
| 3160 |
// SSL_set0_client_CAs sets |ssl|'s client certificate CA list to |name_list|, |
| 3161 |
// which should contain DER-encoded distinguished names (RFC 5280). It takes |
| 3162 |
// ownership of |name_list|. |
| 3163 |
OPENSSL_EXPORT void SSL_set0_client_CAs(SSL *ssl, |
| 3164 |
STACK_OF(CRYPTO_BUFFER) *name_list); |
| 3165 |
|
| 3166 |
// SSL_CTX_set0_client_CAs sets |ctx|'s client certificate CA list to |
| 3167 |
// |name_list|, which should contain DER-encoded distinguished names (RFC 5280). |
| 3168 |
// It takes ownership of |name_list|. |
| 3169 |
OPENSSL_EXPORT void SSL_CTX_set0_client_CAs(SSL_CTX *ctx, |
| 3170 |
STACK_OF(CRYPTO_BUFFER) *name_list); |
| 3171 |
|
| 3172 |
// SSL_get_client_CA_list returns |ssl|'s client certificate CA list. If |ssl| |
| 3173 |
// has not been configured as a client, this is the list configured by |
| 3174 |
// |SSL_CTX_set_client_CA_list|. |
| 3175 |
// |
| 3176 |
// If configured as a client, it returns the client certificate CA list sent by |
| 3177 |
// the server. This may be called during the callbacks set by |
| 3178 |
// |SSL_CTX_set_cert_cb| and |SSL_CTX_set_client_cert_cb|, when the handshake |
| 3179 |
// is paused because of them, or after the handshake has completed. |
| 3180 |
OPENSSL_EXPORT STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *ssl); |
| 3181 |
|
| 3182 |
// SSL_get0_server_requested_CAs returns the CAs sent by a server to guide a |
| 3183 |
// client in certificate selection. They are a series of DER-encoded X.509 |
| 3184 |
// names. This function may only be called during a callback set by |
| 3185 |
// |SSL_CTX_set_cert_cb| or when the handshake is paused because of it. |
| 3186 |
// |
| 3187 |
// The returned stack is owned by |ssl|, as are its contents. It should not be |
| 3188 |
// used past the point where the handshake is restarted after the callback. |
| 3189 |
OPENSSL_EXPORT const STACK_OF(CRYPTO_BUFFER) *SSL_get0_server_requested_CAs( |
| 3190 |
const SSL *ssl); |
| 3191 |
|
| 3192 |
// SSL_CTX_get_client_CA_list returns |ctx|'s client certificate CA list. |
| 3193 |
OPENSSL_EXPORT STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list( |
| 3194 |
const SSL_CTX *ctx); |
| 3195 |
|
| 3196 |
// SSL_add_client_CA appends |x509|'s subject to the client certificate CA list. |
| 3197 |
// It returns one on success or zero on error. The caller retains ownership of |
| 3198 |
// |x509|. |
| 3199 |
OPENSSL_EXPORT int SSL_add_client_CA(SSL *ssl, X509 *x509); |
| 3200 |
|
| 3201 |
// SSL_CTX_add_client_CA appends |x509|'s subject to the client certificate CA |
| 3202 |
// list. It returns one on success or zero on error. The caller retains |
| 3203 |
// ownership of |x509|. |
| 3204 |
OPENSSL_EXPORT int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x509); |
| 3205 |
|
| 3206 |
// SSL_load_client_CA_file opens |file| and reads PEM-encoded certificates from |
| 3207 |
// it. It returns a newly-allocated stack of the certificate subjects or NULL |
| 3208 |
// on error. Duplicates in |file| are ignored. |
| 3209 |
OPENSSL_EXPORT STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); |
| 3210 |
|
| 3211 |
// SSL_dup_CA_list makes a deep copy of |list|. It returns the new list on |
| 3212 |
// success or NULL on allocation error. |
| 3213 |
OPENSSL_EXPORT STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *list); |
| 3214 |
|
| 3215 |
// SSL_add_file_cert_subjects_to_stack behaves like |SSL_load_client_CA_file| |
| 3216 |
// but appends the result to |out|. It returns one on success or zero on |
| 3217 |
// error. |
| 3218 |
OPENSSL_EXPORT int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *out, |
| 3219 |
const char *file); |
| 3220 |
|
| 3221 |
// SSL_add_bio_cert_subjects_to_stack behaves like |
| 3222 |
// |SSL_add_file_cert_subjects_to_stack| but reads from |bio|. |
| 3223 |
OPENSSL_EXPORT int SSL_add_bio_cert_subjects_to_stack(STACK_OF(X509_NAME) *out, |
| 3224 |
BIO *bio); |
| 3225 |
|
| 3226 |
|
| 3227 |
// Server name indication. |
| 3228 |
// |
| 3229 |
// The server_name extension (RFC 3546) allows the client to advertise the name |
| 3230 |
// of the server it is connecting to. This is used in virtual hosting |
| 3231 |
// deployments to select one of a several certificates on a single IP. Only the |
| 3232 |
// host_name name type is supported. |
| 3233 |
|
| 3234 |
#define TLSEXT_NAMETYPE_host_name 0 |
| 3235 |
|
| 3236 |
// SSL_set_tlsext_host_name, for a client, configures |ssl| to advertise |name| |
| 3237 |
// in the server_name extension. It returns one on success and zero on error. |
| 3238 |
OPENSSL_EXPORT int SSL_set_tlsext_host_name(SSL *ssl, const char *name); |
| 3239 |
|
| 3240 |
// SSL_get_servername, for a server, returns the hostname supplied by the |
| 3241 |
// client or NULL if there was none. The |type| argument must be |
| 3242 |
// |TLSEXT_NAMETYPE_host_name|. |
| 3243 |
OPENSSL_EXPORT const char *SSL_get_servername(const SSL *ssl, const int type); |
| 3244 |
|
| 3245 |
// SSL_get_servername_type, for a server, returns |TLSEXT_NAMETYPE_host_name| |
| 3246 |
// if the client sent a hostname and -1 otherwise. |
| 3247 |
OPENSSL_EXPORT int SSL_get_servername_type(const SSL *ssl); |
| 3248 |
|
| 3249 |
// SSL_CTX_set_tlsext_servername_callback configures |callback| to be called on |
| 3250 |
// the server after ClientHello extensions have been parsed and returns one. |
| 3251 |
// The callback may use |SSL_get_servername| to examine the server_name |
| 3252 |
// extension and returns a |SSL_TLSEXT_ERR_*| value. The value of |arg| may be |
| 3253 |
// set by calling |SSL_CTX_set_tlsext_servername_arg|. |
| 3254 |
// |
| 3255 |
// If the callback returns |SSL_TLSEXT_ERR_NOACK|, the server_name extension is |
| 3256 |
// not acknowledged in the ServerHello. If the return value is |
| 3257 |
// |SSL_TLSEXT_ERR_ALERT_FATAL|, then |*out_alert| is the alert to send, |
| 3258 |
// defaulting to |SSL_AD_UNRECOGNIZED_NAME|. |SSL_TLSEXT_ERR_ALERT_WARNING| is |
| 3259 |
// ignored and treated as |SSL_TLSEXT_ERR_OK|. |
| 3260 |
OPENSSL_EXPORT int SSL_CTX_set_tlsext_servername_callback( |
| 3261 |
SSL_CTX *ctx, int (*callback)(SSL *ssl, int *out_alert, void *arg)); |
| 3262 |
|
| 3263 |
// SSL_CTX_set_tlsext_servername_arg sets the argument to the servername |
| 3264 |
// callback and returns one. See |SSL_CTX_set_tlsext_servername_callback|. |
| 3265 |
OPENSSL_EXPORT int SSL_CTX_set_tlsext_servername_arg(SSL_CTX *ctx, void *arg); |
| 3266 |
|
| 3267 |
// SSL_TLSEXT_ERR_* are values returned by some extension-related callbacks. |
| 3268 |
#define SSL_TLSEXT_ERR_OK 0 |
| 3269 |
#define SSL_TLSEXT_ERR_ALERT_WARNING 1 |
| 3270 |
#define SSL_TLSEXT_ERR_ALERT_FATAL 2 |
| 3271 |
#define SSL_TLSEXT_ERR_NOACK 3 |
| 3272 |
|
| 3273 |
// SSL_set_SSL_CTX changes |ssl|'s |SSL_CTX|. |ssl| will use the |
| 3274 |
// certificate-related settings from |ctx|, and |SSL_get_SSL_CTX| will report |
| 3275 |
// |ctx|. This function may be used during the callbacks registered by |
| 3276 |
// |SSL_CTX_set_select_certificate_cb|, |
| 3277 |
// |SSL_CTX_set_tlsext_servername_callback|, and |SSL_CTX_set_cert_cb| or when |
| 3278 |
// the handshake is paused from them. It is typically used to switch |
| 3279 |
// certificates based on SNI. |
| 3280 |
// |
| 3281 |
// Note the session cache and related settings will continue to use the initial |
| 3282 |
// |SSL_CTX|. Callers should use |SSL_CTX_set_session_id_context| to partition |
| 3283 |
// the session cache between different domains. |
| 3284 |
// |
| 3285 |
// TODO(davidben): Should other settings change after this call? |
| 3286 |
OPENSSL_EXPORT SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx); |
| 3287 |
|
| 3288 |
|
| 3289 |
// Application-layer protocol negotiation. |
| 3290 |
// |
| 3291 |
// The ALPN extension (RFC 7301) allows negotiating different application-layer |
| 3292 |
// protocols over a single port. This is used, for example, to negotiate |
| 3293 |
// HTTP/2. |
| 3294 |
|
| 3295 |
// SSL_CTX_set_alpn_protos sets the client ALPN protocol list on |ctx| to |
| 3296 |
// |protos|. |protos| must be in wire-format (i.e. a series of non-empty, 8-bit |
| 3297 |
// length-prefixed strings), or the empty string to disable ALPN. It returns |
| 3298 |
// zero on success and one on failure. Configuring a non-empty string enables |
| 3299 |
// ALPN on a client. |
| 3300 |
// |
| 3301 |
// WARNING: this function is dangerous because it breaks the usual return value |
| 3302 |
// convention. |
| 3303 |
OPENSSL_EXPORT int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const uint8_t *protos, |
| 3304 |
size_t protos_len); |
| 3305 |
|
| 3306 |
// SSL_set_alpn_protos sets the client ALPN protocol list on |ssl| to |protos|. |
| 3307 |
// |protos| must be in wire-format (i.e. a series of non-empty, 8-bit |
| 3308 |
// length-prefixed strings), or the empty string to disable ALPN. It returns |
| 3309 |
// zero on success and one on failure. Configuring a non-empty string enables |
| 3310 |
// ALPN on a client. |
| 3311 |
// |
| 3312 |
// WARNING: this function is dangerous because it breaks the usual return value |
| 3313 |
// convention. |
| 3314 |
OPENSSL_EXPORT int SSL_set_alpn_protos(SSL *ssl, const uint8_t *protos, |
| 3315 |
size_t protos_len); |
| 3316 |
|
| 3317 |
// SSL_CTX_set_alpn_select_cb sets a callback function on |ctx| that is called |
| 3318 |
// during ClientHello processing in order to select an ALPN protocol from the |
| 3319 |
// client's list of offered protocols. |SSL_select_next_proto| is an optional |
| 3320 |
// utility function which may be useful in implementing this callback. |
| 3321 |
// |
| 3322 |
// The callback is passed a wire-format (i.e. a series of non-empty, 8-bit |
| 3323 |
// length-prefixed strings) ALPN protocol list in |in|. To select a protocol, |
| 3324 |
// the callback should set |*out| and |*out_len| to the selected protocol and |
| 3325 |
// return |SSL_TLSEXT_ERR_OK| on success. It does not pass ownership of the |
| 3326 |
// buffer, so |*out| should point to a static string, a buffer that outlives the |
| 3327 |
// callback call, or the corresponding entry in |in|. |
| 3328 |
// |
| 3329 |
// If the server supports ALPN, but there are no protocols in common, the |
| 3330 |
// callback should return |SSL_TLSEXT_ERR_ALERT_FATAL| to abort the connection |
| 3331 |
// with a no_application_protocol alert. |
| 3332 |
// |
| 3333 |
// If the server does not support ALPN, it can return |SSL_TLSEXT_ERR_NOACK| to |
| 3334 |
// continue the handshake without negotiating a protocol. This may be useful if |
| 3335 |
// multiple server configurations share an |SSL_CTX|, only some of which have |
| 3336 |
// ALPN protocols configured. |
| 3337 |
// |
| 3338 |
// |SSL_TLSEXT_ERR_ALERT_WARNING| is ignored and will be treated as |
| 3339 |
// |SSL_TLSEXT_ERR_NOACK|. |
| 3340 |
// |
| 3341 |
// The callback will only be called if the client supports ALPN. Callers that |
| 3342 |
// wish to require ALPN for all clients must check |SSL_get0_alpn_selected| |
| 3343 |
// after the handshake. In QUIC connections, this is done automatically. |
| 3344 |
// |
| 3345 |
// The cipher suite is selected before negotiating ALPN. The callback may use |
| 3346 |
// |SSL_get_pending_cipher| to query the cipher suite. This may be used to |
| 3347 |
// implement HTTP/2's cipher suite constraints. |
| 3348 |
OPENSSL_EXPORT void SSL_CTX_set_alpn_select_cb( |
| 3349 |
SSL_CTX *ctx, |
| 3350 |
int (*cb)(SSL *ssl, const uint8_t **out, uint8_t *out_len, |
| 3351 |
const uint8_t *in, unsigned in_len, void *arg), |
| 3352 |
void *arg); |
| 3353 |
|
| 3354 |
// SSL_get0_alpn_selected gets the selected ALPN protocol (if any) from |ssl|. |
| 3355 |
// On return it sets |*out_data| to point to |*out_len| bytes of protocol name |
| 3356 |
// (not including the leading length-prefix byte). If the server didn't respond |
| 3357 |
// with a negotiated protocol then |*out_len| will be zero. |
| 3358 |
OPENSSL_EXPORT void SSL_get0_alpn_selected(const SSL *ssl, |
| 3359 |
const uint8_t **out_data, |
| 3360 |
unsigned *out_len); |
| 3361 |
|
| 3362 |
// SSL_CTX_set_allow_unknown_alpn_protos configures client connections on |ctx| |
| 3363 |
// to allow unknown ALPN protocols from the server. Otherwise, by default, the |
| 3364 |
// client will require that the protocol be advertised in |
| 3365 |
// |SSL_CTX_set_alpn_protos|. |
| 3366 |
OPENSSL_EXPORT void SSL_CTX_set_allow_unknown_alpn_protos(SSL_CTX *ctx, |
| 3367 |
int enabled); |
| 3368 |
|
| 3369 |
|
| 3370 |
// Application-layer protocol settings |
| 3371 |
// |
| 3372 |
// The ALPS extension (draft-vvv-tls-alps) allows exchanging application-layer |
| 3373 |
// settings in the TLS handshake for applications negotiated with ALPN. Note |
| 3374 |
// that, when ALPS is negotiated, the client and server each advertise their own |
| 3375 |
// settings, so there are functions to both configure setting to send and query |
| 3376 |
// received settings. |
| 3377 |
|
| 3378 |
// SSL_add_application_settings configures |ssl| to enable ALPS with ALPN |
| 3379 |
// protocol |proto|, sending an ALPS value of |settings|. It returns one on |
| 3380 |
// success and zero on error. If |proto| is negotiated via ALPN and the peer |
| 3381 |
// supports ALPS, |settings| will be sent to the peer. The peer's ALPS value can |
| 3382 |
// be retrieved with |SSL_get0_peer_application_settings|. |
| 3383 |
// |
| 3384 |
// On the client, this function should be called before the handshake, once for |
| 3385 |
// each supported ALPN protocol which uses ALPS. |proto| must be included in the |
| 3386 |
// client's ALPN configuration (see |SSL_CTX_set_alpn_protos| and |
| 3387 |
// |SSL_set_alpn_protos|). On the server, ALPS can be preconfigured for each |
| 3388 |
// protocol as in the client, or configuration can be deferred to the ALPN |
| 3389 |
// callback (see |SSL_CTX_set_alpn_select_cb|), in which case only the selected |
| 3390 |
// protocol needs to be configured. |
| 3391 |
// |
| 3392 |
// ALPS can be independently configured from 0-RTT, however changes in protocol |
| 3393 |
// settings will fallback to 1-RTT to negotiate the new value, so it is |
| 3394 |
// recommended for |settings| to be relatively stable. |
| 3395 |
OPENSSL_EXPORT int SSL_add_application_settings(SSL *ssl, const uint8_t *proto, |
| 3396 |
size_t proto_len, |
| 3397 |
const uint8_t *settings, |
| 3398 |
size_t settings_len); |
| 3399 |
|
| 3400 |
// SSL_get0_peer_application_settings sets |*out_data| and |*out_len| to a |
| 3401 |
// buffer containing the peer's ALPS value, or the empty string if ALPS was not |
| 3402 |
// negotiated. Note an empty string could also indicate the peer sent an empty |
| 3403 |
// settings value. Use |SSL_has_application_settings| to check if ALPS was |
| 3404 |
// negotiated. The output buffer is owned by |ssl| and is valid until the next |
| 3405 |
// time |ssl| is modified. |
| 3406 |
OPENSSL_EXPORT void SSL_get0_peer_application_settings(const SSL *ssl, |
| 3407 |
const uint8_t **out_data, |
| 3408 |
size_t *out_len); |
| 3409 |
|
| 3410 |
// SSL_has_application_settings returns one if ALPS was negotiated on this |
| 3411 |
// connection and zero otherwise. |
| 3412 |
OPENSSL_EXPORT int SSL_has_application_settings(const SSL *ssl); |
| 3413 |
|
| 3414 |
// SSL_set_alps_use_new_codepoint configures whether to use the new ALPS |
| 3415 |
// codepoint. By default, the old codepoint is used. |
| 3416 |
OPENSSL_EXPORT void SSL_set_alps_use_new_codepoint(SSL *ssl, int use_new); |
| 3417 |
|
| 3418 |
|
| 3419 |
// Certificate compression. |
| 3420 |
// |
| 3421 |
// Certificates in TLS 1.3 can be compressed (RFC 8879). BoringSSL supports this |
| 3422 |
// as both a client and a server, but does not link against any specific |
| 3423 |
// compression libraries in order to keep dependencies to a minimum. Instead, |
| 3424 |
// hooks for compression and decompression can be installed in an |SSL_CTX| to |
| 3425 |
// enable support. |
| 3426 |
|
| 3427 |
// ssl_cert_compression_func_t is a pointer to a function that performs |
| 3428 |
// compression. It must write the compressed representation of |in| to |out|, |
| 3429 |
// returning one on success and zero on error. The results of compressing |
| 3430 |
// certificates are not cached internally. Implementations may wish to implement |
| 3431 |
// their own cache if they expect it to be useful given the certificates that |
| 3432 |
// they serve. |
| 3433 |
typedef int (*ssl_cert_compression_func_t)(SSL *ssl, CBB *out, |
| 3434 |
const uint8_t *in, size_t in_len); |
| 3435 |
|
| 3436 |
// ssl_cert_decompression_func_t is a pointer to a function that performs |
| 3437 |
// decompression. The compressed data from the peer is passed as |in| and the |
| 3438 |
// decompressed result must be exactly |uncompressed_len| bytes long. It returns |
| 3439 |
// one on success, in which case |*out| must be set to the result of |
| 3440 |
// decompressing |in|, or zero on error. Setting |*out| transfers ownership, |
| 3441 |
// i.e. |CRYPTO_BUFFER_free| will be called on |*out| at some point in the |
| 3442 |
// future. The results of decompressions are not cached internally. |
| 3443 |
// Implementations may wish to implement their own cache if they expect it to be |
| 3444 |
// useful. |
| 3445 |
typedef int (*ssl_cert_decompression_func_t)(SSL *ssl, CRYPTO_BUFFER **out, |
| 3446 |
size_t uncompressed_len, |
| 3447 |
const uint8_t *in, size_t in_len); |
| 3448 |
|
| 3449 |
// SSL_CTX_add_cert_compression_alg registers a certificate compression |
| 3450 |
// algorithm on |ctx| with ID |alg_id|. (The value of |alg_id| should be an IANA |
| 3451 |
// assigned value and each can only be registered once.) |
| 3452 |
// |
| 3453 |
// One of the function pointers may be NULL to avoid having to implement both |
| 3454 |
// sides of a compression algorithm if you're only going to use it in one |
| 3455 |
// direction. In this case, the unimplemented direction acts like it was never |
| 3456 |
// configured. |
| 3457 |
// |
| 3458 |
// For a server, algorithms are registered in preference order with the most |
| 3459 |
// preferable first. It returns one on success or zero on error. |
| 3460 |
OPENSSL_EXPORT int SSL_CTX_add_cert_compression_alg( |
| 3461 |
SSL_CTX *ctx, uint16_t alg_id, ssl_cert_compression_func_t compress, |
| 3462 |
ssl_cert_decompression_func_t decompress); |
| 3463 |
|
| 3464 |
|
| 3465 |
// Next protocol negotiation. |
| 3466 |
// |
| 3467 |
// The NPN extension (draft-agl-tls-nextprotoneg-03) is the predecessor to ALPN |
| 3468 |
// and deprecated in favor of it. |
| 3469 |
|
| 3470 |
// SSL_CTX_set_next_protos_advertised_cb sets a callback that is called when a |
| 3471 |
// TLS server needs a list of supported protocols for Next Protocol |
| 3472 |
// Negotiation. The returned list must be in wire format. The list is returned |
| 3473 |
// by setting |*out| to point to it and |*out_len| to its length. This memory |
| 3474 |
// will not be modified, but one should assume that |ssl| keeps a reference to |
| 3475 |
// it. |
| 3476 |
// |
| 3477 |
// The callback should return |SSL_TLSEXT_ERR_OK| if it wishes to advertise. |
| 3478 |
// Otherwise, no such extension will be included in the ServerHello. |
| 3479 |
OPENSSL_EXPORT void SSL_CTX_set_next_protos_advertised_cb( |
| 3480 |
SSL_CTX *ctx, |
| 3481 |
int (*cb)(SSL *ssl, const uint8_t **out, unsigned *out_len, void *arg), |
| 3482 |
void *arg); |
| 3483 |
|
| 3484 |
// SSL_CTX_set_next_proto_select_cb sets a callback that is called when a client |
| 3485 |
// needs to select a protocol from the server's provided list. |*out| must be |
| 3486 |
// set to point to the selected protocol (which may be within |in|). The length |
| 3487 |
// of the protocol name must be written into |*out_len|. The server's advertised |
| 3488 |
// protocols are provided in |in| and |in_len|. The callback can assume that |
| 3489 |
// |in| is syntactically valid. |SSL_select_next_proto| is an optional utility |
| 3490 |
// function which may be useful in implementing this callback. |
| 3491 |
// |
| 3492 |
// The client must select a protocol. It is fatal to the connection if this |
| 3493 |
// callback returns a value other than |SSL_TLSEXT_ERR_OK|. |
| 3494 |
// |
| 3495 |
// Configuring this callback enables NPN on a client. |
| 3496 |
OPENSSL_EXPORT void SSL_CTX_set_next_proto_select_cb( |
| 3497 |
SSL_CTX *ctx, |
| 3498 |
int (*cb)(SSL *ssl, uint8_t **out, uint8_t *out_len, const uint8_t *in, |
| 3499 |
unsigned in_len, void *arg), |
| 3500 |
void *arg); |
| 3501 |
|
| 3502 |
// SSL_get0_next_proto_negotiated sets |*out_data| and |*out_len| to point to |
| 3503 |
// the client's requested protocol for this connection. If the client didn't |
| 3504 |
// request any protocol, then |*out_data| is set to NULL. |
| 3505 |
// |
| 3506 |
// Note that the client can request any protocol it chooses. The value returned |
| 3507 |
// from this function need not be a member of the list of supported protocols |
| 3508 |
// provided by the server. |
| 3509 |
OPENSSL_EXPORT void SSL_get0_next_proto_negotiated(const SSL *ssl, |
| 3510 |
const uint8_t **out_data, |
| 3511 |
unsigned *out_len); |
| 3512 |
|
| 3513 |
// SSL_select_next_proto implements the standard protocol selection for either |
| 3514 |
// ALPN servers or NPN clients. It is expected that this function is called from |
| 3515 |
// the callback set by |SSL_CTX_set_alpn_select_cb| or |
| 3516 |
// |SSL_CTX_set_next_proto_select_cb|. |
| 3517 |
// |
| 3518 |
// |peer| and |supported| contain the peer and locally-configured protocols, |
| 3519 |
// respectively. This function finds the first protocol in |peer| which is also |
| 3520 |
// in |supported|. If one was found, it sets |*out| and |*out_len| to point to |
| 3521 |
// it and returns |OPENSSL_NPN_NEGOTIATED|. Otherwise, it returns |
| 3522 |
// |OPENSSL_NPN_NO_OVERLAP| and sets |*out| and |*out_len| to the first |
| 3523 |
// supported protocol. |
| 3524 |
// |
| 3525 |
// In ALPN, the server should only select protocols among those that the client |
| 3526 |
// offered. Thus, if this function returns |OPENSSL_NPN_NO_OVERLAP|, the caller |
| 3527 |
// should ignore |*out| and return |SSL_TLSEXT_ERR_ALERT_FATAL| from |
| 3528 |
// |SSL_CTX_set_alpn_select_cb|'s callback to indicate there was no match. |
| 3529 |
// |
| 3530 |
// In NPN, the client may either select one of the server's protocols, or an |
| 3531 |
// "opportunistic" protocol as described in Section 6 of |
| 3532 |
// draft-agl-tls-nextprotoneg-03. When this function returns |
| 3533 |
// |OPENSSL_NPN_NO_OVERLAP|, |*out| implicitly selects the first supported |
| 3534 |
// protocol for use as the opportunistic protocol. The caller may use it, |
| 3535 |
// ignore it and select a different opportunistic protocol, or ignore it and |
| 3536 |
// select no protocol (empty string). |
| 3537 |
// |
| 3538 |
// |peer| and |supported| must be vectors of 8-bit, length-prefixed byte |
| 3539 |
// strings. The length byte itself is not included in the length. A byte string |
| 3540 |
// of length 0 is invalid. No byte string may be truncated. |supported| must be |
| 3541 |
// non-empty; a caller that supports no ALPN/NPN protocols should skip |
| 3542 |
// negotiating the extension, rather than calling this function. If any of these |
| 3543 |
// preconditions do not hold, this function will return |OPENSSL_NPN_NO_OVERLAP| |
| 3544 |
// and set |*out| and |*out_len| to an empty buffer for robustness, but callers |
| 3545 |
// are not recommended to rely on this. An empty buffer is not a valid output |
| 3546 |
// for |SSL_CTX_set_alpn_select_cb|'s callback. |
| 3547 |
// |
| 3548 |
// WARNING: |*out| and |*out_len| may alias either |peer| or |supported| and may |
| 3549 |
// not be used after one of those buffers is modified or released. Additionally, |
| 3550 |
// this function is not const-correct for compatibility reasons. Although |*out| |
| 3551 |
// is a non-const pointer, callers may not modify the buffer though |*out|. |
| 3552 |
OPENSSL_EXPORT int SSL_select_next_proto(uint8_t **out, uint8_t *out_len, |
| 3553 |
const uint8_t *peer, unsigned peer_len, |
| 3554 |
const uint8_t *supported, |
| 3555 |
unsigned supported_len); |
| 3556 |
|
| 3557 |
#define OPENSSL_NPN_UNSUPPORTED 0 |
| 3558 |
#define OPENSSL_NPN_NEGOTIATED 1 |
| 3559 |
#define OPENSSL_NPN_NO_OVERLAP 2 |
| 3560 |
|
| 3561 |
|
| 3562 |
// Channel ID. |
| 3563 |
// |
| 3564 |
// See draft-balfanz-tls-channelid-01. This is an old, experimental mechanism |
| 3565 |
// and should not be used in new code. |
| 3566 |
|
| 3567 |
// SSL_CTX_set_tls_channel_id_enabled configures whether connections associated |
| 3568 |
// with |ctx| should enable Channel ID as a server. |
| 3569 |
OPENSSL_EXPORT void SSL_CTX_set_tls_channel_id_enabled(SSL_CTX *ctx, |
| 3570 |
int enabled); |
| 3571 |
|
| 3572 |
// SSL_set_tls_channel_id_enabled configures whether |ssl| should enable Channel |
| 3573 |
// ID as a server. |
| 3574 |
OPENSSL_EXPORT void SSL_set_tls_channel_id_enabled(SSL *ssl, int enabled); |
| 3575 |
|
| 3576 |
// SSL_CTX_set1_tls_channel_id configures a TLS client to send a TLS Channel ID |
| 3577 |
// to compatible servers. |private_key| must be a P-256 EC key. It returns one |
| 3578 |
// on success and zero on error. |
| 3579 |
OPENSSL_EXPORT int SSL_CTX_set1_tls_channel_id(SSL_CTX *ctx, |
| 3580 |
EVP_PKEY *private_key); |
| 3581 |
|
| 3582 |
// SSL_set1_tls_channel_id configures a TLS client to send a TLS Channel ID to |
| 3583 |
// compatible servers. |private_key| must be a P-256 EC key. It returns one on |
| 3584 |
// success and zero on error. |
| 3585 |
OPENSSL_EXPORT int SSL_set1_tls_channel_id(SSL *ssl, EVP_PKEY *private_key); |
| 3586 |
|
| 3587 |
// SSL_get_tls_channel_id gets the client's TLS Channel ID from a server |SSL| |
| 3588 |
// and copies up to the first |max_out| bytes into |out|. The Channel ID |
| 3589 |
// consists of the client's P-256 public key as an (x,y) pair where each is a |
| 3590 |
// 32-byte, big-endian field element. It returns 0 if the client didn't offer a |
| 3591 |
// Channel ID and the length of the complete Channel ID otherwise. This function |
| 3592 |
// always returns zero if |ssl| is a client. |
| 3593 |
OPENSSL_EXPORT size_t SSL_get_tls_channel_id(SSL *ssl, uint8_t *out, |
| 3594 |
size_t max_out); |
| 3595 |
|
| 3596 |
|
| 3597 |
// DTLS-SRTP. |
| 3598 |
// |
| 3599 |
// See RFC 5764. |
| 3600 |
|
| 3601 |
// srtp_protection_profile_st (aka |SRTP_PROTECTION_PROFILE|) is an SRTP |
| 3602 |
// profile for use with the use_srtp extension. |
| 3603 |
struct srtp_protection_profile_st { |
| 3604 |
const char *name; |
| 3605 |
unsigned long id; |
| 3606 |
} /* SRTP_PROTECTION_PROFILE */; |
| 3607 |
|
| 3608 |
DEFINE_CONST_STACK_OF(SRTP_PROTECTION_PROFILE) |
| 3609 |
|
| 3610 |
// SRTP_* define constants for SRTP profiles. |
| 3611 |
#define SRTP_AES128_CM_SHA1_80 0x0001 |
| 3612 |
#define SRTP_AES128_CM_SHA1_32 0x0002 |
| 3613 |
#define SRTP_AES128_F8_SHA1_80 0x0003 |
| 3614 |
#define SRTP_AES128_F8_SHA1_32 0x0004 |
| 3615 |
#define SRTP_NULL_SHA1_80 0x0005 |
| 3616 |
#define SRTP_NULL_SHA1_32 0x0006 |
| 3617 |
#define SRTP_AEAD_AES_128_GCM 0x0007 |
| 3618 |
#define SRTP_AEAD_AES_256_GCM 0x0008 |
| 3619 |
|
| 3620 |
// SSL_CTX_set_srtp_profiles enables SRTP for all SSL objects created from |
| 3621 |
// |ctx|. |profile| contains a colon-separated list of profile names. It returns |
| 3622 |
// one on success and zero on failure. |
| 3623 |
OPENSSL_EXPORT int SSL_CTX_set_srtp_profiles(SSL_CTX *ctx, |
| 3624 |
const char *profiles); |
| 3625 |
|
| 3626 |
// SSL_set_srtp_profiles enables SRTP for |ssl|. |profile| contains a |
| 3627 |
// colon-separated list of profile names. It returns one on success and zero on |
| 3628 |
// failure. |
| 3629 |
OPENSSL_EXPORT int SSL_set_srtp_profiles(SSL *ssl, const char *profiles); |
| 3630 |
|
| 3631 |
// SSL_get_srtp_profiles returns the SRTP profiles supported by |ssl|. |
| 3632 |
OPENSSL_EXPORT const STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles( |
| 3633 |
const SSL *ssl); |
| 3634 |
|
| 3635 |
// SSL_get_selected_srtp_profile returns the selected SRTP profile, or NULL if |
| 3636 |
// SRTP was not negotiated. |
| 3637 |
OPENSSL_EXPORT const SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile( |
| 3638 |
SSL *ssl); |
| 3639 |
|
| 3640 |
|
| 3641 |
// Pre-shared keys. |
| 3642 |
// |
| 3643 |
// Connections may be configured with PSK (Pre-Shared Key) cipher suites. These |
| 3644 |
// authenticate using out-of-band pre-shared keys rather than certificates. See |
| 3645 |
// RFC 4279. |
| 3646 |
// |
| 3647 |
// This implementation uses NUL-terminated C strings for identities and identity |
| 3648 |
// hints, so values with a NUL character are not supported. (RFC 4279 does not |
| 3649 |
// specify the format of an identity.) |
| 3650 |
|
| 3651 |
// PSK_MAX_IDENTITY_LEN is the maximum supported length of a PSK identity, |
| 3652 |
// excluding the NUL terminator. |
| 3653 |
#define PSK_MAX_IDENTITY_LEN 128 |
| 3654 |
|
| 3655 |
// PSK_MAX_PSK_LEN is the maximum supported length of a pre-shared key. |
| 3656 |
#define PSK_MAX_PSK_LEN 256 |
| 3657 |
|
| 3658 |
// SSL_psk_client_cb_func defines a function signature for the client callback. |
| 3659 |
typedef unsigned int (*SSL_psk_client_cb_func)(SSL *ssl, |
| 3660 |
const char *hint, |
| 3661 |
char *identity, |
| 3662 |
unsigned int max_identity_len, |
| 3663 |
uint8_t *psk, |
| 3664 |
unsigned max_psk_len); |
| 3665 |
|
| 3666 |
// SSL_CTX_set_psk_client_callback sets the callback to be called when PSK is |
| 3667 |
// negotiated on the client. This callback must be set to enable PSK cipher |
| 3668 |
// suites on the client. |
| 3669 |
// |
| 3670 |
// The callback is passed the identity hint in |hint| or NULL if none was |
| 3671 |
// provided. It should select a PSK identity and write the identity and the |
| 3672 |
// corresponding PSK to |identity| and |psk|, respectively. The identity is |
| 3673 |
// written as a NUL-terminated C string of length (excluding the NUL terminator) |
| 3674 |
// at most |max_identity_len|. The PSK's length must be at most |max_psk_len|. |
| 3675 |
// The callback returns the length of the PSK or 0 if no suitable identity was |
| 3676 |
// found. |
| 3677 |
OPENSSL_EXPORT void SSL_CTX_set_psk_client_callback( |
| 3678 |
SSL_CTX *ctx, SSL_psk_client_cb_func cb); |
| 3679 |
|
| 3680 |
// SSL_set_psk_client_callback sets the callback to be called when PSK is |
| 3681 |
// negotiated on the client. This callback must be set to enable PSK cipher |
| 3682 |
// suites on the client. See also |SSL_CTX_set_psk_client_callback|. |
| 3683 |
OPENSSL_EXPORT void SSL_set_psk_client_callback( |
| 3684 |
SSL *ssl, SSL_psk_client_cb_func cb); |
| 3685 |
|
| 3686 |
// SSL_psk_server_cb_func defines a function signature for the server callback. |
| 3687 |
typedef unsigned (*SSL_psk_server_cb_func)(SSL *ssl, |
| 3688 |
const char *identity, |
| 3689 |
uint8_t *psk, |
| 3690 |
unsigned max_psk_len); |
| 3691 |
|
| 3692 |
// SSL_CTX_set_psk_server_callback sets the callback to be called when PSK is |
| 3693 |
// negotiated on the server. This callback must be set to enable PSK cipher |
| 3694 |
// suites on the server. |
| 3695 |
// |
| 3696 |
// The callback is passed the identity in |identity|. It should write a PSK of |
| 3697 |
// length at most |max_psk_len| to |psk| and return the number of bytes written |
| 3698 |
// or zero if the PSK identity is unknown. |
| 3699 |
OPENSSL_EXPORT void SSL_CTX_set_psk_server_callback( |
| 3700 |
SSL_CTX *ctx, SSL_psk_server_cb_func cb); |
| 3701 |
|
| 3702 |
// SSL_set_psk_server_callback sets the callback to be called when PSK is |
| 3703 |
// negotiated on the server. This callback must be set to enable PSK cipher |
| 3704 |
// suites on the server. See also |SSL_CTX_set_psk_server_callback|. |
| 3705 |
OPENSSL_EXPORT void SSL_set_psk_server_callback( |
| 3706 |
SSL *ssl, SSL_psk_server_cb_func cb); |
| 3707 |
|
| 3708 |
// SSL_CTX_use_psk_identity_hint configures server connections to advertise an |
| 3709 |
// identity hint of |identity_hint|. It returns one on success and zero on |
| 3710 |
// error. |
| 3711 |
OPENSSL_EXPORT int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, |
| 3712 |
const char *identity_hint); |
| 3713 |
|
| 3714 |
// SSL_use_psk_identity_hint configures server connections to advertise an |
| 3715 |
// identity hint of |identity_hint|. It returns one on success and zero on |
| 3716 |
// error. |
| 3717 |
OPENSSL_EXPORT int SSL_use_psk_identity_hint(SSL *ssl, |
| 3718 |
const char *identity_hint); |
| 3719 |
|
| 3720 |
// SSL_get_psk_identity_hint returns the PSK identity hint advertised for |ssl| |
| 3721 |
// or NULL if there is none. |
| 3722 |
OPENSSL_EXPORT const char *SSL_get_psk_identity_hint(const SSL *ssl); |
| 3723 |
|
| 3724 |
// SSL_get_psk_identity, after the handshake completes, returns the PSK identity |
| 3725 |
// that was negotiated by |ssl| or NULL if PSK was not used. |
| 3726 |
OPENSSL_EXPORT const char *SSL_get_psk_identity(const SSL *ssl); |
| 3727 |
|
| 3728 |
|
| 3729 |
// Delegated credentials. |
| 3730 |
// |
| 3731 |
// *** EXPERIMENTAL — PRONE TO CHANGE *** |
| 3732 |
// |
| 3733 |
// Delegated credentials (RFC 9345) allow a TLS 1.3 end point to use its |
| 3734 |
// certificate to issue new credentials for authentication. If the peer |
| 3735 |
// indicates support for this extension, then this host may use a delegated |
| 3736 |
// credential to sign the handshake. Once issued, credentials can't be revoked. |
| 3737 |
// In order to mitigate the damage in case the credential secret key is |
| 3738 |
// compromised, the credential is only valid for a short time (days, hours, or |
| 3739 |
// even minutes). |
| 3740 |
// |
| 3741 |
// Currently only the server side is implemented. |
| 3742 |
// |
| 3743 |
// Servers configure a DC for use in the handshake via |
| 3744 |
// |SSL_set1_delegated_credential|. It must be signed by the host's end-entity |
| 3745 |
// certificate as defined in RFC 9345. |
| 3746 |
|
| 3747 |
// SSL_set1_delegated_credential configures the delegated credential (DC) that |
| 3748 |
// will be sent to the peer for the current connection. |dc| is the DC in wire |
| 3749 |
// format, and |pkey| or |key_method| is the corresponding private key. |
| 3750 |
// Currently, only servers may configure a DC to use in the handshake. |
| 3751 |
// |
| 3752 |
// The DC will only be used if the protocol version is correct and the signature |
| 3753 |
// scheme is supported by the peer. If not, the DC will not be negotiated and |
| 3754 |
// the handshake will use the private key (or private key method) associated |
| 3755 |
// with the certificate. |
| 3756 |
OPENSSL_EXPORT int SSL_set1_delegated_credential( |
| 3757 |
SSL *ssl, CRYPTO_BUFFER *dc, EVP_PKEY *pkey, |
| 3758 |
const SSL_PRIVATE_KEY_METHOD *key_method); |
| 3759 |
|
| 3760 |
// SSL_delegated_credential_used returns one if a delegated credential was used |
| 3761 |
// and zero otherwise. |
| 3762 |
OPENSSL_EXPORT int SSL_delegated_credential_used(const SSL *ssl); |
| 3763 |
|
| 3764 |
|
| 3765 |
// QUIC integration. |
| 3766 |
// |
| 3767 |
// QUIC acts as an underlying transport for the TLS 1.3 handshake. The following |
| 3768 |
// functions allow a QUIC implementation to serve as the underlying transport as |
| 3769 |
// described in RFC 9001. |
| 3770 |
// |
| 3771 |
// When configured for QUIC, |SSL_do_handshake| will drive the handshake as |
| 3772 |
// before, but it will not use the configured |BIO|. It will call functions on |
| 3773 |
// |SSL_QUIC_METHOD| to configure secrets and send data. If data is needed from |
| 3774 |
// the peer, it will return |SSL_ERROR_WANT_READ|. As the caller receives data |
| 3775 |
// it can decrypt, it calls |SSL_provide_quic_data|. Subsequent |
| 3776 |
// |SSL_do_handshake| calls will then consume that data and progress the |
| 3777 |
// handshake. After the handshake is complete, the caller should continue to |
| 3778 |
// call |SSL_provide_quic_data| for any post-handshake data, followed by |
| 3779 |
// |SSL_process_quic_post_handshake| to process it. It is an error to call |
| 3780 |
// |SSL_read| and |SSL_write| in QUIC. |
| 3781 |
// |
| 3782 |
// 0-RTT behaves similarly to |TLS_method|'s usual behavior. |SSL_do_handshake| |
| 3783 |
// returns early as soon as the client (respectively, server) is allowed to send |
| 3784 |
// 0-RTT (respectively, half-RTT) data. The caller should then call |
| 3785 |
// |SSL_do_handshake| again to consume the remaining handshake messages and |
| 3786 |
// confirm the handshake. As a client, |SSL_ERROR_EARLY_DATA_REJECTED| and |
| 3787 |
// |SSL_reset_early_data_reject| behave as usual. |
| 3788 |
// |
| 3789 |
// See https://www.rfc-editor.org/rfc/rfc9001.html#section-4.1 for more details. |
| 3790 |
// |
| 3791 |
// To avoid DoS attacks, the QUIC implementation must limit the amount of data |
| 3792 |
// being queued up. The implementation can call |
| 3793 |
// |SSL_quic_max_handshake_flight_len| to get the maximum buffer length at each |
| 3794 |
// encryption level. |
| 3795 |
// |
| 3796 |
// QUIC implementations must additionally configure transport parameters with |
| 3797 |
// |SSL_set_quic_transport_params|. |SSL_get_peer_quic_transport_params| may be |
| 3798 |
// used to query the value received from the peer. BoringSSL handles this |
| 3799 |
// extension as an opaque byte string. The caller is responsible for serializing |
| 3800 |
// and parsing them. See https://www.rfc-editor.org/rfc/rfc9000#section-7.4 for |
| 3801 |
// details. |
| 3802 |
// |
| 3803 |
// QUIC additionally imposes restrictions on 0-RTT. In particular, the QUIC |
| 3804 |
// transport layer requires that if a server accepts 0-RTT data, then the |
| 3805 |
// transport parameters sent on the resumed connection must not lower any limits |
| 3806 |
// compared to the transport parameters that the server sent on the connection |
| 3807 |
// where the ticket for 0-RTT was issued. In effect, the server must remember |
| 3808 |
// the transport parameters with the ticket. Application protocols running on |
| 3809 |
// QUIC may impose similar restrictions, for example HTTP/3's restrictions on |
| 3810 |
// SETTINGS frames. |
| 3811 |
// |
| 3812 |
// BoringSSL implements this check by doing a byte-for-byte comparison of an |
| 3813 |
// opaque context passed in by the server. This context must be the same on the |
| 3814 |
// connection where the ticket was issued and the connection where that ticket |
| 3815 |
// is used for 0-RTT. If there is a mismatch, or the context was not set, |
| 3816 |
// BoringSSL will reject early data (but not reject the resumption attempt). |
| 3817 |
// This context is set via |SSL_set_quic_early_data_context| and should cover |
| 3818 |
// both transport parameters and any application state. |
| 3819 |
// |SSL_set_quic_early_data_context| must be called on the server with a |
| 3820 |
// non-empty context if the server is to support 0-RTT in QUIC. |
| 3821 |
// |
| 3822 |
// BoringSSL does not perform any client-side checks on the transport |
| 3823 |
// parameters received from a server that also accepted early data. It is up to |
| 3824 |
// the caller to verify that the received transport parameters do not lower any |
| 3825 |
// limits, and to close the QUIC connection if that is not the case. The same |
| 3826 |
// holds for any application protocol state remembered for 0-RTT, e.g. HTTP/3 |
| 3827 |
// SETTINGS. |
| 3828 |
|
| 3829 |
// ssl_encryption_level_t represents a specific QUIC encryption level used to |
| 3830 |
// transmit handshake messages. |
| 3831 |
enum ssl_encryption_level_t { |
| 3832 |
ssl_encryption_initial = 0, |
| 3833 |
ssl_encryption_early_data, |
| 3834 |
ssl_encryption_handshake, |
| 3835 |
ssl_encryption_application |
| 3836 |
}; |
| 3837 |
|
| 3838 |
// ssl_quic_method_st (aka |SSL_QUIC_METHOD|) describes custom QUIC hooks. |
| 3839 |
struct ssl_quic_method_st { |
| 3840 |
// set_read_secret configures the read secret and cipher suite for the given |
| 3841 |
// encryption level. It returns one on success and zero to terminate the |
| 3842 |
// handshake with an error. It will be called at most once per encryption |
| 3843 |
// level. |
| 3844 |
// |
| 3845 |
// BoringSSL will not release read keys before QUIC may use them. Once a level |
| 3846 |
// has been initialized, QUIC may begin processing data from it. Handshake |
| 3847 |
// data should be passed to |SSL_provide_quic_data| and application data (if |
| 3848 |
// |level| is |ssl_encryption_early_data| or |ssl_encryption_application|) may |
| 3849 |
// be processed according to the rules of the QUIC protocol. |
| 3850 |
// |
| 3851 |
// QUIC ACKs packets at the same encryption level they were received at, |
| 3852 |
// except that client |ssl_encryption_early_data| (0-RTT) packets trigger |
| 3853 |
// server |ssl_encryption_application| (1-RTT) ACKs. BoringSSL will always |
| 3854 |
// install ACK-writing keys with |set_write_secret| before the packet-reading |
| 3855 |
// keys with |set_read_secret|. This ensures the caller can always ACK any |
| 3856 |
// packet it decrypts. Note this means the server installs 1-RTT write keys |
| 3857 |
// before 0-RTT read keys. |
| 3858 |
// |
| 3859 |
// The converse is not true. An encryption level may be configured with write |
| 3860 |
// secrets a roundtrip before the corresponding secrets for reading ACKs is |
| 3861 |
// available. |
| 3862 |
int (*set_read_secret)(SSL *ssl, enum ssl_encryption_level_t level, |
| 3863 |
const SSL_CIPHER *cipher, const uint8_t *secret, |
| 3864 |
size_t secret_len); |
| 3865 |
// set_write_secret behaves like |set_read_secret| but configures the write |
| 3866 |
// secret and cipher suite for the given encryption level. It will be called |
| 3867 |
// at most once per encryption level. |
| 3868 |
// |
| 3869 |
// BoringSSL will not release write keys before QUIC may use them. If |level| |
| 3870 |
// is |ssl_encryption_early_data| or |ssl_encryption_application|, QUIC may |
| 3871 |
// begin sending application data at |level|. However, note that BoringSSL |
| 3872 |
// configures server |ssl_encryption_application| write keys before the client |
| 3873 |
// Finished. This allows QUIC to send half-RTT data, but the handshake is not |
| 3874 |
// confirmed at this point and, if requesting client certificates, the client |
| 3875 |
// is not yet authenticated. |
| 3876 |
// |
| 3877 |
// See |set_read_secret| for additional invariants between packets and their |
| 3878 |
// ACKs. |
| 3879 |
// |
| 3880 |
// Note that, on 0-RTT reject, the |ssl_encryption_early_data| write secret |
| 3881 |
// may use a different cipher suite from the other keys. |
| 3882 |
int (*set_write_secret)(SSL *ssl, enum ssl_encryption_level_t level, |
| 3883 |
const SSL_CIPHER *cipher, const uint8_t *secret, |
| 3884 |
size_t secret_len); |
| 3885 |
// add_handshake_data adds handshake data to the current flight at the given |
| 3886 |
// encryption level. It returns one on success and zero on error. |
| 3887 |
// |
| 3888 |
// BoringSSL will pack data from a single encryption level together, but a |
| 3889 |
// single handshake flight may include multiple encryption levels. Callers |
| 3890 |
// should defer writing data to the network until |flush_flight| to better |
| 3891 |
// pack QUIC packets into transport datagrams. |
| 3892 |
// |
| 3893 |
// If |level| is not |ssl_encryption_initial|, this function will not be |
| 3894 |
// called before |level| is initialized with |set_write_secret|. |
| 3895 |
int (*add_handshake_data)(SSL *ssl, enum ssl_encryption_level_t level, |
| 3896 |
const uint8_t *data, size_t len); |
| 3897 |
// flush_flight is called when the current flight is complete and should be |
| 3898 |
// written to the transport. Note a flight may contain data at several |
| 3899 |
// encryption levels. It returns one on success and zero on error. |
| 3900 |
int (*flush_flight)(SSL *ssl); |
| 3901 |
// send_alert sends a fatal alert at the specified encryption level. It |
| 3902 |
// returns one on success and zero on error. |
| 3903 |
// |
| 3904 |
// If |level| is not |ssl_encryption_initial|, this function will not be |
| 3905 |
// called before |level| is initialized with |set_write_secret|. |
| 3906 |
int (*send_alert)(SSL *ssl, enum ssl_encryption_level_t level, uint8_t alert); |
| 3907 |
}; |
| 3908 |
|
| 3909 |
// SSL_quic_max_handshake_flight_len returns returns the maximum number of bytes |
| 3910 |
// that may be received at the given encryption level. This function should be |
| 3911 |
// used to limit buffering in the QUIC implementation. |
| 3912 |
// |
| 3913 |
// See https://www.rfc-editor.org/rfc/rfc9000#section-7.5 |
| 3914 |
OPENSSL_EXPORT size_t SSL_quic_max_handshake_flight_len( |
| 3915 |
const SSL *ssl, enum ssl_encryption_level_t level); |
| 3916 |
|
| 3917 |
// SSL_quic_read_level returns the current read encryption level. |
| 3918 |
// |
| 3919 |
// TODO(davidben): Is it still necessary to expose this function to callers? |
| 3920 |
// QUICHE does not use it. |
| 3921 |
OPENSSL_EXPORT enum ssl_encryption_level_t SSL_quic_read_level(const SSL *ssl); |
| 3922 |
|
| 3923 |
// SSL_quic_write_level returns the current write encryption level. |
| 3924 |
// |
| 3925 |
// TODO(davidben): Is it still necessary to expose this function to callers? |
| 3926 |
// QUICHE does not use it. |
| 3927 |
OPENSSL_EXPORT enum ssl_encryption_level_t SSL_quic_write_level(const SSL *ssl); |
| 3928 |
|
| 3929 |
// SSL_provide_quic_data provides data from QUIC at a particular encryption |
| 3930 |
// level |level|. It returns one on success and zero on error. Note this |
| 3931 |
// function will return zero if the handshake is not expecting data from |level| |
| 3932 |
// at this time. The QUIC implementation should then close the connection with |
| 3933 |
// an error. |
| 3934 |
OPENSSL_EXPORT int SSL_provide_quic_data(SSL *ssl, |
| 3935 |
enum ssl_encryption_level_t level, |
| 3936 |
const uint8_t *data, size_t len); |
| 3937 |
|
| 3938 |
|
| 3939 |
// SSL_process_quic_post_handshake processes any data that QUIC has provided |
| 3940 |
// after the handshake has completed. This includes NewSessionTicket messages |
| 3941 |
// sent by the server. It returns one on success and zero on error. |
| 3942 |
OPENSSL_EXPORT int SSL_process_quic_post_handshake(SSL *ssl); |
| 3943 |
|
| 3944 |
// SSL_CTX_set_quic_method configures the QUIC hooks. This should only be |
| 3945 |
// configured with a minimum version of TLS 1.3. |quic_method| must remain valid |
| 3946 |
// for the lifetime of |ctx|. It returns one on success and zero on error. |
| 3947 |
OPENSSL_EXPORT int SSL_CTX_set_quic_method(SSL_CTX *ctx, |
| 3948 |
const SSL_QUIC_METHOD *quic_method); |
| 3949 |
|
| 3950 |
// SSL_set_quic_method configures the QUIC hooks. This should only be |
| 3951 |
// configured with a minimum version of TLS 1.3. |quic_method| must remain valid |
| 3952 |
// for the lifetime of |ssl|. It returns one on success and zero on error. |
| 3953 |
OPENSSL_EXPORT int SSL_set_quic_method(SSL *ssl, |
| 3954 |
const SSL_QUIC_METHOD *quic_method); |
| 3955 |
|
| 3956 |
// SSL_set_quic_transport_params configures |ssl| to send |params| (of length |
| 3957 |
// |params_len|) in the quic_transport_parameters extension in either the |
| 3958 |
// ClientHello or EncryptedExtensions handshake message. It is an error to set |
| 3959 |
// transport parameters if |ssl| is not configured for QUIC. The buffer pointed |
| 3960 |
// to by |params| only need be valid for the duration of the call to this |
| 3961 |
// function. This function returns 1 on success and 0 on failure. |
| 3962 |
OPENSSL_EXPORT int SSL_set_quic_transport_params(SSL *ssl, |
| 3963 |
const uint8_t *params, |
| 3964 |
size_t params_len); |
| 3965 |
|
| 3966 |
// SSL_get_peer_quic_transport_params provides the caller with the value of the |
| 3967 |
// quic_transport_parameters extension sent by the peer. A pointer to the buffer |
| 3968 |
// containing the TransportParameters will be put in |*out_params|, and its |
| 3969 |
// length in |*params_len|. This buffer will be valid for the lifetime of the |
| 3970 |
// |SSL|. If no params were received from the peer, |*out_params_len| will be 0. |
| 3971 |
OPENSSL_EXPORT void SSL_get_peer_quic_transport_params( |
| 3972 |
const SSL *ssl, const uint8_t **out_params, size_t *out_params_len); |
| 3973 |
|
| 3974 |
// SSL_set_quic_use_legacy_codepoint configures whether to use the legacy QUIC |
| 3975 |
// extension codepoint 0xffa5 as opposed to the official value 57. Call with |
| 3976 |
// |use_legacy| set to 1 to use 0xffa5 and call with 0 to use 57. By default, |
| 3977 |
// the standard code point is used. |
| 3978 |
OPENSSL_EXPORT void SSL_set_quic_use_legacy_codepoint(SSL *ssl, int use_legacy); |
| 3979 |
|
| 3980 |
// SSL_set_quic_early_data_context configures a context string in QUIC servers |
| 3981 |
// for accepting early data. If a resumption connection offers early data, the |
| 3982 |
// server will check if the value matches that of the connection which minted |
| 3983 |
// the ticket. If not, resumption still succeeds but early data is rejected. |
| 3984 |
// This should include all QUIC Transport Parameters except ones specified that |
| 3985 |
// the client MUST NOT remember. This should also include any application |
| 3986 |
// protocol-specific state. For HTTP/3, this should be the serialized server |
| 3987 |
// SETTINGS frame and the QUIC Transport Parameters (except the stateless reset |
| 3988 |
// token). |
| 3989 |
// |
| 3990 |
// This function may be called before |SSL_do_handshake| or during server |
| 3991 |
// certificate selection. It returns 1 on success and 0 on failure. |
| 3992 |
OPENSSL_EXPORT int SSL_set_quic_early_data_context(SSL *ssl, |
| 3993 |
const uint8_t *context, |
| 3994 |
size_t context_len); |
| 3995 |
|
| 3996 |
|
| 3997 |
// Early data. |
| 3998 |
// |
| 3999 |
// WARNING: 0-RTT support in BoringSSL is currently experimental and not fully |
| 4000 |
// implemented. It may cause interoperability or security failures when used. |
| 4001 |
// |
| 4002 |
// Early data, or 0-RTT, is a feature in TLS 1.3 which allows clients to send |
| 4003 |
// data on the first flight during a resumption handshake. This can save a |
| 4004 |
// round-trip in some application protocols. |
| 4005 |
// |
| 4006 |
// WARNING: A 0-RTT handshake has different security properties from normal |
| 4007 |
// handshake, so it is off by default unless opted in. In particular, early data |
| 4008 |
// is replayable by a network attacker. Callers must account for this when |
| 4009 |
// sending or processing data before the handshake is confirmed. See RFC 8446 |
| 4010 |
// for more information. |
| 4011 |
// |
| 4012 |
// As a server, if early data is accepted, |SSL_do_handshake| will complete as |
| 4013 |
// soon as the ClientHello is processed and server flight sent. |SSL_write| may |
| 4014 |
// be used to send half-RTT data. |SSL_read| will consume early data and |
| 4015 |
// transition to 1-RTT data as appropriate. Prior to the transition, |
| 4016 |
// |SSL_in_init| will report the handshake is still in progress. Callers may use |
| 4017 |
// it or |SSL_in_early_data| to defer or reject requests as needed. |
| 4018 |
// |
| 4019 |
// Early data as a client is more complex. If the offered session (see |
| 4020 |
// |SSL_set_session|) is 0-RTT-capable, the handshake will return after sending |
| 4021 |
// the ClientHello. The predicted peer certificates and ALPN protocol will be |
| 4022 |
// available via the usual APIs. |SSL_write| will write early data, up to the |
| 4023 |
// session's limit. Writes past this limit and |SSL_read| will complete the |
| 4024 |
// handshake before continuing. Callers may also call |SSL_do_handshake| again |
| 4025 |
// to complete the handshake sooner. |
| 4026 |
// |
| 4027 |
// If the server accepts early data, the handshake will succeed. |SSL_read| and |
| 4028 |
// |SSL_write| will then act as in a 1-RTT handshake. The peer certificates and |
| 4029 |
// ALPN protocol will be as predicted and need not be re-queried. |
| 4030 |
// |
| 4031 |
// If the server rejects early data, |SSL_do_handshake| (and thus |SSL_read| and |
| 4032 |
// |SSL_write|) will then fail with |SSL_get_error| returning |
| 4033 |
// |SSL_ERROR_EARLY_DATA_REJECTED|. The caller should treat this as a connection |
| 4034 |
// error and most likely perform a high-level retry. Note the server may still |
| 4035 |
// have processed the early data due to attacker replays. |
| 4036 |
// |
| 4037 |
// To then continue the handshake on the original connection, use |
| 4038 |
// |SSL_reset_early_data_reject|. The connection will then behave as one which |
| 4039 |
// had not yet completed the handshake. This allows a faster retry than making a |
| 4040 |
// fresh connection. |SSL_do_handshake| will complete the full handshake, |
| 4041 |
// possibly resulting in different peer certificates, ALPN protocol, and other |
| 4042 |
// properties. The caller must disregard any values from before the reset and |
| 4043 |
// query again. |
| 4044 |
// |
| 4045 |
// Finally, to implement the fallback described in RFC 8446 appendix D.3, retry |
| 4046 |
// on a fresh connection without 0-RTT if the handshake fails with |
| 4047 |
// |SSL_R_WRONG_VERSION_ON_EARLY_DATA|. |
| 4048 |
|
| 4049 |
// SSL_CTX_set_early_data_enabled sets whether early data is allowed to be used |
| 4050 |
// with resumptions using |ctx|. |
| 4051 |
OPENSSL_EXPORT void SSL_CTX_set_early_data_enabled(SSL_CTX *ctx, int enabled); |
| 4052 |
|
| 4053 |
// SSL_set_early_data_enabled sets whether early data is allowed to be used |
| 4054 |
// with resumptions using |ssl|. See |SSL_CTX_set_early_data_enabled| for more |
| 4055 |
// information. |
| 4056 |
OPENSSL_EXPORT void SSL_set_early_data_enabled(SSL *ssl, int enabled); |
| 4057 |
|
| 4058 |
// SSL_in_early_data returns one if |ssl| has a pending handshake that has |
| 4059 |
// progressed enough to send or receive early data. Clients may call |SSL_write| |
| 4060 |
// to send early data, but |SSL_read| will complete the handshake before |
| 4061 |
// accepting application data. Servers may call |SSL_read| to read early data |
| 4062 |
// and |SSL_write| to send half-RTT data. |
| 4063 |
OPENSSL_EXPORT int SSL_in_early_data(const SSL *ssl); |
| 4064 |
|
| 4065 |
// SSL_SESSION_early_data_capable returns whether early data would have been |
| 4066 |
// attempted with |session| if enabled. |
| 4067 |
OPENSSL_EXPORT int SSL_SESSION_early_data_capable(const SSL_SESSION *session); |
| 4068 |
|
| 4069 |
// SSL_SESSION_copy_without_early_data returns a copy of |session| with early |
| 4070 |
// data disabled. If |session| already does not support early data, it returns |
| 4071 |
// |session| with the reference count increased. The caller takes ownership of |
| 4072 |
// the result and must release it with |SSL_SESSION_free|. |
| 4073 |
// |
| 4074 |
// This function may be used on the client to clear early data support from |
| 4075 |
// existing sessions when the server rejects early data. In particular, |
| 4076 |
// |SSL_R_WRONG_VERSION_ON_EARLY_DATA| requires a fresh connection to retry, and |
| 4077 |
// the client would not want 0-RTT enabled for the next connection attempt. |
| 4078 |
OPENSSL_EXPORT SSL_SESSION *SSL_SESSION_copy_without_early_data( |
| 4079 |
SSL_SESSION *session); |
| 4080 |
|
| 4081 |
// SSL_early_data_accepted returns whether early data was accepted on the |
| 4082 |
// handshake performed by |ssl|. |
| 4083 |
OPENSSL_EXPORT int SSL_early_data_accepted(const SSL *ssl); |
| 4084 |
|
| 4085 |
// SSL_reset_early_data_reject resets |ssl| after an early data reject. All |
| 4086 |
// 0-RTT state is discarded, including any pending |SSL_write| calls. The caller |
| 4087 |
// should treat |ssl| as a logically fresh connection, usually by driving the |
| 4088 |
// handshake to completion using |SSL_do_handshake|. |
| 4089 |
// |
| 4090 |
// It is an error to call this function on an |SSL| object that is not signaling |
| 4091 |
// |SSL_ERROR_EARLY_DATA_REJECTED|. |
| 4092 |
OPENSSL_EXPORT void SSL_reset_early_data_reject(SSL *ssl); |
| 4093 |
|
| 4094 |
// SSL_get_ticket_age_skew returns the difference, in seconds, between the |
| 4095 |
// client-sent ticket age and the server-computed value in TLS 1.3 server |
| 4096 |
// connections which resumed a session. |
| 4097 |
OPENSSL_EXPORT int32_t SSL_get_ticket_age_skew(const SSL *ssl); |
| 4098 |
|
| 4099 |
// An ssl_early_data_reason_t describes why 0-RTT was accepted or rejected. |
| 4100 |
// These values are persisted to logs. Entries should not be renumbered and |
| 4101 |
// numeric values should never be reused. |
| 4102 |
enum ssl_early_data_reason_t { |
| 4103 |
// The handshake has not progressed far enough for the 0-RTT status to be |
| 4104 |
// known. |
| 4105 |
ssl_early_data_unknown = 0, |
| 4106 |
// 0-RTT is disabled for this connection. |
| 4107 |
ssl_early_data_disabled = 1, |
| 4108 |
// 0-RTT was accepted. |
| 4109 |
ssl_early_data_accepted = 2, |
| 4110 |
// The negotiated protocol version does not support 0-RTT. |
| 4111 |
ssl_early_data_protocol_version = 3, |
| 4112 |
// The peer declined to offer or accept 0-RTT for an unknown reason. |
| 4113 |
ssl_early_data_peer_declined = 4, |
| 4114 |
// The client did not offer a session. |
| 4115 |
ssl_early_data_no_session_offered = 5, |
| 4116 |
// The server declined to resume the session. |
| 4117 |
ssl_early_data_session_not_resumed = 6, |
| 4118 |
// The session does not support 0-RTT. |
| 4119 |
ssl_early_data_unsupported_for_session = 7, |
| 4120 |
// The server sent a HelloRetryRequest. |
| 4121 |
ssl_early_data_hello_retry_request = 8, |
| 4122 |
// The negotiated ALPN protocol did not match the session. |
| 4123 |
ssl_early_data_alpn_mismatch = 9, |
| 4124 |
// The connection negotiated Channel ID, which is incompatible with 0-RTT. |
| 4125 |
ssl_early_data_channel_id = 10, |
| 4126 |
// Value 11 is reserved. (It has historically |ssl_early_data_token_binding|.) |
| 4127 |
// The client and server ticket age were too far apart. |
| 4128 |
ssl_early_data_ticket_age_skew = 12, |
| 4129 |
// QUIC parameters differ between this connection and the original. |
| 4130 |
ssl_early_data_quic_parameter_mismatch = 13, |
| 4131 |
// The application settings did not match the session. |
| 4132 |
ssl_early_data_alps_mismatch = 14, |
| 4133 |
// The value of the largest entry. |
| 4134 |
ssl_early_data_unsupported_with_custom_extension = 15, |
| 4135 |
ssl_early_data_reason_max_value = |
| 4136 |
ssl_early_data_unsupported_with_custom_extension |
| 4137 |
}; |
| 4138 |
|
| 4139 |
// SSL_get_early_data_reason returns details why 0-RTT was accepted or rejected |
| 4140 |
// on |ssl|. This is primarily useful on the server. |
| 4141 |
OPENSSL_EXPORT enum ssl_early_data_reason_t SSL_get_early_data_reason( |
| 4142 |
const SSL *ssl); |
| 4143 |
|
| 4144 |
// SSL_early_data_reason_string returns a string representation for |reason|, or |
| 4145 |
// NULL if |reason| is unknown. This function may be used for logging. |
| 4146 |
OPENSSL_EXPORT const char *SSL_early_data_reason_string( |
| 4147 |
enum ssl_early_data_reason_t reason); |
| 4148 |
|
| 4149 |
|
| 4150 |
// Encrypted ClientHello. |
| 4151 |
// |
| 4152 |
// ECH is a mechanism for encrypting the entire ClientHello message in TLS 1.3. |
| 4153 |
// This can prevent observers from seeing cleartext information about the |
| 4154 |
// connection, such as the server_name extension. |
| 4155 |
// |
| 4156 |
// By default, BoringSSL will treat the server name, session ticket, and client |
| 4157 |
// certificate as secret, but most other parameters, such as the ALPN protocol |
| 4158 |
// list will be treated as public and sent in the cleartext ClientHello. Other |
| 4159 |
// APIs may be added for applications with different secrecy requirements. |
| 4160 |
// |
| 4161 |
// ECH support in BoringSSL is still experimental and under development. |
| 4162 |
// |
| 4163 |
// See https://tools.ietf.org/html/draft-ietf-tls-esni-13. |
| 4164 |
|
| 4165 |
// SSL_set_enable_ech_grease configures whether the client will send a GREASE |
| 4166 |
// ECH extension when no supported ECHConfig is available. |
| 4167 |
OPENSSL_EXPORT void SSL_set_enable_ech_grease(SSL *ssl, int enable); |
| 4168 |
|
| 4169 |
// SSL_set1_ech_config_list configures |ssl| to, as a client, offer ECH with the |
| 4170 |
// specified configuration. |ech_config_list| should contain a serialized |
| 4171 |
// ECHConfigList structure. It returns one on success and zero on error. |
| 4172 |
// |
| 4173 |
// This function returns an error if the input is malformed. If the input is |
| 4174 |
// valid but none of the ECHConfigs implement supported parameters, it will |
| 4175 |
// return success and proceed without ECH. |
| 4176 |
// |
| 4177 |
// If a supported ECHConfig is found, |ssl| will encrypt the true ClientHello |
| 4178 |
// parameters. If the server cannot decrypt it, e.g. due to a key mismatch, ECH |
| 4179 |
// has a recovery flow. |ssl| will handshake using the cleartext parameters, |
| 4180 |
// including a public name in the ECHConfig. If using |
| 4181 |
// |SSL_CTX_set_custom_verify|, callers should use |SSL_get0_ech_name_override| |
| 4182 |
// to verify the certificate with the public name. If using the built-in |
| 4183 |
// verifier, the |X509_STORE_CTX| will be configured automatically. |
| 4184 |
// |
| 4185 |
// If no other errors are found in this handshake, it will fail with |
| 4186 |
// |SSL_R_ECH_REJECTED|. Since it didn't use the true parameters, the connection |
| 4187 |
// cannot be used for application data. Instead, callers should handle this |
| 4188 |
// error by calling |SSL_get0_ech_retry_configs| and retrying the connection |
| 4189 |
// with updated ECH parameters. If the retry also fails with |
| 4190 |
// |SSL_R_ECH_REJECTED|, the caller should report a connection failure. |
| 4191 |
OPENSSL_EXPORT int SSL_set1_ech_config_list(SSL *ssl, |
| 4192 |
const uint8_t *ech_config_list, |
| 4193 |
size_t ech_config_list_len); |
| 4194 |
|
| 4195 |
// SSL_get0_ech_name_override, if |ssl| is a client and the server rejected ECH, |
| 4196 |
// sets |*out_name| and |*out_name_len| to point to a buffer containing the ECH |
| 4197 |
// public name. Otherwise, the buffer will be empty. |
| 4198 |
// |
| 4199 |
// When offering ECH as a client, this function should be called during the |
| 4200 |
// certificate verification callback (see |SSL_CTX_set_custom_verify|). If |
| 4201 |
// |*out_name_len| is non-zero, the caller should verify the certificate against |
| 4202 |
// the result, interpreted as a DNS name, rather than the true server name. In |
| 4203 |
// this case, the handshake will never succeed and is only used to authenticate |
| 4204 |
// retry configs. See also |SSL_get0_ech_retry_configs|. |
| 4205 |
OPENSSL_EXPORT void SSL_get0_ech_name_override(const SSL *ssl, |
| 4206 |
const char **out_name, |
| 4207 |
size_t *out_name_len); |
| 4208 |
|
| 4209 |
// SSL_get0_ech_retry_configs sets |*out_retry_configs| and |
| 4210 |
// |*out_retry_configs_len| to a buffer containing a serialized ECHConfigList. |
| 4211 |
// If the server did not provide an ECHConfigList, |*out_retry_configs_len| will |
| 4212 |
// be zero. |
| 4213 |
// |
| 4214 |
// When handling an |SSL_R_ECH_REJECTED| error code as a client, callers should |
| 4215 |
// use this function to recover from potential key mismatches. If the result is |
| 4216 |
// non-empty, the caller should retry the connection, passing this buffer to |
| 4217 |
// |SSL_set1_ech_config_list|. If the result is empty, the server has rolled |
| 4218 |
// back ECH support, and the caller should retry without ECH. |
| 4219 |
// |
| 4220 |
// This function must only be called in response to an |SSL_R_ECH_REJECTED| |
| 4221 |
// error code. Calling this function on |ssl|s that have not authenticated the |
| 4222 |
// rejection handshake will assert in debug builds and otherwise return an |
| 4223 |
// unparsable list. |
| 4224 |
OPENSSL_EXPORT void SSL_get0_ech_retry_configs( |
| 4225 |
const SSL *ssl, const uint8_t **out_retry_configs, |
| 4226 |
size_t *out_retry_configs_len); |
| 4227 |
|
| 4228 |
// SSL_marshal_ech_config constructs a new serialized ECHConfig. On success, it |
| 4229 |
// sets |*out| to a newly-allocated buffer containing the result and |*out_len| |
| 4230 |
// to the size of the buffer. The caller must call |OPENSSL_free| on |*out| to |
| 4231 |
// release the memory. On failure, it returns zero. |
| 4232 |
// |
| 4233 |
// The |config_id| field is a single byte identifier for the ECHConfig. Reusing |
| 4234 |
// config IDs is allowed, but if multiple ECHConfigs with the same config ID are |
| 4235 |
// active at a time, server load may increase. See |
| 4236 |
// |SSL_ECH_KEYS_has_duplicate_config_id|. |
| 4237 |
// |
| 4238 |
// The public key and KEM algorithm are taken from |key|. |public_name| is the |
| 4239 |
// DNS name used to authenticate the recovery flow. |max_name_len| should be the |
| 4240 |
// length of the longest name in the ECHConfig's anonymity set and influences |
| 4241 |
// client padding decisions. |
| 4242 |
OPENSSL_EXPORT int SSL_marshal_ech_config(uint8_t **out, size_t *out_len, |
| 4243 |
uint8_t config_id, |
| 4244 |
const EVP_HPKE_KEY *key, |
| 4245 |
const char *public_name, |
| 4246 |
size_t max_name_len); |
| 4247 |
|
| 4248 |
// SSL_ECH_KEYS_new returns a newly-allocated |SSL_ECH_KEYS| or NULL on error. |
| 4249 |
OPENSSL_EXPORT SSL_ECH_KEYS *SSL_ECH_KEYS_new(void); |
| 4250 |
|
| 4251 |
// SSL_ECH_KEYS_up_ref increments the reference count of |keys|. |
| 4252 |
OPENSSL_EXPORT void SSL_ECH_KEYS_up_ref(SSL_ECH_KEYS *keys); |
| 4253 |
|
| 4254 |
// SSL_ECH_KEYS_free releases memory associated with |keys|. |
| 4255 |
OPENSSL_EXPORT void SSL_ECH_KEYS_free(SSL_ECH_KEYS *keys); |
| 4256 |
|
| 4257 |
// SSL_ECH_KEYS_add decodes |ech_config| as an ECHConfig and appends it with |
| 4258 |
// |key| to |keys|. If |is_retry_config| is non-zero, this config will be |
| 4259 |
// returned to the client on configuration mismatch. It returns one on success |
| 4260 |
// and zero on error. |
| 4261 |
// |
| 4262 |
// This function should be called successively to register each ECHConfig in |
| 4263 |
// decreasing order of preference. This configuration must be completed before |
| 4264 |
// setting |keys| on an |SSL_CTX| with |SSL_CTX_set1_ech_keys|. After that |
| 4265 |
// point, |keys| is immutable; no more ECHConfig values may be added. |
| 4266 |
// |
| 4267 |
// See also |SSL_CTX_set1_ech_keys|. |
| 4268 |
OPENSSL_EXPORT int SSL_ECH_KEYS_add(SSL_ECH_KEYS *keys, int is_retry_config, |
| 4269 |
const uint8_t *ech_config, |
| 4270 |
size_t ech_config_len, |
| 4271 |
const EVP_HPKE_KEY *key); |
| 4272 |
|
| 4273 |
// SSL_ECH_KEYS_has_duplicate_config_id returns one if |keys| has duplicate |
| 4274 |
// config IDs or zero otherwise. Duplicate config IDs still work, but may |
| 4275 |
// increase server load due to trial decryption. |
| 4276 |
OPENSSL_EXPORT int SSL_ECH_KEYS_has_duplicate_config_id( |
| 4277 |
const SSL_ECH_KEYS *keys); |
| 4278 |
|
| 4279 |
// SSL_ECH_KEYS_marshal_retry_configs serializes the retry configs in |keys| as |
| 4280 |
// an ECHConfigList. On success, it sets |*out| to a newly-allocated buffer |
| 4281 |
// containing the result and |*out_len| to the size of the buffer. The caller |
| 4282 |
// must call |OPENSSL_free| on |*out| to release the memory. On failure, it |
| 4283 |
// returns zero. |
| 4284 |
// |
| 4285 |
// This output may be advertised to clients in DNS. |
| 4286 |
OPENSSL_EXPORT int SSL_ECH_KEYS_marshal_retry_configs(const SSL_ECH_KEYS *keys, |
| 4287 |
uint8_t **out, |
| 4288 |
size_t *out_len); |
| 4289 |
|
| 4290 |
// SSL_CTX_set1_ech_keys configures |ctx| to use |keys| to decrypt encrypted |
| 4291 |
// ClientHellos. It returns one on success, and zero on failure. If |keys| does |
| 4292 |
// not contain any retry configs, this function will fail. Retry configs are |
| 4293 |
// marked as such when they are added to |keys| with |SSL_ECH_KEYS_add|. |
| 4294 |
// |
| 4295 |
// Once |keys| has been passed to this function, it is immutable. Unlike most |
| 4296 |
// |SSL_CTX| configuration functions, this function may be called even if |ctx| |
| 4297 |
// already has associated connections on multiple threads. This may be used to |
| 4298 |
// rotate keys in a long-lived server process. |
| 4299 |
// |
| 4300 |
// The configured ECHConfig values should also be advertised out-of-band via DNS |
| 4301 |
// (see draft-ietf-dnsop-svcb-https). Before advertising an ECHConfig in DNS, |
| 4302 |
// deployments should ensure all instances of the service are configured with |
| 4303 |
// the ECHConfig and corresponding private key. |
| 4304 |
// |
| 4305 |
// Only the most recent fully-deployed ECHConfigs should be advertised in DNS. |
| 4306 |
// |keys| may contain a newer set if those ECHConfigs are mid-deployment. It |
| 4307 |
// should also contain older sets, until the DNS change has rolled out and the |
| 4308 |
// old records have expired from caches. |
| 4309 |
// |
| 4310 |
// If there is a mismatch, |SSL| objects associated with |ctx| will complete the |
| 4311 |
// handshake using the cleartext ClientHello and send updated ECHConfig values |
| 4312 |
// to the client. The client will then retry to recover, but with a latency |
| 4313 |
// penalty. This recovery flow depends on the public name in the ECHConfig. |
| 4314 |
// Before advertising an ECHConfig in DNS, deployments must ensure all instances |
| 4315 |
// of the service can present a valid certificate for the public name. |
| 4316 |
// |
| 4317 |
// BoringSSL negotiates ECH before certificate selection callbacks are called, |
| 4318 |
// including |SSL_CTX_set_select_certificate_cb|. If ECH is negotiated, the |
| 4319 |
// reported |SSL_CLIENT_HELLO| structure and |SSL_get_servername| function will |
| 4320 |
// transparently reflect the inner ClientHello. Callers should select parameters |
| 4321 |
// based on these values to correctly handle ECH as well as the recovery flow. |
| 4322 |
OPENSSL_EXPORT int SSL_CTX_set1_ech_keys(SSL_CTX *ctx, SSL_ECH_KEYS *keys); |
| 4323 |
|
| 4324 |
// SSL_ech_accepted returns one if |ssl| negotiated ECH and zero otherwise. |
| 4325 |
OPENSSL_EXPORT int SSL_ech_accepted(const SSL *ssl); |
| 4326 |
|
| 4327 |
|
| 4328 |
// Alerts. |
| 4329 |
// |
| 4330 |
// TLS uses alerts to signal error conditions. Alerts have a type (warning or |
| 4331 |
// fatal) and description. OpenSSL internally handles fatal alerts with |
| 4332 |
// dedicated error codes (see |SSL_AD_REASON_OFFSET|). Except for close_notify, |
| 4333 |
// warning alerts are silently ignored and may only be surfaced with |
| 4334 |
// |SSL_CTX_set_info_callback|. |
| 4335 |
|
| 4336 |
// SSL_AD_REASON_OFFSET is the offset between error reasons and |SSL_AD_*| |
| 4337 |
// values. Any error code under |ERR_LIB_SSL| with an error reason above this |
| 4338 |
// value corresponds to an alert description. Consumers may add or subtract |
| 4339 |
// |SSL_AD_REASON_OFFSET| to convert between them. |
| 4340 |
// |
| 4341 |
// make_errors.go reserves error codes above 1000 for manually-assigned errors. |
| 4342 |
// This value must be kept in sync with reservedReasonCode in make_errors.h |
| 4343 |
#define SSL_AD_REASON_OFFSET 1000 |
| 4344 |
|
| 4345 |
// SSL_AD_* are alert descriptions. |
| 4346 |
#define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY |
| 4347 |
#define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE |
| 4348 |
#define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC |
| 4349 |
#define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED |
| 4350 |
#define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW |
| 4351 |
#define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE |
| 4352 |
#define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE |
| 4353 |
#define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE // Legacy SSL 3.0 value |
| 4354 |
#define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE |
| 4355 |
#define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE |
| 4356 |
#define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED |
| 4357 |
#define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED |
| 4358 |
#define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN |
| 4359 |
#define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER |
| 4360 |
#define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA |
| 4361 |
#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED |
| 4362 |
#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR |
| 4363 |
#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR |
| 4364 |
#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION |
| 4365 |
#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION |
| 4366 |
#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY |
| 4367 |
#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR |
| 4368 |
#define SSL_AD_INAPPROPRIATE_FALLBACK SSL3_AD_INAPPROPRIATE_FALLBACK |
| 4369 |
#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED |
| 4370 |
#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION |
| 4371 |
#define SSL_AD_MISSING_EXTENSION TLS1_AD_MISSING_EXTENSION |
| 4372 |
#define SSL_AD_UNSUPPORTED_EXTENSION TLS1_AD_UNSUPPORTED_EXTENSION |
| 4373 |
#define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE |
| 4374 |
#define SSL_AD_UNRECOGNIZED_NAME TLS1_AD_UNRECOGNIZED_NAME |
| 4375 |
#define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE \ |
| 4376 |
TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE |
| 4377 |
#define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE |
| 4378 |
#define SSL_AD_UNKNOWN_PSK_IDENTITY TLS1_AD_UNKNOWN_PSK_IDENTITY |
| 4379 |
#define SSL_AD_CERTIFICATE_REQUIRED TLS1_AD_CERTIFICATE_REQUIRED |
| 4380 |
#define SSL_AD_NO_APPLICATION_PROTOCOL TLS1_AD_NO_APPLICATION_PROTOCOL |
| 4381 |
#define SSL_AD_ECH_REQUIRED TLS1_AD_ECH_REQUIRED |
| 4382 |
|
| 4383 |
// SSL_alert_type_string_long returns a string description of |value| as an |
| 4384 |
// alert type (warning or fatal). |
| 4385 |
OPENSSL_EXPORT const char *SSL_alert_type_string_long(int value); |
| 4386 |
|
| 4387 |
// SSL_alert_desc_string_long returns a string description of |value| as an |
| 4388 |
// alert description or "unknown" if unknown. |
| 4389 |
OPENSSL_EXPORT const char *SSL_alert_desc_string_long(int value); |
| 4390 |
|
| 4391 |
// SSL_send_fatal_alert sends a fatal alert over |ssl| of the specified type, |
| 4392 |
// which should be one of the |SSL_AD_*| constants. It returns one on success |
| 4393 |
// and <= 0 on error. The caller should pass the return value into |
| 4394 |
// |SSL_get_error| to determine how to proceed. Once this function has been |
| 4395 |
// called, future calls to |SSL_write| will fail. |
| 4396 |
// |
| 4397 |
// If retrying a failed operation due to |SSL_ERROR_WANT_WRITE|, subsequent |
| 4398 |
// calls must use the same |alert| parameter. |
| 4399 |
OPENSSL_EXPORT int SSL_send_fatal_alert(SSL *ssl, uint8_t alert); |
| 4400 |
|
| 4401 |
|
| 4402 |
// ex_data functions. |
| 4403 |
// |
| 4404 |
// See |ex_data.h| for details. |
| 4405 |
|
| 4406 |
OPENSSL_EXPORT int SSL_set_ex_data(SSL *ssl, int idx, void *data); |
| 4407 |
OPENSSL_EXPORT void *SSL_get_ex_data(const SSL *ssl, int idx); |
| 4408 |
OPENSSL_EXPORT int SSL_get_ex_new_index(long argl, void *argp, |
| 4409 |
CRYPTO_EX_unused *unused, |
| 4410 |
CRYPTO_EX_dup *dup_unused, |
| 4411 |
CRYPTO_EX_free *free_func); |
| 4412 |
|
| 4413 |
OPENSSL_EXPORT int SSL_SESSION_set_ex_data(SSL_SESSION *session, int idx, |
| 4414 |
void *data); |
| 4415 |
OPENSSL_EXPORT void *SSL_SESSION_get_ex_data(const SSL_SESSION *session, |
| 4416 |
int idx); |
| 4417 |
OPENSSL_EXPORT int SSL_SESSION_get_ex_new_index(long argl, void *argp, |
| 4418 |
CRYPTO_EX_unused *unused, |
| 4419 |
CRYPTO_EX_dup *dup_unused, |
| 4420 |
CRYPTO_EX_free *free_func); |
| 4421 |
|
| 4422 |
OPENSSL_EXPORT int SSL_CTX_set_ex_data(SSL_CTX *ctx, int idx, void *data); |
| 4423 |
OPENSSL_EXPORT void *SSL_CTX_get_ex_data(const SSL_CTX *ctx, int idx); |
| 4424 |
OPENSSL_EXPORT int SSL_CTX_get_ex_new_index(long argl, void *argp, |
| 4425 |
CRYPTO_EX_unused *unused, |
| 4426 |
CRYPTO_EX_dup *dup_unused, |
| 4427 |
CRYPTO_EX_free *free_func); |
| 4428 |
|
| 4429 |
|
| 4430 |
// Low-level record-layer state. |
| 4431 |
|
| 4432 |
// SSL_get_ivs sets |*out_iv_len| to the length of the IVs for the ciphers |
| 4433 |
// underlying |ssl| and sets |*out_read_iv| and |*out_write_iv| to point to the |
| 4434 |
// current IVs for the read and write directions. This is only meaningful for |
| 4435 |
// connections with implicit IVs (i.e. CBC mode with TLS 1.0). |
| 4436 |
// |
| 4437 |
// It returns one on success or zero on error. |
| 4438 |
OPENSSL_EXPORT int SSL_get_ivs(const SSL *ssl, const uint8_t **out_read_iv, |
| 4439 |
const uint8_t **out_write_iv, |
| 4440 |
size_t *out_iv_len); |
| 4441 |
|
| 4442 |
// SSL_get_key_block_len returns the length of |ssl|'s key block, for TLS 1.2 |
| 4443 |
// and below. It is an error to call this function during a handshake, or if |
| 4444 |
// |ssl| negotiated TLS 1.3. |
| 4445 |
OPENSSL_EXPORT size_t SSL_get_key_block_len(const SSL *ssl); |
| 4446 |
|
| 4447 |
// SSL_generate_key_block generates |out_len| bytes of key material for |ssl|'s |
| 4448 |
// current connection state, for TLS 1.2 and below. It is an error to call this |
| 4449 |
// function during a handshake, or if |ssl| negotiated TLS 1.3. |
| 4450 |
OPENSSL_EXPORT int SSL_generate_key_block(const SSL *ssl, uint8_t *out, |
| 4451 |
size_t out_len); |
| 4452 |
|
| 4453 |
// SSL_get_read_traffic_secret retrives |ssl|'s read traffic key for the current |
| 4454 |
// connection state. This is only valid for TLS 1.3 connections. It is an error |
| 4455 |
// to call this function during a handshake, or if |ssl| was negotiated with |
| 4456 |
// TLS 1.2 or lower. |
| 4457 |
// |
| 4458 |
// If |secret| is NULL then |*out_len| is |
| 4459 |
// set to the maximum number of output bytes. Otherwise, on entry, |
| 4460 |
// |*out_len| must contain the length of the |secret| buffer. If the call |
| 4461 |
// is successful, the read traffic secret is written to |secret| and |*out_len| |
| 4462 |
// is set to its length. |
| 4463 |
// |
| 4464 |
// It returns one on success, or zero on error. |
| 4465 |
OPENSSL_EXPORT int SSL_get_read_traffic_secret( |
| 4466 |
const SSL *ssl, |
| 4467 |
uint8_t *secret, size_t *out_len); |
| 4468 |
|
| 4469 |
// SSL_get_write_traffic_secret retrieves |ssl|'s write traffic key for the |
| 4470 |
// current connection state. This is only valid for TLS 1.3 connections. It is |
| 4471 |
// an error to call this function during a handshake, or if |ssl| was negotiated |
| 4472 |
// with TLS 1.2 or lower. |
| 4473 |
// |
| 4474 |
// If |secret| is NULL then |*out_len| is |
| 4475 |
// set to the maximum number of output bytes. Otherwise, on entry, |
| 4476 |
// |*out_len| must contain the length of the |secret| buffer. If the call |
| 4477 |
// is successful, the write traffic secret is written to |secret| and |*out_len| |
| 4478 |
// is set to its length. |
| 4479 |
// |
| 4480 |
// It returns one on success, or zero on error. |
| 4481 |
OPENSSL_EXPORT int SSL_get_write_traffic_secret( |
| 4482 |
const SSL *ssl, |
| 4483 |
uint8_t *secret, size_t *out_len); |
| 4484 |
|
| 4485 |
// SSL_get_read_sequence returns, in TLS, the expected sequence number of the |
| 4486 |
// next incoming record in the current epoch. In DTLS, it returns the maximum |
| 4487 |
// sequence number received in the current epoch and includes the epoch number |
| 4488 |
// in the two most significant bytes. |
| 4489 |
OPENSSL_EXPORT uint64_t SSL_get_read_sequence(const SSL *ssl); |
| 4490 |
|
| 4491 |
// SSL_get_write_sequence returns the sequence number of the next outgoing |
| 4492 |
// record in the current epoch. In DTLS, it includes the epoch number in the |
| 4493 |
// two most significant bytes. |
| 4494 |
OPENSSL_EXPORT uint64_t SSL_get_write_sequence(const SSL *ssl); |
| 4495 |
|
| 4496 |
// SSL_CTX_set_record_protocol_version returns whether |version| is zero. |
| 4497 |
OPENSSL_EXPORT int SSL_CTX_set_record_protocol_version(SSL_CTX *ctx, |
| 4498 |
int version); |
| 4499 |
|
| 4500 |
|
| 4501 |
// Handshake hints. |
| 4502 |
// |
| 4503 |
// WARNING: Contact the BoringSSL team before using this API. While this |
| 4504 |
// mechanism was designed to gracefully recover from version skew and |
| 4505 |
// configuration mismatch, splitting a single TLS server into multiple services |
| 4506 |
// is complex. |
| 4507 |
// |
| 4508 |
// Some server deployments make asynchronous RPC calls in both ClientHello |
| 4509 |
// dispatch and private key operations. In TLS handshakes where the private key |
| 4510 |
// operation occurs in the first round-trip, this results in two consecutive RPC |
| 4511 |
// round-trips. Handshake hints allow the RPC service to predict a signature. |
| 4512 |
// If correctly predicted, this can skip the second RPC call. |
| 4513 |
// |
| 4514 |
// First, the server installs a certificate selection callback (see |
| 4515 |
// |SSL_CTX_set_select_certificate_cb|). When that is called, it performs the |
| 4516 |
// RPC as before, but includes the ClientHello and a capabilities string from |
| 4517 |
// |SSL_serialize_capabilities|. |
| 4518 |
// |
| 4519 |
// Next, the RPC service creates its own |SSL| object, applies the results of |
| 4520 |
// certificate selection, calls |SSL_request_handshake_hints|, and runs the |
| 4521 |
// handshake. If this successfully computes handshake hints (see |
| 4522 |
// |SSL_serialize_handshake_hints|), the RPC server should send the hints |
| 4523 |
// alongside any certificate selection results. |
| 4524 |
// |
| 4525 |
// Finally, the server calls |SSL_set_handshake_hints| and applies any |
| 4526 |
// configuration from the RPC server. It then completes the handshake as before. |
| 4527 |
// If the hints apply, BoringSSL will use the predicted signature and skip the |
| 4528 |
// private key callbacks. Otherwise, BoringSSL will call private key callbacks |
| 4529 |
// to generate a signature as before. |
| 4530 |
// |
| 4531 |
// Callers should synchronize configuration across the two services. |
| 4532 |
// Configuration mismatches and some cases of version skew are not fatal, but |
| 4533 |
// may result in the hints not applying. Additionally, some handshake flows use |
| 4534 |
// the private key in later round-trips, such as TLS 1.3 HelloRetryRequest. In |
| 4535 |
// those cases, BoringSSL will not predict a signature as there is no benefit. |
| 4536 |
// Callers must allow for handshakes to complete without a predicted signature. |
| 4537 |
|
| 4538 |
// SSL_serialize_capabilities writes an opaque byte string to |out| describing |
| 4539 |
// some of |ssl|'s capabilities. It returns one on success and zero on error. |
| 4540 |
// |
| 4541 |
// This string is used by BoringSSL internally to reduce the impact of version |
| 4542 |
// skew. |
| 4543 |
OPENSSL_EXPORT int SSL_serialize_capabilities(const SSL *ssl, CBB *out); |
| 4544 |
|
| 4545 |
// SSL_request_handshake_hints configures |ssl| to generate a handshake hint for |
| 4546 |
// |client_hello|. It returns one on success and zero on error. |client_hello| |
| 4547 |
// should contain a serialized ClientHello structure, from the |client_hello| |
| 4548 |
// and |client_hello_len| fields of the |SSL_CLIENT_HELLO| structure. |
| 4549 |
// |capabilities| should contain the output of |SSL_serialize_capabilities|. |
| 4550 |
// |
| 4551 |
// When configured, |ssl| will perform no I/O (so there is no need to configure |
| 4552 |
// |BIO|s). For QUIC, the caller should still configure an |SSL_QUIC_METHOD|, |
| 4553 |
// but the callbacks themselves will never be called and may be left NULL or |
| 4554 |
// report failure. |SSL_provide_quic_data| also should not be called. |
| 4555 |
// |
| 4556 |
// If hint generation is successful, |SSL_do_handshake| will stop the handshake |
| 4557 |
// early with |SSL_get_error| returning |SSL_ERROR_HANDSHAKE_HINTS_READY|. At |
| 4558 |
// this point, the caller should run |SSL_serialize_handshake_hints| to extract |
| 4559 |
// the resulting hints. |
| 4560 |
// |
| 4561 |
// Hint generation may fail if, e.g., |ssl| was unable to process the |
| 4562 |
// ClientHello. Callers should then complete the certificate selection RPC and |
| 4563 |
// continue the original handshake with no hint. It will likely fail, but this |
| 4564 |
// reports the correct alert to the client and is more robust in case of |
| 4565 |
// mismatch. |
| 4566 |
OPENSSL_EXPORT int SSL_request_handshake_hints(SSL *ssl, |
| 4567 |
const uint8_t *client_hello, |
| 4568 |
size_t client_hello_len, |
| 4569 |
const uint8_t *capabilities, |
| 4570 |
size_t capabilities_len); |
| 4571 |
|
| 4572 |
// SSL_serialize_handshake_hints writes an opaque byte string to |out| |
| 4573 |
// containing the handshake hints computed by |out|. It returns one on success |
| 4574 |
// and zero on error. This function should only be called if |
| 4575 |
// |SSL_request_handshake_hints| was configured and the handshake terminated |
| 4576 |
// with |SSL_ERROR_HANDSHAKE_HINTS_READY|. |
| 4577 |
// |
| 4578 |
// This string may be passed to |SSL_set_handshake_hints| on another |SSL| to |
| 4579 |
// avoid an extra signature call. |
| 4580 |
OPENSSL_EXPORT int SSL_serialize_handshake_hints(const SSL *ssl, CBB *out); |
| 4581 |
|
| 4582 |
// SSL_set_handshake_hints configures |ssl| to use |hints| as handshake hints. |
| 4583 |
// It returns one on success and zero on error. The handshake will then continue |
| 4584 |
// as before, but apply predicted values from |hints| where applicable. |
| 4585 |
// |
| 4586 |
// Hints may contain connection and session secrets, so they must not leak and |
| 4587 |
// must come from a source trusted to terminate the connection. However, they |
| 4588 |
// will not change |ssl|'s configuration. The caller is responsible for |
| 4589 |
// serializing and applying options from the RPC server as needed. This ensures |
| 4590 |
// |ssl|'s behavior is self-consistent and consistent with the caller's local |
| 4591 |
// decisions. |
| 4592 |
OPENSSL_EXPORT int SSL_set_handshake_hints(SSL *ssl, const uint8_t *hints, |
| 4593 |
size_t hints_len); |
| 4594 |
|
| 4595 |
|
| 4596 |
// Obscure functions. |
| 4597 |
|
| 4598 |
// SSL_CTX_set_msg_callback installs |cb| as the message callback for |ctx|. |
| 4599 |
// This callback will be called when sending or receiving low-level record |
| 4600 |
// headers, complete handshake messages, ChangeCipherSpec, and alerts. |
| 4601 |
// |write_p| is one for outgoing messages and zero for incoming messages. |
| 4602 |
// |
| 4603 |
// For each record header, |cb| is called with |version| = 0 and |content_type| |
| 4604 |
// = |SSL3_RT_HEADER|. The |len| bytes from |buf| contain the header. Note that |
| 4605 |
// this does not include the record body. If the record is sealed, the length |
| 4606 |
// in the header is the length of the ciphertext. |
| 4607 |
// |
| 4608 |
// For each handshake message, ChangeCipherSpec, and alert, |version| is the |
| 4609 |
// protocol version and |content_type| is the corresponding record type. The |
| 4610 |
// |len| bytes from |buf| contain the handshake message, one-byte |
| 4611 |
// ChangeCipherSpec body, and two-byte alert, respectively. |
| 4612 |
// |
| 4613 |
// In connections that enable ECH, |cb| is additionally called with |
| 4614 |
// |content_type| = |SSL3_RT_CLIENT_HELLO_INNER| for each ClientHelloInner that |
| 4615 |
// is encrypted or decrypted. The |len| bytes from |buf| contain the |
| 4616 |
// ClientHelloInner, including the reconstructed outer extensions and handshake |
| 4617 |
// header. |
| 4618 |
// |
| 4619 |
// For a V2ClientHello, |version| is |SSL2_VERSION|, |content_type| is zero, and |
| 4620 |
// the |len| bytes from |buf| contain the V2ClientHello structure. |
| 4621 |
OPENSSL_EXPORT void SSL_CTX_set_msg_callback( |
| 4622 |
SSL_CTX *ctx, void (*cb)(int is_write, int version, int content_type, |
| 4623 |
const void *buf, size_t len, SSL *ssl, void *arg)); |
| 4624 |
|
| 4625 |
// SSL_CTX_set_msg_callback_arg sets the |arg| parameter of the message |
| 4626 |
// callback. |
| 4627 |
OPENSSL_EXPORT void SSL_CTX_set_msg_callback_arg(SSL_CTX *ctx, void *arg); |
| 4628 |
|
| 4629 |
// SSL_set_msg_callback installs |cb| as the message callback of |ssl|. See |
| 4630 |
// |SSL_CTX_set_msg_callback| for when this callback is called. |
| 4631 |
OPENSSL_EXPORT void SSL_set_msg_callback( |
| 4632 |
SSL *ssl, void (*cb)(int write_p, int version, int content_type, |
| 4633 |
const void *buf, size_t len, SSL *ssl, void *arg)); |
| 4634 |
|
| 4635 |
// SSL_set_msg_callback_arg sets the |arg| parameter of the message callback. |
| 4636 |
OPENSSL_EXPORT void SSL_set_msg_callback_arg(SSL *ssl, void *arg); |
| 4637 |
|
| 4638 |
// SSL_CTX_set_keylog_callback configures a callback to log key material. This |
| 4639 |
// is intended for debugging use with tools like Wireshark. The |cb| function |
| 4640 |
// should log |line| followed by a newline, synchronizing with any concurrent |
| 4641 |
// access to the log. |
| 4642 |
// |
| 4643 |
// The format is described in |
| 4644 |
// https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format. |
| 4645 |
OPENSSL_EXPORT void SSL_CTX_set_keylog_callback(SSL_CTX *ctx, |
| 4646 |
void (*cb)(const SSL *ssl, |
| 4647 |
const char *line)); |
| 4648 |
|
| 4649 |
// SSL_CTX_get_keylog_callback returns the callback configured by |
| 4650 |
// |SSL_CTX_set_keylog_callback|. |
| 4651 |
OPENSSL_EXPORT void (*SSL_CTX_get_keylog_callback(const SSL_CTX *ctx))( |
| 4652 |
const SSL *ssl, const char *line); |
| 4653 |
|
| 4654 |
// SSL_CTX_set_current_time_cb configures a callback to retrieve the current |
| 4655 |
// time, which should be set in |*out_clock|. This can be used for testing |
| 4656 |
// purposes; for example, a callback can be configured that returns a time |
| 4657 |
// set explicitly by the test. The |ssl| pointer passed to |cb| is always null. |
| 4658 |
OPENSSL_EXPORT void SSL_CTX_set_current_time_cb( |
| 4659 |
SSL_CTX *ctx, void (*cb)(const SSL *ssl, struct timeval *out_clock)); |
| 4660 |
|
| 4661 |
// SSL_set_shed_handshake_config allows some of the configuration of |ssl| to be |
| 4662 |
// freed after its handshake completes. Once configuration has been shed, APIs |
| 4663 |
// that query it may fail. "Configuration" in this context means anything that |
| 4664 |
// was set by the caller, as distinct from information derived from the |
| 4665 |
// handshake. For example, |SSL_get_ciphers| queries how the |SSL| was |
| 4666 |
// configured by the caller, and fails after configuration has been shed, |
| 4667 |
// whereas |SSL_get_cipher| queries the result of the handshake, and is |
| 4668 |
// unaffected by configuration shedding. |
| 4669 |
// |
| 4670 |
// If configuration shedding is enabled, it is an error to call |SSL_clear|. |
| 4671 |
// |
| 4672 |
// Note that configuration shedding as a client additionally depends on |
| 4673 |
// renegotiation being disabled (see |SSL_set_renegotiate_mode|). If |
| 4674 |
// renegotiation is possible, the configuration will be retained. If |
| 4675 |
// configuration shedding is enabled and renegotiation later disabled after the |
| 4676 |
// handshake, |SSL_set_renegotiate_mode| will shed configuration then. This may |
| 4677 |
// be useful for clients which support renegotiation with some ALPN protocols, |
| 4678 |
// such as HTTP/1.1, and not others, such as HTTP/2. |
| 4679 |
OPENSSL_EXPORT void SSL_set_shed_handshake_config(SSL *ssl, int enable); |
| 4680 |
|
| 4681 |
enum ssl_renegotiate_mode_t { |
| 4682 |
ssl_renegotiate_never = 0, |
| 4683 |
ssl_renegotiate_once, |
| 4684 |
ssl_renegotiate_freely, |
| 4685 |
ssl_renegotiate_ignore, |
| 4686 |
ssl_renegotiate_explicit |
| 4687 |
}; |
| 4688 |
|
| 4689 |
// SSL_set_renegotiate_mode configures how |ssl|, a client, reacts to |
| 4690 |
// renegotiation attempts by a server. If |ssl| is a server, peer-initiated |
| 4691 |
// renegotiations are *always* rejected and this function does nothing. |
| 4692 |
// |
| 4693 |
// WARNING: Renegotiation is error-prone, complicates TLS's security properties, |
| 4694 |
// and increases its attack surface. When enabled, many common assumptions about |
| 4695 |
// BoringSSL's behavior no longer hold, and the calling application must handle |
| 4696 |
// more cases. Renegotiation is also incompatible with many application |
| 4697 |
// protocols, e.g. section 9.2.1 of RFC 7540. Many functions behave in ambiguous |
| 4698 |
// or undefined ways during a renegotiation. |
| 4699 |
// |
| 4700 |
// The renegotiation mode defaults to |ssl_renegotiate_never|, but may be set |
| 4701 |
// at any point in a connection's lifetime. Set it to |ssl_renegotiate_once| to |
| 4702 |
// allow one renegotiation, |ssl_renegotiate_freely| to allow all |
| 4703 |
// renegotiations or |ssl_renegotiate_ignore| to ignore HelloRequest messages. |
| 4704 |
// Note that ignoring HelloRequest messages may cause the connection to stall |
| 4705 |
// if the server waits for the renegotiation to complete. |
| 4706 |
// |
| 4707 |
// If set to |ssl_renegotiate_explicit|, |SSL_read| and |SSL_peek| calls which |
| 4708 |
// encounter a HelloRequest will pause with |SSL_ERROR_WANT_RENEGOTIATE|. |
| 4709 |
// |SSL_write| will continue to work while paused. The caller may call |
| 4710 |
// |SSL_renegotiate| to begin the renegotiation at a later point. This mode may |
| 4711 |
// be used if callers wish to eagerly call |SSL_peek| without triggering a |
| 4712 |
// renegotiation. |
| 4713 |
// |
| 4714 |
// If configuration shedding is enabled (see |SSL_set_shed_handshake_config|), |
| 4715 |
// configuration is released if, at any point after the handshake, renegotiation |
| 4716 |
// is disabled. It is not possible to switch from disabling renegotiation to |
| 4717 |
// enabling it on a given connection. Callers that condition renegotiation on, |
| 4718 |
// e.g., ALPN must enable renegotiation before the handshake and conditionally |
| 4719 |
// disable it afterwards. |
| 4720 |
// |
| 4721 |
// When enabled, renegotiation can cause properties of |ssl|, such as the cipher |
| 4722 |
// suite, to change during the lifetime of the connection. More over, during a |
| 4723 |
// renegotiation, not all properties of the new handshake are available or fully |
| 4724 |
// established. In BoringSSL, most functions, such as |SSL_get_current_cipher|, |
| 4725 |
// report information from the most recently completed handshake, not the |
| 4726 |
// pending one. However, renegotiation may rerun handshake callbacks, such as |
| 4727 |
// |SSL_CTX_set_cert_cb|. Such callbacks must ensure they are acting on the |
| 4728 |
// desired versions of each property. |
| 4729 |
// |
| 4730 |
// BoringSSL does not reverify peer certificates on renegotiation and instead |
| 4731 |
// requires they match between handshakes, so certificate verification callbacks |
| 4732 |
// (see |SSL_CTX_set_custom_verify|) may assume |ssl| is in the initial |
| 4733 |
// handshake and use |SSL_get0_peer_certificates|, etc. |
| 4734 |
// |
| 4735 |
// There is no support in BoringSSL for initiating renegotiations as a client |
| 4736 |
// or server. |
| 4737 |
OPENSSL_EXPORT void SSL_set_renegotiate_mode(SSL *ssl, |
| 4738 |
enum ssl_renegotiate_mode_t mode); |
| 4739 |
|
| 4740 |
// SSL_renegotiate starts a deferred renegotiation on |ssl| if it was configured |
| 4741 |
// with |ssl_renegotiate_explicit| and has a pending HelloRequest. It returns |
| 4742 |
// one on success and zero on error. |
| 4743 |
// |
| 4744 |
// This function does not do perform any I/O. On success, a subsequent |
| 4745 |
// |SSL_do_handshake| call will run the handshake. |SSL_write| and |
| 4746 |
// |SSL_read| will also complete the handshake before sending or receiving |
| 4747 |
// application data. |
| 4748 |
OPENSSL_EXPORT int SSL_renegotiate(SSL *ssl); |
| 4749 |
|
| 4750 |
// SSL_renegotiate_pending returns one if |ssl| is in the middle of a |
| 4751 |
// renegotiation. |
| 4752 |
OPENSSL_EXPORT int SSL_renegotiate_pending(SSL *ssl); |
| 4753 |
|
| 4754 |
// SSL_total_renegotiations returns the total number of renegotiation handshakes |
| 4755 |
// performed by |ssl|. This includes the pending renegotiation, if any. |
| 4756 |
OPENSSL_EXPORT int SSL_total_renegotiations(const SSL *ssl); |
| 4757 |
|
| 4758 |
// SSL_MAX_CERT_LIST_DEFAULT is the default maximum length, in bytes, of a peer |
| 4759 |
// certificate chain. |
| 4760 |
#define SSL_MAX_CERT_LIST_DEFAULT (1024 * 100) |
| 4761 |
|
| 4762 |
// SSL_CTX_get_max_cert_list returns the maximum length, in bytes, of a peer |
| 4763 |
// certificate chain accepted by |ctx|. |
| 4764 |
OPENSSL_EXPORT size_t SSL_CTX_get_max_cert_list(const SSL_CTX *ctx); |
| 4765 |
|
| 4766 |
// SSL_CTX_set_max_cert_list sets the maximum length, in bytes, of a peer |
| 4767 |
// certificate chain to |max_cert_list|. This affects how much memory may be |
| 4768 |
// consumed during the handshake. |
| 4769 |
OPENSSL_EXPORT void SSL_CTX_set_max_cert_list(SSL_CTX *ctx, |
| 4770 |
size_t max_cert_list); |
| 4771 |
|
| 4772 |
// SSL_get_max_cert_list returns the maximum length, in bytes, of a peer |
| 4773 |
// certificate chain accepted by |ssl|. |
| 4774 |
OPENSSL_EXPORT size_t SSL_get_max_cert_list(const SSL *ssl); |
| 4775 |
|
| 4776 |
// SSL_set_max_cert_list sets the maximum length, in bytes, of a peer |
| 4777 |
// certificate chain to |max_cert_list|. This affects how much memory may be |
| 4778 |
// consumed during the handshake. |
| 4779 |
OPENSSL_EXPORT void SSL_set_max_cert_list(SSL *ssl, size_t max_cert_list); |
| 4780 |
|
| 4781 |
// SSL_CTX_set_max_send_fragment sets the maximum length, in bytes, of records |
| 4782 |
// sent by |ctx|. Beyond this length, handshake messages and application data |
| 4783 |
// will be split into multiple records. It returns one on success or zero on |
| 4784 |
// error. |
| 4785 |
OPENSSL_EXPORT int SSL_CTX_set_max_send_fragment(SSL_CTX *ctx, |
| 4786 |
size_t max_send_fragment); |
| 4787 |
|
| 4788 |
// SSL_set_max_send_fragment sets the maximum length, in bytes, of records sent |
| 4789 |
// by |ssl|. Beyond this length, handshake messages and application data will |
| 4790 |
// be split into multiple records. It returns one on success or zero on |
| 4791 |
// error. The minimum is 512, and the max is 16384. |
| 4792 |
OPENSSL_EXPORT int SSL_set_max_send_fragment(SSL *ssl, |
| 4793 |
size_t max_send_fragment); |
| 4794 |
|
| 4795 |
// ssl_early_callback_ctx (aka |SSL_CLIENT_HELLO|) is passed to certain |
| 4796 |
// callbacks that are called very early on during the server handshake. At this |
| 4797 |
// point, much of the SSL* hasn't been filled out and only the ClientHello can |
| 4798 |
// be depended on. |
| 4799 |
struct ssl_early_callback_ctx { |
| 4800 |
SSL *ssl; |
| 4801 |
const uint8_t *client_hello; |
| 4802 |
size_t client_hello_len; |
| 4803 |
uint16_t version; |
| 4804 |
const uint8_t *random; |
| 4805 |
size_t random_len; |
| 4806 |
const uint8_t *session_id; |
| 4807 |
size_t session_id_len; |
| 4808 |
const uint8_t *cipher_suites; |
| 4809 |
size_t cipher_suites_len; |
| 4810 |
const uint8_t *compression_methods; |
| 4811 |
size_t compression_methods_len; |
| 4812 |
const uint8_t *extensions; |
| 4813 |
size_t extensions_len; |
| 4814 |
} /* SSL_CLIENT_HELLO */; |
| 4815 |
|
| 4816 |
// ssl_select_cert_result_t enumerates the possible results from selecting a |
| 4817 |
// certificate with |select_certificate_cb|. |
| 4818 |
enum ssl_select_cert_result_t { |
| 4819 |
// ssl_select_cert_success indicates that the certificate selection was |
| 4820 |
// successful. |
| 4821 |
ssl_select_cert_success = 1, |
| 4822 |
// ssl_select_cert_retry indicates that the operation could not be |
| 4823 |
// immediately completed and must be reattempted at a later point. |
| 4824 |
ssl_select_cert_retry = 0, |
| 4825 |
// ssl_select_cert_error indicates that a fatal error occured and the |
| 4826 |
// handshake should be terminated. |
| 4827 |
ssl_select_cert_error = -1 |
| 4828 |
}; |
| 4829 |
|
| 4830 |
// SSL_early_callback_ctx_extension_get searches the extensions in |
| 4831 |
// |client_hello| for an extension of the given type. If not found, it returns |
| 4832 |
// zero. Otherwise it sets |out_data| to point to the extension contents (not |
| 4833 |
// including the type and length bytes), sets |out_len| to the length of the |
| 4834 |
// extension contents and returns one. |
| 4835 |
OPENSSL_EXPORT int SSL_early_callback_ctx_extension_get( |
| 4836 |
const SSL_CLIENT_HELLO *client_hello, uint16_t extension_type, |
| 4837 |
const uint8_t **out_data, size_t *out_len); |
| 4838 |
|
| 4839 |
// SSL_CTX_set_select_certificate_cb sets a callback that is called before most |
| 4840 |
// ClientHello processing and before the decision whether to resume a session |
| 4841 |
// is made. The callback may inspect the ClientHello and configure the |
| 4842 |
// connection. See |ssl_select_cert_result_t| for details of the return values. |
| 4843 |
// |
| 4844 |
// In the case that a retry is indicated, |SSL_get_error| will return |
| 4845 |
// |SSL_ERROR_PENDING_CERTIFICATE| and the caller should arrange for the |
| 4846 |
// high-level operation on |ssl| to be retried at a later time, which will |
| 4847 |
// result in another call to |cb|. |
| 4848 |
// |
| 4849 |
// |SSL_get_servername| may be used during this callback. |
| 4850 |
// |
| 4851 |
// Note: The |SSL_CLIENT_HELLO| is only valid for the duration of the callback |
| 4852 |
// and is not valid while the handshake is paused. |
| 4853 |
OPENSSL_EXPORT void SSL_CTX_set_select_certificate_cb( |
| 4854 |
SSL_CTX *ctx, |
| 4855 |
enum ssl_select_cert_result_t (*cb)(const SSL_CLIENT_HELLO *)); |
| 4856 |
|
| 4857 |
// SSL_CTX_set_dos_protection_cb sets a callback that is called once the |
| 4858 |
// resumption decision for a ClientHello has been made. It can return one to |
| 4859 |
// allow the handshake to continue or zero to cause the handshake to abort. |
| 4860 |
OPENSSL_EXPORT void SSL_CTX_set_dos_protection_cb( |
| 4861 |
SSL_CTX *ctx, int (*cb)(const SSL_CLIENT_HELLO *)); |
| 4862 |
|
| 4863 |
// SSL_CTX_set_reverify_on_resume configures whether the certificate |
| 4864 |
// verification callback will be used to reverify stored certificates |
| 4865 |
// when resuming a session. This only works with |SSL_CTX_set_custom_verify|. |
| 4866 |
// For now, this is incompatible with |SSL_VERIFY_NONE| mode, and is only |
| 4867 |
// respected on clients. |
| 4868 |
OPENSSL_EXPORT void SSL_CTX_set_reverify_on_resume(SSL_CTX *ctx, int enabled); |
| 4869 |
|
| 4870 |
// SSL_set_enforce_rsa_key_usage configures whether, when |ssl| is a client |
| 4871 |
// negotiating TLS 1.2 or below, the keyUsage extension of RSA leaf server |
| 4872 |
// certificates will be checked for consistency with the TLS usage. In all other |
| 4873 |
// cases, this check is always enabled. |
| 4874 |
// |
| 4875 |
// This parameter may be set late; it will not be read until after the |
| 4876 |
// certificate verification callback. |
| 4877 |
OPENSSL_EXPORT void SSL_set_enforce_rsa_key_usage(SSL *ssl, int enabled); |
| 4878 |
|
| 4879 |
// SSL_was_key_usage_invalid returns one if |ssl|'s handshake succeeded despite |
| 4880 |
// using TLS parameters which were incompatible with the leaf certificate's |
| 4881 |
// keyUsage extension. Otherwise, it returns zero. |
| 4882 |
// |
| 4883 |
// If |SSL_set_enforce_rsa_key_usage| is enabled or not applicable, this |
| 4884 |
// function will always return zero because key usages will be consistently |
| 4885 |
// checked. |
| 4886 |
OPENSSL_EXPORT int SSL_was_key_usage_invalid(const SSL *ssl); |
| 4887 |
|
| 4888 |
// SSL_ST_* are possible values for |SSL_state|, the bitmasks that make them up, |
| 4889 |
// and some historical values for compatibility. Only |SSL_ST_INIT| and |
| 4890 |
// |SSL_ST_OK| are ever returned. |
| 4891 |
#define SSL_ST_CONNECT 0x1000 |
| 4892 |
#define SSL_ST_ACCEPT 0x2000 |
| 4893 |
#define SSL_ST_MASK 0x0FFF |
| 4894 |
#define SSL_ST_INIT (SSL_ST_CONNECT | SSL_ST_ACCEPT) |
| 4895 |
#define SSL_ST_OK 0x03 |
| 4896 |
#define SSL_ST_RENEGOTIATE (0x04 | SSL_ST_INIT) |
| 4897 |
#define SSL_ST_BEFORE (0x05 | SSL_ST_INIT) |
| 4898 |
|
| 4899 |
// OSSL_HANDSHAKE_STATE enumerates possible TLS states returned from |
| 4900 |
// |SSL_get_state| and |SSL_state|. TLS_ST_* are aliases for |SSL_ST_*| for |
| 4901 |
// OpenSSL 1.1.0 compatibility. |
| 4902 |
typedef enum { |
| 4903 |
TLS_ST_OK = SSL_ST_OK, |
| 4904 |
TLS_ST_BEFORE = SSL_ST_INIT |
| 4905 |
} OSSL_HANDSHAKE_STATE; |
| 4906 |
|
| 4907 |
// SSL_CB_* are possible values for the |type| parameter in the info |
| 4908 |
// callback and the bitmasks that make them up. |
| 4909 |
#define SSL_CB_LOOP 0x01 |
| 4910 |
#define SSL_CB_EXIT 0x02 |
| 4911 |
#define SSL_CB_READ 0x04 |
| 4912 |
#define SSL_CB_WRITE 0x08 |
| 4913 |
#define SSL_CB_ALERT 0x4000 |
| 4914 |
#define SSL_CB_READ_ALERT (SSL_CB_ALERT | SSL_CB_READ) |
| 4915 |
#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT | SSL_CB_WRITE) |
| 4916 |
#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT | SSL_CB_LOOP) |
| 4917 |
#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT | SSL_CB_EXIT) |
| 4918 |
#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT | SSL_CB_LOOP) |
| 4919 |
#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT | SSL_CB_EXIT) |
| 4920 |
#define SSL_CB_HANDSHAKE_START 0x10 |
| 4921 |
#define SSL_CB_HANDSHAKE_DONE 0x20 |
| 4922 |
|
| 4923 |
// SSL_CTX_set_info_callback configures a callback to be run when various |
| 4924 |
// events occur during a connection's lifetime. The |type| argument determines |
| 4925 |
// the type of event and the meaning of the |value| argument. Callbacks must |
| 4926 |
// ignore unexpected |type| values. |
| 4927 |
// |
| 4928 |
// |SSL_CB_READ_ALERT| is signaled for each alert received, warning or fatal. |
| 4929 |
// The |value| argument is a 16-bit value where the alert level (either |
| 4930 |
// |SSL3_AL_WARNING| or |SSL3_AL_FATAL|) is in the most-significant eight bits |
| 4931 |
// and the alert type (one of |SSL_AD_*|) is in the least-significant eight. |
| 4932 |
// |
| 4933 |
// |SSL_CB_WRITE_ALERT| is signaled for each alert sent. The |value| argument |
| 4934 |
// is constructed as with |SSL_CB_READ_ALERT|. |
| 4935 |
// |
| 4936 |
// |SSL_CB_HANDSHAKE_START| is signaled when a handshake begins. The |value| |
| 4937 |
// argument is always one. |
| 4938 |
// |
| 4939 |
// |SSL_CB_HANDSHAKE_DONE| is signaled when a handshake completes successfully. |
| 4940 |
// The |value| argument is always one. If a handshake False Starts, this event |
| 4941 |
// may be used to determine when the Finished message is received. |
| 4942 |
// |
| 4943 |
// The following event types expose implementation details of the handshake |
| 4944 |
// state machine. Consuming them is deprecated. |
| 4945 |
// |
| 4946 |
// |SSL_CB_ACCEPT_LOOP| (respectively, |SSL_CB_CONNECT_LOOP|) is signaled when |
| 4947 |
// a server (respectively, client) handshake progresses. The |value| argument |
| 4948 |
// is always one. |
| 4949 |
// |
| 4950 |
// |SSL_CB_ACCEPT_EXIT| (respectively, |SSL_CB_CONNECT_EXIT|) is signaled when |
| 4951 |
// a server (respectively, client) handshake completes, fails, or is paused. |
| 4952 |
// The |value| argument is one if the handshake succeeded and <= 0 |
| 4953 |
// otherwise. |
| 4954 |
OPENSSL_EXPORT void SSL_CTX_set_info_callback(SSL_CTX *ctx, |
| 4955 |
void (*cb)(const SSL *ssl, |
| 4956 |
int type, int value)); |
| 4957 |
|
| 4958 |
// SSL_CTX_get_info_callback returns the callback set by |
| 4959 |
// |SSL_CTX_set_info_callback|. |
| 4960 |
OPENSSL_EXPORT void (*SSL_CTX_get_info_callback(SSL_CTX *ctx))(const SSL *ssl, |
| 4961 |
int type, |
| 4962 |
int value); |
| 4963 |
|
| 4964 |
// SSL_set_info_callback configures a callback to be run at various events |
| 4965 |
// during a connection's lifetime. See |SSL_CTX_set_info_callback|. |
| 4966 |
OPENSSL_EXPORT void SSL_set_info_callback(SSL *ssl, |
| 4967 |
void (*cb)(const SSL *ssl, int type, |
| 4968 |
int value)); |
| 4969 |
|
| 4970 |
// SSL_get_info_callback returns the callback set by |SSL_set_info_callback|. |
| 4971 |
OPENSSL_EXPORT void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl, |
| 4972 |
int type, |
| 4973 |
int value); |
| 4974 |
|
| 4975 |
// SSL_state_string_long returns the current state of the handshake state |
| 4976 |
// machine as a string. This may be useful for debugging and logging. |
| 4977 |
OPENSSL_EXPORT const char *SSL_state_string_long(const SSL *ssl); |
| 4978 |
|
| 4979 |
#define SSL_SENT_SHUTDOWN 1 |
| 4980 |
#define SSL_RECEIVED_SHUTDOWN 2 |
| 4981 |
|
| 4982 |
// SSL_get_shutdown returns a bitmask with a subset of |SSL_SENT_SHUTDOWN| and |
| 4983 |
// |SSL_RECEIVED_SHUTDOWN| to query whether close_notify was sent or received, |
| 4984 |
// respectively. |
| 4985 |
OPENSSL_EXPORT int SSL_get_shutdown(const SSL *ssl); |
| 4986 |
|
| 4987 |
// SSL_get_peer_signature_algorithm returns the signature algorithm used by the |
| 4988 |
// peer. If not applicable, it returns zero. |
| 4989 |
OPENSSL_EXPORT uint16_t SSL_get_peer_signature_algorithm(const SSL *ssl); |
| 4990 |
|
| 4991 |
// SSL_get_peer_signature_nid sets |psig_nid| to the NID of the digest used by |
| 4992 |
// the peer to sign their TLS messages. Returns one on success and zero on |
| 4993 |
// failure. |
| 4994 |
OPENSSL_EXPORT int SSL_get_peer_signature_nid(const SSL *ssl, int *psig_nid); |
| 4995 |
|
| 4996 |
// SSL_get_peer_signature_type_nid sets |psigtype_nid| to the signature type |
| 4997 |
// used by the peer to sign their TLS messages. The signature type is the NID of |
| 4998 |
// the public key type used for signing. Returns one on success and zero on |
| 4999 |
// failure. |
| 5000 |
OPENSSL_EXPORT int SSL_get_peer_signature_type_nid(const SSL *ssl, |
| 5001 |
int *psigtype_nid); |
| 5002 |
|
| 5003 |
// SSL_get_client_random writes up to |max_out| bytes of the most recent |
| 5004 |
// handshake's client_random to |out| and returns the number of bytes written. |
| 5005 |
// If |max_out| is zero, it returns the size of the client_random. |
| 5006 |
OPENSSL_EXPORT size_t SSL_get_client_random(const SSL *ssl, uint8_t *out, |
| 5007 |
size_t max_out); |
| 5008 |
|
| 5009 |
// SSL_get_server_random writes up to |max_out| bytes of the most recent |
| 5010 |
// handshake's server_random to |out| and returns the number of bytes written. |
| 5011 |
// If |max_out| is zero, it returns the size of the server_random. |
| 5012 |
OPENSSL_EXPORT size_t SSL_get_server_random(const SSL *ssl, uint8_t *out, |
| 5013 |
size_t max_out); |
| 5014 |
|
| 5015 |
// SSL_get_pending_cipher returns the cipher suite for the current handshake or |
| 5016 |
// NULL if one has not been negotiated yet or there is no pending handshake. |
| 5017 |
OPENSSL_EXPORT const SSL_CIPHER *SSL_get_pending_cipher(const SSL *ssl); |
| 5018 |
|
| 5019 |
// SSL_set_retain_only_sha256_of_client_certs, on a server, sets whether only |
| 5020 |
// the SHA-256 hash of peer's certificate should be saved in memory and in the |
| 5021 |
// session. This can save memory, ticket size and session cache space. If |
| 5022 |
// enabled, |SSL_get_peer_certificate| will return NULL after the handshake |
| 5023 |
// completes. See |SSL_SESSION_has_peer_sha256| and |
| 5024 |
// |SSL_SESSION_get0_peer_sha256| to query the hash. |
| 5025 |
OPENSSL_EXPORT void SSL_set_retain_only_sha256_of_client_certs(SSL *ssl, |
| 5026 |
int enable); |
| 5027 |
|
| 5028 |
// SSL_CTX_set_retain_only_sha256_of_client_certs, on a server, sets whether |
| 5029 |
// only the SHA-256 hash of peer's certificate should be saved in memory and in |
| 5030 |
// the session. This can save memory, ticket size and session cache space. If |
| 5031 |
// enabled, |SSL_get_peer_certificate| will return NULL after the handshake |
| 5032 |
// completes. See |SSL_SESSION_has_peer_sha256| and |
| 5033 |
// |SSL_SESSION_get0_peer_sha256| to query the hash. |
| 5034 |
OPENSSL_EXPORT void SSL_CTX_set_retain_only_sha256_of_client_certs(SSL_CTX *ctx, |
| 5035 |
int enable); |
| 5036 |
|
| 5037 |
// SSL_CTX_set_grease_enabled configures whether sockets on |ctx| should enable |
| 5038 |
// GREASE. See RFC 8701. |
| 5039 |
OPENSSL_EXPORT void SSL_CTX_set_grease_enabled(SSL_CTX *ctx, int enabled); |
| 5040 |
|
| 5041 |
// SSL_CTX_set_permute_extensions configures whether sockets on |ctx| should |
| 5042 |
// permute extensions. For now, this is only implemented for the ClientHello. |
| 5043 |
OPENSSL_EXPORT void SSL_CTX_set_permute_extensions(SSL_CTX *ctx, int enabled); |
| 5044 |
|
| 5045 |
// SSL_set_permute_extensions configures whether sockets on |ssl| should |
| 5046 |
// permute extensions. For now, this is only implemented for the ClientHello. |
| 5047 |
OPENSSL_EXPORT void SSL_set_permute_extensions(SSL *ssl, int enabled); |
| 5048 |
|
| 5049 |
// SSL_max_seal_overhead returns the maximum overhead, in bytes, of sealing a |
| 5050 |
// record with |ssl|. |
| 5051 |
OPENSSL_EXPORT size_t SSL_max_seal_overhead(const SSL *ssl); |
| 5052 |
|
| 5053 |
// SSL_CTX_set_false_start_allowed_without_alpn configures whether connections |
| 5054 |
// on |ctx| may use False Start (if |SSL_MODE_ENABLE_FALSE_START| is enabled) |
| 5055 |
// without negotiating ALPN. |
| 5056 |
OPENSSL_EXPORT void SSL_CTX_set_false_start_allowed_without_alpn(SSL_CTX *ctx, |
| 5057 |
int allowed); |
| 5058 |
|
| 5059 |
// SSL_used_hello_retry_request returns one if the TLS 1.3 HelloRetryRequest |
| 5060 |
// message has been either sent by the server or received by the client. It |
| 5061 |
// returns zero otherwise. |
| 5062 |
OPENSSL_EXPORT int SSL_used_hello_retry_request(const SSL *ssl); |
| 5063 |
|
| 5064 |
// SSL_set_jdk11_workaround configures whether to workaround various bugs in |
| 5065 |
// JDK 11's TLS 1.3 implementation by disabling TLS 1.3 for such clients. |
| 5066 |
// |
| 5067 |
// https://bugs.openjdk.java.net/browse/JDK-8211806 |
| 5068 |
// https://bugs.openjdk.java.net/browse/JDK-8212885 |
| 5069 |
// https://bugs.openjdk.java.net/browse/JDK-8213202 |
| 5070 |
OPENSSL_EXPORT void SSL_set_jdk11_workaround(SSL *ssl, int enable); |
| 5071 |
|
| 5072 |
// SSL_set_check_client_certificate_type configures whether the client, in |
| 5073 |
// TLS 1.2 and below, will check its certificate against the server's requested |
| 5074 |
// certificate types. |
| 5075 |
// |
| 5076 |
// By default, this option is enabled. If disabled, certificate selection within |
| 5077 |
// the library may not function correctly. This flag is provided temporarily in |
| 5078 |
// case of compatibility issues. It will be removed sometime after June 2024. |
| 5079 |
OPENSSL_EXPORT void SSL_set_check_client_certificate_type(SSL *ssl, int enable); |
| 5080 |
|
| 5081 |
|
| 5082 |
// SSL Stat Counters. |
| 5083 |
|
| 5084 |
// SSL_CTX_sess_connect returns the number of started SSL/TLS handshakes in |
| 5085 |
// client mode. |
| 5086 |
OPENSSL_EXPORT int SSL_CTX_sess_connect(const SSL_CTX *ctx); |
| 5087 |
|
| 5088 |
// SSL_CTX_sess_connect_good returns the number of successfully established |
| 5089 |
// SSL/TLS sessions in client mode. |
| 5090 |
OPENSSL_EXPORT int SSL_CTX_sess_connect_good(const SSL_CTX *ctx); |
| 5091 |
|
| 5092 |
// SSL_CTX_sess_connect_renegotiate returns the number of started renegotiations |
| 5093 |
// in client mode. |
| 5094 |
OPENSSL_EXPORT int SSL_CTX_sess_connect_renegotiate(const SSL_CTX *ctx); |
| 5095 |
|
| 5096 |
// SSL_CTX_sess_accept returns the number of started SSL/TLS handshakes in |
| 5097 |
// server mode. |
| 5098 |
OPENSSL_EXPORT int SSL_CTX_sess_accept(const SSL_CTX *ctx); |
| 5099 |
|
| 5100 |
// SSL_CTX_sess_accept_renegotiate returns zero. AWS-LC does not support server |
| 5101 |
// side renegotiations. |
| 5102 |
OPENSSL_EXPORT int SSL_CTX_sess_accept_renegotiate(const SSL_CTX *ctx); |
| 5103 |
|
| 5104 |
// SSL_CTX_sess_accept_good returns the number of successfully established |
| 5105 |
// SSL/TLS sessions in server mode. |
| 5106 |
OPENSSL_EXPORT int SSL_CTX_sess_accept_good(const SSL_CTX *ctx); |
| 5107 |
|
| 5108 |
// SSL_CTX_sess_hits returns the number of successfully reused sessions, from |
| 5109 |
// both session cache and session tickets. |
| 5110 |
OPENSSL_EXPORT int SSL_CTX_sess_hits(const SSL_CTX *ctx); |
| 5111 |
|
| 5112 |
// SSL_CTX_sess_cb_hits returns the number of successfully retrieved sessions |
| 5113 |
// from the external session cache in server mode. |
| 5114 |
OPENSSL_EXPORT int SSL_CTX_sess_cb_hits(const SSL_CTX *ctx); |
| 5115 |
|
| 5116 |
// SSL_CTX_sess_misses returns the number of sessions proposed by clients that |
| 5117 |
// were not found in the internal session cache in server mode. |
| 5118 |
OPENSSL_EXPORT int SSL_CTX_sess_misses(const SSL_CTX *ctx); |
| 5119 |
|
| 5120 |
// SSL_CTX_sess_timeouts returns the number of sessions proposed by clients and |
| 5121 |
// either found in the internal or external session cache in server mode, but |
| 5122 |
// that were invalid due to timeout. |
| 5123 |
OPENSSL_EXPORT int SSL_CTX_sess_timeouts(const SSL_CTX *ctx); |
| 5124 |
|
| 5125 |
// SSL_CTX_sess_cache_full returns the number of sessions that were removed |
| 5126 |
// because the maximum session cache size was exceeded. |
| 5127 |
OPENSSL_EXPORT int SSL_CTX_sess_cache_full(const SSL_CTX *ctx); |
| 5128 |
|
| 5129 |
|
| 5130 |
// SSL BIO methods |
| 5131 |
|
| 5132 |
// BIO_f_ssl returns a |BIO_METHOD| that can wrap an |SSL*| in a |BIO*|. Note |
| 5133 |
// that this has quite different behaviour from the version in OpenSSL (notably |
| 5134 |
// that it doesn't try to auto renegotiate). There is also no current support |
| 5135 |
// for the |BIO_set_ssl*| related functions in OpenSSL or |BIO_puts| with this |
| 5136 |
// BIO type within AWS-LC. |
| 5137 |
OPENSSL_EXPORT const BIO_METHOD *BIO_f_ssl(void); |
| 5138 |
|
| 5139 |
// BIO_set_ssl sets |ssl| as the underlying connection for |bio|, which must |
| 5140 |
// have been created using |BIO_f_ssl|. If |take_owership| is true, |bio| will |
| 5141 |
// call |SSL_free| on |ssl| when closed. It returns one on success or something |
| 5142 |
// other than one on error. |
| 5143 |
OPENSSL_EXPORT long BIO_set_ssl(BIO *bio, SSL *ssl, int take_owership); |
| 5144 |
|
| 5145 |
// BIO_get_ssl assigns the internal |SSL| of |bio| to |*ssl|. |*ssl| should |
| 5146 |
// not be freed. It returns one on success or something other than one on error. |
| 5147 |
OPENSSL_EXPORT long BIO_get_ssl(BIO *bio, SSL **ssl); |
| 5148 |
|
| 5149 |
// BIO_new_ssl_connect requires socket support for the underlying connect BIO. |
| 5150 |
// It is unavailable on platforms that define OPENSSL_NO_SOCK. |
| 5151 |
#if !defined(OPENSSL_NO_SOCK) |
| 5152 |
// BIO_new_ssl_connect uses |ctx| to return a newly allocated BIO chain with |
| 5153 |
// |BIO_new_ssl|, followed by a connect BIO. |
| 5154 |
// |
| 5155 |
// Note: This allocates a |BIO| with |BIO_f_ssl| to the user, so the same |
| 5156 |
// caveats hold true for this function as well. See |BIO_f_ssl| for more |
| 5157 |
// details. |
| 5158 |
OPENSSL_EXPORT BIO *BIO_new_ssl_connect(SSL_CTX *ctx); |
| 5159 |
#endif // !OPENSSL_NO_SOCK |
| 5160 |
|
| 5161 |
// BIO_new_ssl returns a newly allocated SSL BIO created with |ctx|. A client |
| 5162 |
// SSL is created if |client| is non-zero, and a server is created if otherwise. |
| 5163 |
// |
| 5164 |
// Note: This allocates a |BIO| with |BIO_f_ssl| to the user, so the same |
| 5165 |
// caveats hold true for this function as well. See |BIO_f_ssl| for more |
| 5166 |
// details. |
| 5167 |
OPENSSL_EXPORT BIO *BIO_new_ssl(SSL_CTX *ctx, int client); |
| 5168 |
|
| 5169 |
|
| 5170 |
// Deprecated functions. |
| 5171 |
|
| 5172 |
// SSL_library_init calls |CRYPTO_library_init| and returns one. |
| 5173 |
OPENSSL_EXPORT int SSL_library_init(void); |
| 5174 |
|
| 5175 |
// SSL_CIPHER_description writes a description of |cipher| into |buf| and |
| 5176 |
// returns |buf|. If |buf| is NULL, it returns a newly allocated string, to be |
| 5177 |
// freed with |OPENSSL_free|, or NULL on error. |
| 5178 |
// |
| 5179 |
// The description includes a trailing newline and has the form: |
| 5180 |
// AES128-SHA Kx=RSA Au=RSA Enc=AES(128) Mac=SHA1 |
| 5181 |
// |
| 5182 |
// Consider |SSL_CIPHER_standard_name| or |SSL_CIPHER_get_name| instead. |
| 5183 |
OPENSSL_EXPORT const char *SSL_CIPHER_description(const SSL_CIPHER *cipher, |
| 5184 |
char *buf, int len); |
| 5185 |
|
| 5186 |
// SSL_CIPHER_get_version returns the string "TLSv1/SSLv3". |
| 5187 |
OPENSSL_EXPORT const char *SSL_CIPHER_get_version(const SSL_CIPHER *cipher); |
| 5188 |
|
| 5189 |
// SSLv23_method calls |TLS_method|. |
| 5190 |
OPENSSL_EXPORT const SSL_METHOD *SSLv23_method(void); |
| 5191 |
|
| 5192 |
// These version-specific methods behave exactly like |TLS_method| and |
| 5193 |
// |DTLS_method| except they also call |SSL_CTX_set_min_proto_version| and |
| 5194 |
// |SSL_CTX_set_max_proto_version| to lock connections to that protocol |
| 5195 |
// version. |
| 5196 |
OPENSSL_EXPORT const SSL_METHOD *TLSv1_method(void); |
| 5197 |
OPENSSL_EXPORT const SSL_METHOD *TLSv1_1_method(void); |
| 5198 |
OPENSSL_EXPORT const SSL_METHOD *TLSv1_2_method(void); |
| 5199 |
OPENSSL_EXPORT const SSL_METHOD *DTLSv1_method(void); |
| 5200 |
OPENSSL_EXPORT const SSL_METHOD *DTLSv1_2_method(void); |
| 5201 |
|
| 5202 |
// These client- and server-specific methods call their corresponding generic |
| 5203 |
// methods. |
| 5204 |
OPENSSL_EXPORT const SSL_METHOD *TLS_server_method(void); |
| 5205 |
OPENSSL_EXPORT const SSL_METHOD *TLS_client_method(void); |
| 5206 |
OPENSSL_EXPORT const SSL_METHOD *SSLv23_server_method(void); |
| 5207 |
OPENSSL_EXPORT const SSL_METHOD *SSLv23_client_method(void); |
| 5208 |
OPENSSL_EXPORT const SSL_METHOD *TLSv1_server_method(void); |
| 5209 |
OPENSSL_EXPORT const SSL_METHOD *TLSv1_client_method(void); |
| 5210 |
OPENSSL_EXPORT const SSL_METHOD *TLSv1_1_server_method(void); |
| 5211 |
OPENSSL_EXPORT const SSL_METHOD *TLSv1_1_client_method(void); |
| 5212 |
OPENSSL_EXPORT const SSL_METHOD *TLSv1_2_server_method(void); |
| 5213 |
OPENSSL_EXPORT const SSL_METHOD *TLSv1_2_client_method(void); |
| 5214 |
OPENSSL_EXPORT const SSL_METHOD *DTLS_server_method(void); |
| 5215 |
OPENSSL_EXPORT const SSL_METHOD *DTLS_client_method(void); |
| 5216 |
OPENSSL_EXPORT const SSL_METHOD *DTLSv1_server_method(void); |
| 5217 |
OPENSSL_EXPORT const SSL_METHOD *DTLSv1_client_method(void); |
| 5218 |
OPENSSL_EXPORT const SSL_METHOD *DTLSv1_2_server_method(void); |
| 5219 |
OPENSSL_EXPORT const SSL_METHOD *DTLSv1_2_client_method(void); |
| 5220 |
|
| 5221 |
// SSL_clear resets |ssl| to allow another connection and returns one on success |
| 5222 |
// or zero on failure. It returns most configuration state but releases memory |
| 5223 |
// associated with the current connection. |
| 5224 |
// |
| 5225 |
// Free |ssl| and create a new one instead. |
| 5226 |
OPENSSL_EXPORT int SSL_clear(SSL *ssl); |
| 5227 |
|
| 5228 |
// SSL_cutthrough_complete calls |SSL_in_false_start|. |
| 5229 |
OPENSSL_EXPORT int SSL_cutthrough_complete(const SSL *ssl); |
| 5230 |
|
| 5231 |
// SSL_num_renegotiations calls |SSL_total_renegotiations|. |
| 5232 |
OPENSSL_EXPORT int SSL_num_renegotiations(const SSL *ssl); |
| 5233 |
|
| 5234 |
// SSL_clear_num_renegotiations calls |SSL_total_renegotiations| and resets the |
| 5235 |
// total number of renegotiation handshakes performed by |ssl| to 0. |
| 5236 |
OPENSSL_EXPORT int SSL_clear_num_renegotiations(const SSL *ssl); |
| 5237 |
|
| 5238 |
// SSL_CTX_get_read_ahead returns 1 if |ctx| is not null and read ahead is |
| 5239 |
// enabled, otherwise it returns 0. |
| 5240 |
OPENSSL_EXPORT int SSL_CTX_get_read_ahead(const SSL_CTX *ctx); |
| 5241 |
|
| 5242 |
// SSL_CTX_set_read_ahead enables or disables read ahead on |ctx|: |
| 5243 |
// if |yes| is 1 it enables read ahead and returns 1, |
| 5244 |
// if |yes| is 0 it disables read ahead and returns 1, |
| 5245 |
// if |yes| is any other value nothing is changed and 0 is returned. |
| 5246 |
// |
| 5247 |
// When read ahead is enabled all future reads will be up to the buffer size configured |
| 5248 |
// with |SSL_CTX_set_default_read_buffer_len|, the default buffer size is |
| 5249 |
// |SSL3_RT_MAX_PLAIN_LENGTH| + |SSL3_RT_MAX_ENCRYPTED_OVERHEAD| = 16704 bytes. |
| 5250 |
// |
| 5251 |
// Read ahead should only be enabled on non-blocking IO sources configured with |SSL_set_bio|. |
| 5252 |
// When read ahead is enabled AWS-LC will make reads for potentially more data than is |
| 5253 |
// avaliable in the BIO with the assumption a partial read will be returned. If |
| 5254 |
// a blocking BIO is used and never returns the read could get stuck forever. |
| 5255 |
OPENSSL_EXPORT int SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes); |
| 5256 |
|
| 5257 |
// SSL_get_read_ahead returns 1 if |ssl| is not null and read ahead is enabled |
| 5258 |
// otherwise it returns 0. |
| 5259 |
OPENSSL_EXPORT int SSL_get_read_ahead(const SSL *ssl); |
| 5260 |
|
| 5261 |
// SSL_set_read_ahead enables or disables read ahead on |ssl|: |
| 5262 |
// if |yes| is 1 it enables read ahead and returns 1, |
| 5263 |
// if |yes| is 0 it disables read ahead and returns 1, |
| 5264 |
// if |yes| is any other value nothing is changed and 0 is returned. |
| 5265 |
// |
| 5266 |
// When read ahead is enabled all future reads will be for up to the buffer size configured |
| 5267 |
// with |SSL_CTX_set_default_read_buffer_len|. The default buffer size is |
| 5268 |
// |SSL3_RT_MAX_PLAIN_LENGTH| + |SSL3_RT_MAX_ENCRYPTED_OVERHEAD| = 16704 bytes |
| 5269 |
// |
| 5270 |
// Read ahead should only be enabled on non-blocking IO sources configured with |SSL_set_bio|, |
| 5271 |
// when read ahead is enabled AWS-LC will make reads for potentially more data than is |
| 5272 |
// available in the BIO. |
| 5273 |
OPENSSL_EXPORT int SSL_set_read_ahead(SSL *ssl, int yes); |
| 5274 |
|
| 5275 |
// SSL_CTX_set_default_read_buffer_len sets the size of the buffer reads will use on |
| 5276 |
// |ctx| if read ahead has been enabled. 0 is the minimum and 65535 is the maximum. |
| 5277 |
// A |len| of 0 is the same behavior as read ahead turned off: each call to |
| 5278 |
// |SSL_read| reads the amount specified in the TLS Record Header. |
| 5279 |
OPENSSL_EXPORT int SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len); |
| 5280 |
|
| 5281 |
// SSL_set_default_read_buffer_len sets the size of the buffer reads will use on |
| 5282 |
// |ssl| if read ahead has been enabled. 0 is the minimum and 65535 is the maximum. |
| 5283 |
// A |len| of 0 is the same behavior as read ahead turned off: each call to |
| 5284 |
// |SSL_read| reads the amount specified in the TLS Record Header. |
| 5285 |
OPENSSL_EXPORT int SSL_set_default_read_buffer_len(SSL *ssl, size_t len); |
| 5286 |
|
| 5287 |
// SSL_MODE_HANDSHAKE_CUTTHROUGH is the same as SSL_MODE_ENABLE_FALSE_START. |
| 5288 |
#define SSL_MODE_HANDSHAKE_CUTTHROUGH SSL_MODE_ENABLE_FALSE_START |
| 5289 |
|
| 5290 |
// i2d_SSL_SESSION serializes |in|, as described in |i2d_SAMPLE|. |
| 5291 |
// |
| 5292 |
// Use |SSL_SESSION_to_bytes| instead. |
| 5293 |
OPENSSL_EXPORT int i2d_SSL_SESSION(SSL_SESSION *in, uint8_t **pp); |
| 5294 |
|
| 5295 |
// d2i_SSL_SESSION parses a serialized session from the |length| bytes pointed |
| 5296 |
// to by |*pp|, as described in |d2i_SAMPLE|. |
| 5297 |
// |
| 5298 |
// Use |SSL_SESSION_from_bytes| instead. |
| 5299 |
OPENSSL_EXPORT SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const uint8_t **pp, |
| 5300 |
long length); |
| 5301 |
|
| 5302 |
// i2d_SSL_SESSION_bio serializes |session| and writes the result to |bio|. It |
| 5303 |
// returns the number of bytes written on success and <= 0 on error. |
| 5304 |
OPENSSL_EXPORT int i2d_SSL_SESSION_bio(BIO *bio, const SSL_SESSION *session); |
| 5305 |
|
| 5306 |
// d2i_SSL_SESSION_bio reads a serialized |SSL_SESSION| from |bio| and returns a |
| 5307 |
// newly-allocated |SSL_SESSION| or NULL on error. If |out| is not NULL, it also |
| 5308 |
// frees |*out| and sets |*out| to the new |SSL_SESSION|. |
| 5309 |
OPENSSL_EXPORT SSL_SESSION *d2i_SSL_SESSION_bio(BIO *bio, SSL_SESSION **out); |
| 5310 |
|
| 5311 |
// SSL_CTX_set_tlsext_use_srtp calls |SSL_CTX_set_srtp_profiles|. It returns |
| 5312 |
// zero on success and one on failure. |
| 5313 |
// |
| 5314 |
// WARNING: this function is dangerous because it breaks the usual return value |
| 5315 |
// convention. Use |SSL_CTX_set_srtp_profiles| instead. |
| 5316 |
OPENSSL_EXPORT int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, |
| 5317 |
const char *profiles); |
| 5318 |
|
| 5319 |
// SSL_set_tlsext_use_srtp calls |SSL_set_srtp_profiles|. It returns zero on |
| 5320 |
// success and one on failure. |
| 5321 |
// |
| 5322 |
// WARNING: this function is dangerous because it breaks the usual return value |
| 5323 |
// convention. Use |SSL_set_srtp_profiles| instead. |
| 5324 |
OPENSSL_EXPORT int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles); |
| 5325 |
|
| 5326 |
// SSL_CTX_set1_sigalgs takes |num_values| ints and interprets them as pairs |
| 5327 |
// where the first is the nid of a hash function and the second is an |
| 5328 |
// |EVP_PKEY_*| value. It configures the signature algorithm preferences for |
| 5329 |
// |ctx| based on them and returns one on success or zero on error. |
| 5330 |
// |
| 5331 |
// This API is compatible with OpenSSL. However, BoringSSL-specific code should |
| 5332 |
// prefer |SSL_CTX_set_signing_algorithm_prefs| because it's clearer and it's |
| 5333 |
// more convenient to codesearch for specific algorithm values. |
| 5334 |
OPENSSL_EXPORT int SSL_CTX_set1_sigalgs(SSL_CTX *ctx, const int *values, |
| 5335 |
size_t num_values); |
| 5336 |
|
| 5337 |
// SSL_set1_sigalgs takes |num_values| ints and interprets them as pairs where |
| 5338 |
// the first is the nid of a hash function and the second is an |EVP_PKEY_*| |
| 5339 |
// value. It configures the signature algorithm preferences for |ssl| based on |
| 5340 |
// them and returns one on success or zero on error. |
| 5341 |
// |
| 5342 |
// This API is compatible with OpenSSL. However, BoringSSL-specific code should |
| 5343 |
// prefer |SSL_CTX_set_signing_algorithm_prefs| because it's clearer and it's |
| 5344 |
// more convenient to codesearch for specific algorithm values. |
| 5345 |
OPENSSL_EXPORT int SSL_set1_sigalgs(SSL *ssl, const int *values, |
| 5346 |
size_t num_values); |
| 5347 |
|
| 5348 |
// SSL_CTX_set1_sigalgs_list takes a textual specification of a set of signature |
| 5349 |
// algorithms and configures them on |ctx|. It returns one on success and zero |
| 5350 |
// on error. See |
| 5351 |
// https://www.openssl.org/docs/man1.1.0/man3/SSL_CTX_set1_sigalgs_list.html for |
| 5352 |
// a description of the text format. Also note that TLS 1.3 names (e.g. |
| 5353 |
// "rsa_pkcs1_md5_sha1") can also be used (as in OpenSSL, although OpenSSL |
| 5354 |
// doesn't document that). |
| 5355 |
// |
| 5356 |
// This API is compatible with OpenSSL. However, BoringSSL-specific code should |
| 5357 |
// prefer |SSL_CTX_set_signing_algorithm_prefs| because it's clearer and it's |
| 5358 |
// more convenient to codesearch for specific algorithm values. |
| 5359 |
OPENSSL_EXPORT int SSL_CTX_set1_sigalgs_list(SSL_CTX *ctx, const char *str); |
| 5360 |
|
| 5361 |
// SSL_set1_sigalgs_list takes a textual specification of a set of signature |
| 5362 |
// algorithms and configures them on |ssl|. It returns one on success and zero |
| 5363 |
// on error. See |
| 5364 |
// https://www.openssl.org/docs/man1.1.0/man3/SSL_CTX_set1_sigalgs_list.html for |
| 5365 |
// a description of the text format. Also note that TLS 1.3 names (e.g. |
| 5366 |
// "rsa_pkcs1_md5_sha1") can also be used (as in OpenSSL, although OpenSSL |
| 5367 |
// doesn't document that). |
| 5368 |
// |
| 5369 |
// This API is compatible with OpenSSL. However, BoringSSL-specific code should |
| 5370 |
// prefer |SSL_CTX_set_signing_algorithm_prefs| because it's clearer and it's |
| 5371 |
// more convenient to codesearch for specific algorithm values. |
| 5372 |
OPENSSL_EXPORT int SSL_set1_sigalgs_list(SSL *ssl, const char *str); |
| 5373 |
|
| 5374 |
// SSL_SESSION_print prints the contents of |sess| to |bp|. |
| 5375 |
OPENSSL_EXPORT int SSL_SESSION_print(BIO *bp, const SSL_SESSION *sess); |
| 5376 |
|
| 5377 |
#define SSL_set_app_data(s, arg) (SSL_set_ex_data(s, 0, (char *)(arg))) |
| 5378 |
#define SSL_get_app_data(s) (SSL_get_ex_data(s, 0)) |
| 5379 |
#define SSL_SESSION_set_app_data(s, a) \ |
| 5380 |
(SSL_SESSION_set_ex_data(s, 0, (char *)(a))) |
| 5381 |
#define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s, 0)) |
| 5382 |
#define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx, 0)) |
| 5383 |
#define SSL_CTX_set_app_data(ctx, arg) \ |
| 5384 |
(SSL_CTX_set_ex_data(ctx, 0, (char *)(arg))) |
| 5385 |
|
| 5386 |
#define OpenSSL_add_ssl_algorithms() SSL_library_init() |
| 5387 |
#define SSLeay_add_ssl_algorithms() SSL_library_init() |
| 5388 |
|
| 5389 |
#define SSL_get_cipher(ssl) SSL_CIPHER_get_name(SSL_get_current_cipher(ssl)) |
| 5390 |
#define SSL_get_cipher_bits(ssl, out_alg_bits) \ |
| 5391 |
SSL_CIPHER_get_bits(SSL_get_current_cipher(ssl), out_alg_bits) |
| 5392 |
#define SSL_get_cipher_version(ssl) \ |
| 5393 |
SSL_CIPHER_get_version(SSL_get_current_cipher(ssl)) |
| 5394 |
#define SSL_get_cipher_name(ssl) \ |
| 5395 |
SSL_CIPHER_get_name(SSL_get_current_cipher(ssl)) |
| 5396 |
#define SSL_get_time(session) SSL_SESSION_get_time(session) |
| 5397 |
#define SSL_set_time(session, time) SSL_SESSION_set_time((session), (time)) |
| 5398 |
#define SSL_get_timeout(session) SSL_SESSION_get_timeout(session) |
| 5399 |
#define SSL_set_timeout(session, timeout) \ |
| 5400 |
SSL_SESSION_set_timeout((session), (timeout)) |
| 5401 |
|
| 5402 |
// SSL_cache_hit calls |SSL_session_reused|. |
| 5403 |
OPENSSL_EXPORT int SSL_cache_hit(SSL *ssl); |
| 5404 |
|
| 5405 |
// SSL_get_default_timeout returns |SSL_DEFAULT_SESSION_TIMEOUT|. |
| 5406 |
OPENSSL_EXPORT long SSL_get_default_timeout(const SSL *ssl); |
| 5407 |
|
| 5408 |
// SSL_get_version returns a string describing the TLS version used by |ssl|. |
| 5409 |
// For example, "TLSv1.2" or "DTLSv1". |
| 5410 |
OPENSSL_EXPORT const char *SSL_get_version(const SSL *ssl); |
| 5411 |
|
| 5412 |
// SSL_get_all_version_names outputs a list of possible strings |
| 5413 |
// |SSL_get_version| may return in this version of BoringSSL. It writes at most |
| 5414 |
// |max_out| entries to |out| and returns the total number it would have |
| 5415 |
// written, if |max_out| had been large enough. |max_out| may be initially set |
| 5416 |
// to zero to size the output. |
| 5417 |
// |
| 5418 |
// This function is only intended to help initialize tables in callers that want |
| 5419 |
// possible strings pre-declared. This list would not be suitable to set a list |
| 5420 |
// of supported features. It is in no particular order, and may contain |
| 5421 |
// placeholder, experimental, or deprecated values that do not apply to every |
| 5422 |
// caller. Future versions of BoringSSL may also return strings not in this |
| 5423 |
// list, so this does not apply if, say, sending strings across services. |
| 5424 |
OPENSSL_EXPORT size_t SSL_get_all_version_names(const char **out, |
| 5425 |
size_t max_out); |
| 5426 |
|
| 5427 |
// SSL_get_cipher_list returns the name of the |n|th cipher in the output of |
| 5428 |
// |SSL_get_ciphers| or NULL if out of range. Use |SSL_get_ciphers| instead. |
| 5429 |
OPENSSL_EXPORT const char *SSL_get_cipher_list(const SSL *ssl, int n); |
| 5430 |
|
| 5431 |
// SSL_CTX_set_client_cert_cb sets a callback which is called on the client if |
| 5432 |
// the server requests a client certificate and none is configured. On success, |
| 5433 |
// the callback should return one and set |*out_x509| to |*out_pkey| to a leaf |
| 5434 |
// certificate and private key, respectively, passing ownership. It should |
| 5435 |
// return zero to send no certificate and -1 to fail or pause the handshake. If |
| 5436 |
// the handshake is paused, |SSL_get_error| will return |
| 5437 |
// |SSL_ERROR_WANT_X509_LOOKUP|. |
| 5438 |
// |
| 5439 |
// The callback may call |SSL_get0_certificate_types| and |
| 5440 |
// |SSL_get_client_CA_list| for information on the server's certificate request. |
| 5441 |
// |
| 5442 |
// Use |SSL_CTX_set_cert_cb| instead. Configuring intermediate certificates with |
| 5443 |
// this function is confusing. This callback may not be registered concurrently |
| 5444 |
// with |SSL_CTX_set_cert_cb| or |SSL_set_cert_cb|. |
| 5445 |
OPENSSL_EXPORT void SSL_CTX_set_client_cert_cb( |
| 5446 |
SSL_CTX *ctx, int (*cb)(SSL *ssl, X509 **out_x509, EVP_PKEY **out_pkey)); |
| 5447 |
|
| 5448 |
#define SSL_NOTHING SSL_ERROR_NONE |
| 5449 |
#define SSL_WRITING SSL_ERROR_WANT_WRITE |
| 5450 |
#define SSL_READING SSL_ERROR_WANT_READ |
| 5451 |
|
| 5452 |
// SSL_want returns one of the above values to determine what the most recent |
| 5453 |
// operation on |ssl| was blocked on. Use |SSL_get_error| instead. |
| 5454 |
OPENSSL_EXPORT int SSL_want(const SSL *ssl); |
| 5455 |
|
| 5456 |
#define SSL_want_read(ssl) (SSL_want(ssl) == SSL_READING) |
| 5457 |
#define SSL_want_write(ssl) (SSL_want(ssl) == SSL_WRITING) |
| 5458 |
|
| 5459 |
// SSL_get_finished writes up to |count| bytes of the Finished message sent by |
| 5460 |
// |ssl| to |buf|. It returns the total untruncated length or zero if none has |
| 5461 |
// been sent yet. |
| 5462 |
// |
| 5463 |
// Use |SSL_get_tls_unique| instead. |
| 5464 |
OPENSSL_EXPORT size_t SSL_get_finished(const SSL *ssl, void *buf, size_t count); |
| 5465 |
|
| 5466 |
// SSL_get_peer_finished writes up to |count| bytes of the Finished message |
| 5467 |
// received from |ssl|'s peer to |buf|. It returns the total untruncated length |
| 5468 |
// or zero if none has been received yet. |
| 5469 |
// |
| 5470 |
// Use |SSL_get_tls_unique| instead. |
| 5471 |
OPENSSL_EXPORT size_t SSL_get_peer_finished(const SSL *ssl, void *buf, |
| 5472 |
size_t count); |
| 5473 |
|
| 5474 |
// SSL_alert_type_string returns an unintelligible 1 letter string description |
| 5475 |
// of |value| as an alert type (W or F). Use |SSL_alert_type_string_long| |
| 5476 |
// instead. |
| 5477 |
OPENSSL_EXPORT const char *SSL_alert_type_string(int value); |
| 5478 |
|
| 5479 |
// SSL_alert_desc_string returns an unintelligible 2 letter string description |
| 5480 |
// of |value|. Use |SSL_alert_desc_string_long| instead. |
| 5481 |
OPENSSL_EXPORT const char *SSL_alert_desc_string(int value); |
| 5482 |
|
| 5483 |
// SSL_state_string returns |SSL_state_string_long|. |
| 5484 |
OPENSSL_EXPORT const char *SSL_state_string(const SSL *ssl); |
| 5485 |
|
| 5486 |
// SSL_TXT_* expand to strings. |
| 5487 |
#define SSL_TXT_MEDIUM "MEDIUM" |
| 5488 |
#define SSL_TXT_HIGH "HIGH" |
| 5489 |
#define SSL_TXT_FIPS "FIPS" |
| 5490 |
#define SSL_TXT_kRSA "kRSA" |
| 5491 |
#define SSL_TXT_kDHE "kDHE" |
| 5492 |
#define SSL_TXT_kEDH "kEDH" |
| 5493 |
#define SSL_TXT_kECDHE "kECDHE" |
| 5494 |
#define SSL_TXT_kEECDH "kEECDH" |
| 5495 |
#define SSL_TXT_kPSK "kPSK" |
| 5496 |
#define SSL_TXT_aRSA "aRSA" |
| 5497 |
#define SSL_TXT_aECDSA "aECDSA" |
| 5498 |
#define SSL_TXT_aPSK "aPSK" |
| 5499 |
#define SSL_TXT_DH "DH" |
| 5500 |
#define SSL_TXT_DHE "DHE" |
| 5501 |
#define SSL_TXT_EDH "EDH" |
| 5502 |
#define SSL_TXT_RSA "RSA" |
| 5503 |
#define SSL_TXT_ECDH "ECDH" |
| 5504 |
#define SSL_TXT_ECDHE "ECDHE" |
| 5505 |
#define SSL_TXT_EECDH "EECDH" |
| 5506 |
#define SSL_TXT_ECDSA "ECDSA" |
| 5507 |
#define SSL_TXT_PSK "PSK" |
| 5508 |
#define SSL_TXT_3DES "3DES" |
| 5509 |
#define SSL_TXT_RC4 "RC4" |
| 5510 |
#define SSL_TXT_AES128 "AES128" |
| 5511 |
#define SSL_TXT_AES256 "AES256" |
| 5512 |
#define SSL_TXT_AES "AES" |
| 5513 |
#define SSL_TXT_AES_GCM "AESGCM" |
| 5514 |
#define SSL_TXT_CHACHA20 "CHACHA20" |
| 5515 |
#define SSL_TXT_MD5 "MD5" |
| 5516 |
#define SSL_TXT_SHA1 "SHA1" |
| 5517 |
#define SSL_TXT_SHA "SHA" |
| 5518 |
#define SSL_TXT_SHA256 "SHA256" |
| 5519 |
#define SSL_TXT_SHA384 "SHA384" |
| 5520 |
#define SSL_TXT_SSLV3 "SSLv3" |
| 5521 |
#define SSL_TXT_TLSV1 "TLSv1" |
| 5522 |
#define SSL_TXT_TLSV1_1 "TLSv1.1" |
| 5523 |
#define SSL_TXT_TLSV1_2 "TLSv1.2" |
| 5524 |
#define SSL_TXT_TLSV1_3 "TLSv1.3" |
| 5525 |
#define SSL_TXT_ALL "ALL" |
| 5526 |
#define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT" |
| 5527 |
|
| 5528 |
typedef struct ssl_conf_ctx_st SSL_CONF_CTX; |
| 5529 |
|
| 5530 |
// SSL_state returns |SSL_ST_INIT| if a handshake is in progress and |SSL_ST_OK| |
| 5531 |
// otherwise. |
| 5532 |
// |
| 5533 |
// Use |SSL_is_init| instead. |
| 5534 |
OPENSSL_EXPORT int SSL_state(const SSL *ssl); |
| 5535 |
|
| 5536 |
#define SSL_get_state(ssl) SSL_state(ssl) |
| 5537 |
|
| 5538 |
// SSL_set_shutdown causes |ssl| to behave as if the shutdown bitmask (see |
| 5539 |
// |SSL_get_shutdown|) were |mode|. This may be used to skip sending or |
| 5540 |
// receiving close_notify in |SSL_shutdown| by causing the implementation to |
| 5541 |
// believe the events already happened. |
| 5542 |
// |
| 5543 |
// Note: |SSL_set_shutdown| cannot be used to unset a bit that has already |
| 5544 |
// been set in AWS-LC. Doing so will be ignored. |
| 5545 |
// |
| 5546 |
// Use |SSL_CTX_set_quiet_shutdown| instead. |
| 5547 |
OPENSSL_EXPORT void SSL_set_shutdown(SSL *ssl, int mode); |
| 5548 |
|
| 5549 |
// SSL_CTX_set_tmp_ecdh calls |SSL_CTX_set1_groups| with a one-element list |
| 5550 |
// containing |ec_key|'s curve. The remainder of |ec_key| is ignored. |
| 5551 |
OPENSSL_EXPORT int SSL_CTX_set_tmp_ecdh(SSL_CTX *ctx, const EC_KEY *ec_key); |
| 5552 |
|
| 5553 |
// SSL_set_tmp_ecdh calls |SSL_set1_groups| with a one-element list containing |
| 5554 |
// |ec_key|'s curve. The remainder of |ec_key| is ignored. |
| 5555 |
OPENSSL_EXPORT int SSL_set_tmp_ecdh(SSL *ssl, const EC_KEY *ec_key); |
| 5556 |
|
| 5557 |
#if !defined(OPENSSL_NO_FILESYSTEM) |
| 5558 |
// SSL_add_dir_cert_subjects_to_stack lists files in directory |dir|. It calls |
| 5559 |
// |SSL_add_file_cert_subjects_to_stack| on each file and returns one on success |
| 5560 |
// or zero on error. This function is deprecated. |
| 5561 |
OPENSSL_EXPORT int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *out, |
| 5562 |
const char *dir); |
| 5563 |
#endif |
| 5564 |
|
| 5565 |
// SSL_CTX_enable_tls_channel_id calls |SSL_CTX_set_tls_channel_id_enabled|. |
| 5566 |
OPENSSL_EXPORT int SSL_CTX_enable_tls_channel_id(SSL_CTX *ctx); |
| 5567 |
|
| 5568 |
// SSL_enable_tls_channel_id calls |SSL_set_tls_channel_id_enabled|. |
| 5569 |
OPENSSL_EXPORT int SSL_enable_tls_channel_id(SSL *ssl); |
| 5570 |
|
| 5571 |
// SSL_get_session returns a non-owning pointer to |ssl|'s session. For |
| 5572 |
// historical reasons, which session it returns depends on |ssl|'s state. |
| 5573 |
// |
| 5574 |
// Prior to the start of the initial handshake, it returns the session the |
| 5575 |
// caller set with |SSL_set_session|. After the initial handshake has finished |
| 5576 |
// and if no additional handshakes are in progress, it returns the currently |
| 5577 |
// active session. Its behavior is undefined while a handshake is in progress. |
| 5578 |
// |
| 5579 |
// If trying to add new sessions to an external session cache, use |
| 5580 |
// |SSL_CTX_sess_set_new_cb| instead. In particular, using the callback is |
| 5581 |
// required as of TLS 1.3. For compatibility, this function will return an |
| 5582 |
// unresumable session which may be cached, but will never be resumed. |
| 5583 |
// |
| 5584 |
// If querying properties of the connection, use APIs on the |SSL| object. |
| 5585 |
OPENSSL_EXPORT SSL_SESSION *SSL_get_session(const SSL *ssl); |
| 5586 |
|
| 5587 |
// SSL_get0_session is an alias for |SSL_get_session|. |
| 5588 |
#define SSL_get0_session SSL_get_session |
| 5589 |
|
| 5590 |
// SSL_get1_session acts like |SSL_get_session| but returns a new reference to |
| 5591 |
// the session. |
| 5592 |
OPENSSL_EXPORT SSL_SESSION *SSL_get1_session(SSL *ssl); |
| 5593 |
|
| 5594 |
#define OPENSSL_INIT_NO_LOAD_SSL_STRINGS 0 |
| 5595 |
#define OPENSSL_INIT_LOAD_SSL_STRINGS 0 |
| 5596 |
#define OPENSSL_INIT_SSL_DEFAULT 0 |
| 5597 |
|
| 5598 |
// OPENSSL_init_ssl calls |CRYPTO_library_init| and returns one. |
| 5599 |
OPENSSL_EXPORT int OPENSSL_init_ssl(uint64_t opts, |
| 5600 |
const OPENSSL_INIT_SETTINGS *settings); |
| 5601 |
|
| 5602 |
// The following constants are legacy aliases for RSA-PSS with rsaEncryption |
| 5603 |
// keys. Use the new names instead. |
| 5604 |
#define SSL_SIGN_RSA_PSS_SHA256 SSL_SIGN_RSA_PSS_RSAE_SHA256 |
| 5605 |
#define SSL_SIGN_RSA_PSS_SHA384 SSL_SIGN_RSA_PSS_RSAE_SHA384 |
| 5606 |
#define SSL_SIGN_RSA_PSS_SHA512 SSL_SIGN_RSA_PSS_RSAE_SHA512 |
| 5607 |
|
| 5608 |
// SSL_set_tlsext_status_type configures a client to request OCSP stapling if |
| 5609 |
// |type| is |TLSEXT_STATUSTYPE_ocsp| and disables it otherwise. It returns one |
| 5610 |
// on success and zero if handshake configuration has already been shed. |
| 5611 |
// |
| 5612 |
// Use |SSL_enable_ocsp_stapling| instead. |
| 5613 |
OPENSSL_EXPORT int SSL_set_tlsext_status_type(SSL *ssl, int type); |
| 5614 |
|
| 5615 |
// SSL_get_tlsext_status_type returns |TLSEXT_STATUSTYPE_ocsp| if the client |
| 5616 |
// requested OCSP stapling and |TLSEXT_STATUSTYPE_nothing| otherwise. On the |
| 5617 |
// client, this reflects whether OCSP stapling was enabled via, e.g., |
| 5618 |
// |SSL_set_tlsext_status_type|. On the server, this is determined during the |
| 5619 |
// handshake. It may be queried in callbacks set by |SSL_CTX_set_cert_cb|. The |
| 5620 |
// result is undefined after the handshake completes. |
| 5621 |
OPENSSL_EXPORT int SSL_get_tlsext_status_type(const SSL *ssl); |
| 5622 |
|
| 5623 |
// SSL_set_tlsext_status_ocsp_resp sets the OCSP response. It returns one on |
| 5624 |
// success and zero on error. On success, |ssl| takes ownership of |resp|, which |
| 5625 |
// must have been allocated by |OPENSSL_malloc|. |
| 5626 |
// |
| 5627 |
// Use |SSL_set_ocsp_response| instead. |
| 5628 |
OPENSSL_EXPORT int SSL_set_tlsext_status_ocsp_resp(SSL *ssl, uint8_t *resp, |
| 5629 |
size_t resp_len); |
| 5630 |
|
| 5631 |
// SSL_get_tlsext_status_ocsp_resp sets |*out| to point to the OCSP response |
| 5632 |
// from the server. It returns the length of the response. If there was no |
| 5633 |
// response, it sets |*out| to NULL and returns zero. |
| 5634 |
// |
| 5635 |
// Use |SSL_get0_ocsp_response| instead. |
| 5636 |
// |
| 5637 |
// WARNING: the returned data is not guaranteed to be well formed. |
| 5638 |
OPENSSL_EXPORT size_t SSL_get_tlsext_status_ocsp_resp(const SSL *ssl, |
| 5639 |
const uint8_t **out); |
| 5640 |
|
| 5641 |
// SSL_CTX_set_tlsext_status_cb configures the legacy OpenSSL OCSP callback and |
| 5642 |
// returns one. Though the type signature is the same, this callback has |
| 5643 |
// different behavior for client and server connections: |
| 5644 |
// |
| 5645 |
// For clients, the callback is called after certificate verification. It should |
| 5646 |
// return one for success, zero for a bad OCSP response, and a negative number |
| 5647 |
// for internal error. Instead, handle this as part of certificate verification. |
| 5648 |
// (Historically, OpenSSL verified certificates just before parsing stapled OCSP |
| 5649 |
// responses, but BoringSSL fixes this ordering. All server credentials are |
| 5650 |
// available during verification.) |
| 5651 |
// |
| 5652 |
// Do not use this callback as a server. It is provided for compatibility |
| 5653 |
// purposes only. For servers, it is called to configure server credentials. It |
| 5654 |
// should return |SSL_TLSEXT_ERR_OK| on success, |SSL_TLSEXT_ERR_NOACK| to |
| 5655 |
// ignore OCSP requests, or |SSL_TLSEXT_ERR_ALERT_FATAL| on error. It is usually |
| 5656 |
// used to fetch OCSP responses on demand, which is not ideal. Instead, treat |
| 5657 |
// OCSP responses like other server credentials, such as certificates or SCT |
| 5658 |
// lists. Configure, store, and refresh them eagerly. This avoids downtime if |
| 5659 |
// the CA's OCSP responder is briefly offline. |
| 5660 |
OPENSSL_EXPORT int SSL_CTX_set_tlsext_status_cb(SSL_CTX *ctx, |
| 5661 |
int (*callback)(SSL *ssl, |
| 5662 |
void *arg)); |
| 5663 |
|
| 5664 |
// SSL_CTX_get_tlsext_status_cb returns the legacy OpenSSL OCSP callback if set. |
| 5665 |
OPENSSL_EXPORT int SSL_CTX_get_tlsext_status_cb(SSL_CTX *ctx, |
| 5666 |
int (**callback)(SSL *, |
| 5667 |
void *)); |
| 5668 |
|
| 5669 |
// SSL_CTX_set_tlsext_status_arg sets additional data for |
| 5670 |
// |SSL_CTX_set_tlsext_status_cb|'s callback and returns one. |
| 5671 |
OPENSSL_EXPORT int SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg); |
| 5672 |
|
| 5673 |
// The following symbols are compatibility aliases for reason codes used when |
| 5674 |
// receiving an alert from the peer. Use the other names instead, which fit the |
| 5675 |
// naming convention. |
| 5676 |
// |
| 5677 |
// TODO(davidben): Fix references to |SSL_R_TLSV1_CERTIFICATE_REQUIRED| and |
| 5678 |
// remove the compatibility value. The others come from OpenSSL. |
| 5679 |
#define SSL_R_TLSV1_UNSUPPORTED_EXTENSION \ |
| 5680 |
SSL_R_TLSV1_ALERT_UNSUPPORTED_EXTENSION |
| 5681 |
#define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE \ |
| 5682 |
SSL_R_TLSV1_ALERT_CERTIFICATE_UNOBTAINABLE |
| 5683 |
#define SSL_R_TLSV1_UNRECOGNIZED_NAME SSL_R_TLSV1_ALERT_UNRECOGNIZED_NAME |
| 5684 |
#define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE \ |
| 5685 |
SSL_R_TLSV1_ALERT_BAD_CERTIFICATE_STATUS_RESPONSE |
| 5686 |
#define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE \ |
| 5687 |
SSL_R_TLSV1_ALERT_BAD_CERTIFICATE_HASH_VALUE |
| 5688 |
#define SSL_R_TLSV1_CERTIFICATE_REQUIRED SSL_R_TLSV1_ALERT_CERTIFICATE_REQUIRED |
| 5689 |
|
| 5690 |
// The following symbols are compatibility aliases for |SSL_GROUP_*|. |
| 5691 |
#define SSL_CURVE_SECP224R1 SSL_GROUP_SECP224R1 |
| 5692 |
#define SSL_CURVE_SECP256R1 SSL_GROUP_SECP256R1 |
| 5693 |
#define SSL_CURVE_SECP384R1 SSL_GROUP_SECP384R1 |
| 5694 |
#define SSL_CURVE_SECP521R1 SSL_GROUP_SECP521R1 |
| 5695 |
#define SSL_CURVE_X25519 SSL_GROUP_X25519 |
| 5696 |
|
| 5697 |
// TLSEXT_nid_unknown is a constant used in OpenSSL for |
| 5698 |
// |SSL_get_negotiated_group| to return an unrecognized group. AWS-LC never |
| 5699 |
// returns this value, but we define this constant for compatibility. |
| 5700 |
#define TLSEXT_nid_unknown 0x1000000 |
| 5701 |
|
| 5702 |
// SSL_get_curve_id calls |SSL_get_group_id|. |
| 5703 |
OPENSSL_EXPORT uint16_t SSL_get_curve_id(const SSL *ssl); |
| 5704 |
|
| 5705 |
// SSL_get_curve_name calls |SSL_get_group_name|. |
| 5706 |
OPENSSL_EXPORT const char *SSL_get_curve_name(uint16_t curve_id); |
| 5707 |
|
| 5708 |
// SSL_get_all_curve_names calls |SSL_get_all_group_names|. |
| 5709 |
OPENSSL_EXPORT size_t SSL_get_all_curve_names(const char **out, size_t max_out); |
| 5710 |
|
| 5711 |
// SSL_CTX_set1_curves calls |SSL_CTX_set1_groups|. |
| 5712 |
OPENSSL_EXPORT int SSL_CTX_set1_curves(SSL_CTX *ctx, const int *curves, |
| 5713 |
size_t num_curves); |
| 5714 |
|
| 5715 |
// SSL_set1_curves calls |SSL_set1_groups|. |
| 5716 |
OPENSSL_EXPORT int SSL_set1_curves(SSL *ssl, const int *curves, |
| 5717 |
size_t num_curves); |
| 5718 |
|
| 5719 |
// SSL_CTX_set1_curves_list calls |SSL_CTX_set1_groups_list|. |
| 5720 |
OPENSSL_EXPORT int SSL_CTX_set1_curves_list(SSL_CTX *ctx, const char *curves); |
| 5721 |
|
| 5722 |
// SSL_set1_curves_list calls |SSL_set1_groups_list|. |
| 5723 |
OPENSSL_EXPORT int SSL_set1_curves_list(SSL *ssl, const char *curves); |
| 5724 |
|
| 5725 |
|
| 5726 |
// No-op Configuration Flags |
| 5727 |
// |
| 5728 |
// The following flags do nothing and are included only to make it easier to |
| 5729 |
// compile code with AWS-LC. Flags defined within this section are not |
| 5730 |
// configurable and the state of AWS-LC does not change when used. |
| 5731 |
|
| 5732 |
// SSL_MODE_AUTO_RETRY is ON by default in AWS-LC and OpenSSL. This will let |
| 5733 |
// the application automatically retry if the transport is blocking. |
| 5734 |
// Read/write operations will only return after the handshake and successful |
| 5735 |
// completion. |
| 5736 |
#define SSL_MODE_AUTO_RETRY 0 |
| 5737 |
|
| 5738 |
// SSL_MODE_RELEASE_BUFFERS is ON by default in AWS-LC. When a read/write |
| 5739 |
// buffer is no longer needed for a given SSL, the memory holding it is |
| 5740 |
// released. |
| 5741 |
#define SSL_MODE_RELEASE_BUFFERS 0 |
| 5742 |
|
| 5743 |
// SSL_MODE_SEND_CLIENTHELLO_TIME is OFF by default in AWS-LC. Turning this ON |
| 5744 |
// in OpenSSL sends the current time in the Random fields of the ClientHello |
| 5745 |
// records is sent. |
| 5746 |
#define SSL_MODE_SEND_CLIENTHELLO_TIME 0 |
| 5747 |
|
| 5748 |
// SSL_MODE_SEND_SERVERHELLO_TIME is ON by default in AWS-LC. The current time |
| 5749 |
// in the Random fields of the ServerHello records is sent. |
| 5750 |
#define SSL_MODE_SEND_SERVERHELLO_TIME 0 |
| 5751 |
|
| 5752 |
// SSL_OP_ALL is OFF by default in AWS-LC. Turning this ON in OpenSSL enables |
| 5753 |
// all the less harmless bug workarounds that OpenSSL has had historically. |
| 5754 |
// |
| 5755 |
// See https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_options.html |
| 5756 |
// for more details. |
| 5757 |
#define SSL_OP_ALL 0 |
| 5758 |
|
| 5759 |
// SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION is OFF by default in AWS-LC. |
| 5760 |
// Turning this ON in OpenSSL allows legacy insecure renegotiation for |
| 5761 |
// unpatched clients and servers and is intentionally not supported in AWS-LC. |
| 5762 |
#define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION 0 |
| 5763 |
|
| 5764 |
// SSL_OP_CRYPTOPRO_TLSEXT_BUG is OFF by default in AWS-LC. Turning this ON in |
| 5765 |
// OpenSSL lets the server add a server-hello extension from early version of |
| 5766 |
// the cryptopro draft, when the GOST ciphersuite is negotiated. Required for |
| 5767 |
// interoperability with CryptoPro CSP 3.x. |
| 5768 |
// |
| 5769 |
// Note: AWS-LC does not support GOST ciphersuites. |
| 5770 |
#define SSL_OP_CRYPTOPRO_TLSEXT_BUG 0 |
| 5771 |
|
| 5772 |
// SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS is ON by default in AWS-LC. This |
| 5773 |
// disables a countermeasure against a SSL 3.0/TLS 1.0 protocol vulnerability |
| 5774 |
// affecting CBC ciphers, which cannot be handled by some broken SSL |
| 5775 |
// implementations. |
| 5776 |
#define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0 |
| 5777 |
|
| 5778 |
// SSL_OP_LEGACY_SERVER_CONNECT is OFF by default in AWS-LC. Turning this ON in |
| 5779 |
// OpenSSL allows legacy insecure renegotiation between OpenSSL and unpatched |
| 5780 |
// servers "only" and is intentionally not supported in AWS-LC. |
| 5781 |
#define SSL_OP_LEGACY_SERVER_CONNECT 0 |
| 5782 |
|
| 5783 |
// SSL_OP_NO_COMPRESSION is ON by default in AWS-LC. AWS-LC intentionally does |
| 5784 |
// not support TLS record compressions. |
| 5785 |
#define SSL_OP_NO_COMPRESSION 0 |
| 5786 |
|
| 5787 |
// SSL_OP_NO_RENEGOTIATION is ON by default in AWS-LC. This disables all |
| 5788 |
// renegotiation in TLSv1.2 and earlier. |
| 5789 |
// To enable renegotiation, use |SSL_set_renegotiate_mode|. |
| 5790 |
#define SSL_OP_NO_RENEGOTIATION 0 // ssl_renegotiate_never is the default |
| 5791 |
|
| 5792 |
// SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is ON by default in AWS-LC. |
| 5793 |
// This always starts a new session when performing renegotiation as a server |
| 5794 |
// (i.e., session resumption requests are only accepted in the initial |
| 5795 |
// handshake). |
| 5796 |
// There is no support for renegototiation for a server in AWS-LC. |
| 5797 |
#define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0 |
| 5798 |
|
| 5799 |
// SSL_OP_NO_SSLv2 is ON by default in AWS-LC. There is no support for SSLv2 in |
| 5800 |
// AWS-LC |
| 5801 |
#define SSL_OP_NO_SSLv2 0 |
| 5802 |
|
| 5803 |
// SSL_OP_NO_SSLv3 is ON by default in AWS-LC. There is no support for SSLv3 in |
| 5804 |
// AWS-LC |
| 5805 |
#define SSL_OP_NO_SSLv3 0 |
| 5806 |
|
| 5807 |
// SSL_OP_SAFARI_ECDHE_ECDSA_BUG is OFF by default in AWS-LC. Turning this ON in |
| 5808 |
// OpenSSL lets the application not prefer ECDHE-ECDSA ciphers when the client |
| 5809 |
// appears to be Safari on OSX. |
| 5810 |
// |
| 5811 |
// Note: OS X 10.8..10.8.3 broke support for ECDHE-ECDSA ciphers. |
| 5812 |
#define SSL_OP_SAFARI_ECDHE_ECDSA_BUG 0 |
| 5813 |
|
| 5814 |
// SSL_OP_TLSEXT_PADDING is OFF by default in AWS-LC. Turning this ON in OpenSSL |
| 5815 |
// adds a padding extension to ensure the ClientHello size is never between 256 |
| 5816 |
// and 511 bytes in length. This is needed as a workaround for F5 terminators. |
| 5817 |
#define SSL_OP_TLSEXT_PADDING 0 |
| 5818 |
|
| 5819 |
// SSL_OP_TLS_ROLLBACK_BUG is OFF by default in AWS-LC. Turning this ON in |
| 5820 |
// OpenSSL disables version rollback attack detection and is intentionally not |
| 5821 |
// supported in AWS-LC. |
| 5822 |
#define SSL_OP_TLS_ROLLBACK_BUG 0 |
| 5823 |
|
| 5824 |
// SSL_VERIFY_CLIENT_ONCE is OFF by default in AWS-LC. Turning this ON in |
| 5825 |
// OpenSSL only requests a client certificate on the initial TLS handshake and |
| 5826 |
// is intentionally not supported in AWS-LC. |
| 5827 |
#define SSL_VERIFY_CLIENT_ONCE 0 |
| 5828 |
|
| 5829 |
// SSL_OP_TLSEXT_PADDING is OFF by default in AWS-LC. Turning this ON in |
| 5830 |
// OpenSSL adds a padding extension to ensure the ClientHello size is never |
| 5831 |
// between 256 and 511 bytes in length. This is needed as a workaround for some |
| 5832 |
// implementations. |
| 5833 |
#define SSL_OP_TLSEXT_PADDING 0 |
| 5834 |
|
| 5835 |
// SSL_OP_SAFARI_ECDHE_ECDSA_BUG is OFF by default in AWS-LC. Turning this ON in |
| 5836 |
// OpenSSL defers ECDHE-ECDSA ciphers when the client appears to be Safari on |
| 5837 |
// OSX. OSX 10.8 ~ 10.8.3 has broken support for ECDHE-ECDSA ciphers. |
| 5838 |
#define SSL_OP_SAFARI_ECDHE_ECDSA_BUG 0 |
| 5839 |
|
| 5840 |
// SSL_OP_CRYPTOPRO_TLSEXT_BUG is OFF by default in AWS-LC. Turning this ON in |
| 5841 |
// OpenSSL adds the server-hello extension from the early version of cryptopro |
| 5842 |
// draft when GOST ciphersuite is negotiated (which we don't support). |
| 5843 |
#define SSL_OP_CRYPTOPRO_TLSEXT_BUG 0 |
| 5844 |
|
| 5845 |
// The following have no effect in both AWS-LC and OpenSSL. |
| 5846 |
#define SSL_OP_EPHEMERAL_RSA 0 |
| 5847 |
#define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0 |
| 5848 |
#define SSL_OP_MICROSOFT_SESS_ID_BUG 0 |
| 5849 |
#define SSL_OP_MSIE_SSLV2_RSA_PADDING 0 |
| 5850 |
#define SSL_OP_NETSCAPE_CA_DN_BUG 0 |
| 5851 |
#define SSL_OP_NETSCAPE_CHALLENGE_BUG 0 |
| 5852 |
#define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0 |
| 5853 |
#define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0 |
| 5854 |
#define SSL_OP_PKCS1_CHECK_1 0 |
| 5855 |
#define SSL_OP_PKCS1_CHECK_2 0 |
| 5856 |
#define SSL_OP_SINGLE_DH_USE 0 |
| 5857 |
#define SSL_OP_SINGLE_ECDH_USE 0 |
| 5858 |
#define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0 |
| 5859 |
#define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0 |
| 5860 |
#define SSL_OP_TLS_BLOCK_PADDING_BUG 0 |
| 5861 |
#define SSL_OP_TLS_D5_BUG 0 |
| 5862 |
|
| 5863 |
|
| 5864 |
// |SSL_COMP| and |COMP_METHOD| No-ops [Deprecated]. |
| 5865 |
// |
| 5866 |
// Support for SSL compression has been completely removed and the following |
| 5867 |
// functions are only provided as no-ops for easier compatibility. |
| 5868 |
|
| 5869 |
typedef void COMP_METHOD; |
| 5870 |
typedef struct ssl_comp_st SSL_COMP; |
| 5871 |
|
| 5872 |
// SSL_COMP_get_compression_methods returns NULL. |
| 5873 |
OPENSSL_EXPORT OPENSSL_DEPRECATED STACK_OF(SSL_COMP) * |
| 5874 |
SSL_COMP_get_compression_methods(void); |
| 5875 |
|
| 5876 |
// SSL_COMP_add_compression_method returns one. |
| 5877 |
OPENSSL_EXPORT OPENSSL_DEPRECATED int SSL_COMP_add_compression_method( |
| 5878 |
int id, COMP_METHOD *cm); |
| 5879 |
|
| 5880 |
// SSL_COMP_get_name returns NULL. |
| 5881 |
OPENSSL_EXPORT OPENSSL_DEPRECATED const char *SSL_COMP_get_name( |
| 5882 |
const COMP_METHOD *comp); |
| 5883 |
|
| 5884 |
// SSL_COMP_get0_name returns the |name| member of |comp|. |
| 5885 |
OPENSSL_EXPORT OPENSSL_DEPRECATED const char *SSL_COMP_get0_name( |
| 5886 |
const SSL_COMP *comp); |
| 5887 |
|
| 5888 |
// SSL_COMP_get_id returns the |id| member of |comp|. |
| 5889 |
OPENSSL_EXPORT OPENSSL_DEPRECATED int SSL_COMP_get_id(const SSL_COMP *comp); |
| 5890 |
|
| 5891 |
// SSL_COMP_free_compression_methods does nothing. |
| 5892 |
OPENSSL_EXPORT OPENSSL_DEPRECATED void SSL_COMP_free_compression_methods(void); |
| 5893 |
|
| 5894 |
// SSL_get_current_compression returns NULL. |
| 5895 |
OPENSSL_EXPORT OPENSSL_DEPRECATED const COMP_METHOD * |
| 5896 |
SSL_get_current_compression(SSL *ssl); |
| 5897 |
|
| 5898 |
// SSL_get_current_expansion returns NULL. |
| 5899 |
OPENSSL_EXPORT OPENSSL_DEPRECATED const COMP_METHOD *SSL_get_current_expansion( |
| 5900 |
SSL *ssl); |
| 5901 |
|
| 5902 |
struct ssl_comp_st { |
| 5903 |
int id; |
| 5904 |
const char *name; |
| 5905 |
char *method; |
| 5906 |
}; |
| 5907 |
|
| 5908 |
DEFINE_STACK_OF(SSL_COMP) |
| 5909 |
|
| 5910 |
// PHA No-ops [Deprecated]. |
| 5911 |
|
| 5912 |
// SSL_verify_client_post_handshake is a no-op function for compatibility with |
| 5913 |
// OpenSSL. It always returns 0. |
| 5914 |
OPENSSL_EXPORT OPENSSL_DEPRECATED int SSL_verify_client_post_handshake(SSL *ssl); |
| 5915 |
|
| 5916 |
// FFDH Ciphersuite No-ops [Deprecated]. |
| 5917 |
// |
| 5918 |
// AWS-LC does not support the use of FFDH cipher suites in libssl. The |
| 5919 |
// following functions are only provided as no-ops for easier compatibility. |
| 5920 |
|
| 5921 |
// SSL_CTX_set_tmp_dh returns 1. |
| 5922 |
// |
| 5923 |
// TODO (CryptoAlg-2398): Add |OPENSSL_DEPRECATED|. nginx defines -Werror and |
| 5924 |
// depends on this. |
| 5925 |
OPENSSL_EXPORT int SSL_CTX_set_tmp_dh(SSL_CTX *ctx, const DH *dh); |
| 5926 |
|
| 5927 |
// SSL_set_tmp_dh returns 1. |
| 5928 |
OPENSSL_EXPORT OPENSSL_DEPRECATED int SSL_set_tmp_dh(SSL *ssl, const DH *dh); |
| 5929 |
|
| 5930 |
// SSL_CTX_set_tmp_dh_callback does nothing. |
| 5931 |
OPENSSL_EXPORT OPENSSL_DEPRECATED void SSL_CTX_set_tmp_dh_callback( |
| 5932 |
SSL_CTX *ctx, DH *(*cb)(SSL *ssl, int is_export, int keylength)); |
| 5933 |
|
| 5934 |
// SSL_set_tmp_dh_callback does nothing. |
| 5935 |
OPENSSL_EXPORT OPENSSL_DEPRECATED void SSL_set_tmp_dh_callback( |
| 5936 |
SSL *ssl, DH *(*cb)(SSL *ssl, int is_export, int keylength)); |
| 5937 |
|
| 5938 |
// SSL_CTX_set_dh_auto does nothing and returns 0 for error. |
| 5939 |
OPENSSL_EXPORT OPENSSL_DEPRECATED long SSL_CTX_set_dh_auto(SSL_CTX *ctx, |
| 5940 |
int onoff); |
| 5941 |
|
| 5942 |
|
| 5943 |
// Security Levels No-ops [Deprecated]. |
| 5944 |
// |
| 5945 |
// OpenSSL has the option to set “security levels”. Security levels can be |
| 5946 |
// defined either at compile time with "-DOPENSSL_TLS_SECURITY_LEVEL=level" or |
| 5947 |
// at runtime with |SSL_CTX_set_security_level|. AWS-LC does not support this |
| 5948 |
// and the security level APIs are no-ops within AWS-LC. AWS-LC intentionally |
| 5949 |
// limits the knobs a consumer can tweak in regards to security. |
| 5950 |
|
| 5951 |
// SSL_CTX_get_security_level returns 0. This is only to maintain compatibility |
| 5952 |
// with OpenSSL and no security assumptions should be based on the number this |
| 5953 |
// function returns. |
| 5954 |
// |
| 5955 |
// Per OpenSSL's definition of Level 0, 1, and 2: |
| 5956 |
// |
| 5957 |
// Level 0: |
| 5958 |
// Everything is permitted. This retains compatibility with previous versions of |
| 5959 |
// OpenSSL. |
| 5960 |
// |
| 5961 |
// Level 1 |
| 5962 |
// The security level corresponds to a minimum of 80 bits of security. Any |
| 5963 |
// parameters offering below 80 bits of security are excluded. As a result RSA, |
| 5964 |
// DSA and DH keys shorter than 1024 bits and ECC keys shorter than 160 bits are |
| 5965 |
// prohibited. All export cipher suites are prohibited since they all offer less |
| 5966 |
// than 80 bits of security. SSL version 2 is prohibited. Any cipher suite using |
| 5967 |
// MD5 for the MAC is also prohibited. |
| 5968 |
// |
| 5969 |
// Level 2 |
| 5970 |
// Security level set to 112 bits of security. As a result RSA, DSA and DH keys |
| 5971 |
// shorter than 2048 bits and ECC keys shorter than 224 bits are prohibited. In |
| 5972 |
// addition to the level 1 exclusions any cipher suite using RC4 is also |
| 5973 |
// prohibited. SSL version 3 is also not allowed. Compression is disabled. |
| 5974 |
// |
| 5975 |
// AWS-LC's libssl doesn't support SSLv2 or SSLv3 and we have no support for MD5 |
| 5976 |
// or RC4 related cipher suites. However, we don't directly prohibit 512 bit RSA |
| 5977 |
// keys like Level 1 in OpenSSL states. Since this function is only retained for |
| 5978 |
// OpenSSL compatibility, we set the returned value to 0. |
| 5979 |
OPENSSL_EXPORT OPENSSL_DEPRECATED int SSL_CTX_get_security_level( |
| 5980 |
const SSL_CTX *ctx); |
| 5981 |
|
| 5982 |
// SSL_CTX_set_security_level does nothing. See documentation in |
| 5983 |
// |SSL_CTX_get_security_level| about implied security levels for AWS-LC. |
| 5984 |
OPENSSL_EXPORT OPENSSL_DEPRECATED void SSL_CTX_set_security_level( |
| 5985 |
const SSL_CTX *ctx, int level); |
| 5986 |
|
| 5987 |
|
| 5988 |
// General No-op Functions [Deprecated]. |
| 5989 |
|
| 5990 |
// SSL_set_state does nothing. |
| 5991 |
OPENSSL_EXPORT OPENSSL_DEPRECATED void SSL_set_state(SSL *ssl, int state); |
| 5992 |
|
| 5993 |
// SSL_get_shared_ciphers writes an empty string to |buf| and returns a |
| 5994 |
// pointer to |buf|, or NULL if |len| is less than or equal to zero. |
| 5995 |
// |
| 5996 |
// TODO (CryptoAlg-2398): Add |OPENSSL_DEPRECATED|. nginx defines -Werror and |
| 5997 |
// depends on this. |
| 5998 |
OPENSSL_EXPORT char *SSL_get_shared_ciphers(const SSL *ssl, char *buf, int len); |
| 5999 |
|
| 6000 |
// SSL_get_shared_sigalgs returns zero. |
| 6001 |
OPENSSL_EXPORT OPENSSL_DEPRECATED int SSL_get_shared_sigalgs( |
| 6002 |
SSL *ssl, int idx, int *psign, int *phash, int *psignandhash, uint8_t *rsig, |
| 6003 |
uint8_t *rhash); |
| 6004 |
|
| 6005 |
// SSL_CTX_set_ecdh_auto returns one. This is also a no-op in OpenSSL. |
| 6006 |
#define SSL_CTX_set_ecdh_auto(ctx, onoff) 1 |
| 6007 |
|
| 6008 |
// SSL_set_ecdh_auto returns one. This is also a no-op in OpenSSL. |
| 6009 |
#define SSL_set_ecdh_auto(ssl, onoff) 1 |
| 6010 |
|
| 6011 |
// ERR_load_SSL_strings does nothing in AWS-LC and OpenSSL. |
| 6012 |
OPENSSL_EXPORT OPENSSL_DEPRECATED void ERR_load_SSL_strings(void); |
| 6013 |
|
| 6014 |
// SSL_load_error_strings does nothing in AWS-LC and OpenSSL. |
| 6015 |
// |
| 6016 |
// TODO (CryptoAlg-2398): Add |OPENSSL_DEPRECATED|. nginx defines -Werror and |
| 6017 |
// depends on this. |
| 6018 |
OPENSSL_EXPORT void SSL_load_error_strings(void); |
| 6019 |
|
| 6020 |
|
| 6021 |
// SSL TMP_RSA No-ops [Deprecated]. |
| 6022 |
// |
| 6023 |
// Support for these methods was intentionally removed due to them being the |
| 6024 |
// center of the FREAK attack. These functions are also no-ops in OpenSSL. |
| 6025 |
// FREAK Attack: https://freakattack.com/ |
| 6026 |
|
| 6027 |
// SSL_CTX_set_tmp_rsa_callback does nothing. |
| 6028 |
OPENSSL_EXPORT OPENSSL_DEPRECATED void SSL_CTX_set_tmp_rsa_callback( |
| 6029 |
SSL_CTX *ctx, RSA *(*cb)(SSL *ssl, int is_export, int keylength)); |
| 6030 |
|
| 6031 |
// SSL_set_tmp_rsa_callback does nothing. |
| 6032 |
OPENSSL_EXPORT OPENSSL_DEPRECATED void SSL_set_tmp_rsa_callback( |
| 6033 |
SSL *ssl, RSA *(*cb)(SSL *ssl, int is_export, int keylength)); |
| 6034 |
|
| 6035 |
// SSL_CTX_need_tmp_RSA returns zero. |
| 6036 |
OPENSSL_EXPORT OPENSSL_DEPRECATED int SSL_CTX_need_tmp_RSA(const SSL_CTX *ctx); |
| 6037 |
|
| 6038 |
// SSL_need_tmp_RSA returns zero. |
| 6039 |
OPENSSL_EXPORT OPENSSL_DEPRECATED int SSL_need_tmp_RSA(const SSL *ssl); |
| 6040 |
|
| 6041 |
// SSL_CTX_set_tmp_rsa returns one. |
| 6042 |
OPENSSL_EXPORT OPENSSL_DEPRECATED int SSL_CTX_set_tmp_rsa(SSL_CTX *ctx, |
| 6043 |
const RSA *rsa); |
| 6044 |
|
| 6045 |
// SSL_set_tmp_rsa returns one. |
| 6046 |
OPENSSL_EXPORT OPENSSL_DEPRECATED int SSL_set_tmp_rsa(SSL *ssl, const RSA *rsa); |
| 6047 |
|
| 6048 |
|
| 6049 |
// Nodejs compatibility section (hidden). |
| 6050 |
// |
| 6051 |
// These defines exist for node.js, with the hope that we can eliminate the |
| 6052 |
// need for them over time. |
| 6053 |
|
| 6054 |
#define SSLerr(function, reason) \ |
| 6055 |
ERR_put_error(ERR_LIB_SSL, 0, reason, __FILE__, __LINE__) |
| 6056 |
|
| 6057 |
|
| 6058 |
// Preprocessor compatibility section (hidden). |
| 6059 |
// |
| 6060 |
// Historically, a number of APIs were implemented in OpenSSL as macros and |
| 6061 |
// constants to 'ctrl' functions. To avoid breaking #ifdefs in consumers, this |
| 6062 |
// section defines a number of legacy macros. |
| 6063 |
// |
| 6064 |
// Although using either the CTRL values or their wrapper macros in #ifdefs is |
| 6065 |
// still supported, the CTRL values may not be passed to |SSL_ctrl| and |
| 6066 |
// |SSL_CTX_ctrl|. Call the functions (previously wrapper macros) instead. |
| 6067 |
// |
| 6068 |
// See PORTING.md in the BoringSSL source tree for a table of corresponding |
| 6069 |
// functions. |
| 6070 |
// https://github.com/aws/aws-lc/blob/main/PORTING.md#replacements-for-ctrl-values |
| 6071 |
|
| 6072 |
#define DTLS_CTRL_GET_TIMEOUT doesnt_exist |
| 6073 |
#define DTLS_CTRL_HANDLE_TIMEOUT doesnt_exist |
| 6074 |
#define SSL_CTRL_CHAIN doesnt_exist |
| 6075 |
#define SSL_CTRL_CHAIN_CERT doesnt_exist |
| 6076 |
#define SSL_CTRL_CHANNEL_ID doesnt_exist |
| 6077 |
#define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS doesnt_exist |
| 6078 |
#define SSL_CTRL_CLEAR_MODE doesnt_exist |
| 6079 |
#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS doesnt_exist |
| 6080 |
#define SSL_CTRL_CLEAR_OPTIONS doesnt_exist |
| 6081 |
#define SSL_CTRL_EXTRA_CHAIN_CERT doesnt_exist |
| 6082 |
#define SSL_CTRL_GET_CHAIN_CERTS doesnt_exist |
| 6083 |
#define SSL_CTRL_GET_CHANNEL_ID doesnt_exist |
| 6084 |
#define SSL_CTRL_GET_CLIENT_CERT_TYPES doesnt_exist |
| 6085 |
#define SSL_CTRL_GET_EXTRA_CHAIN_CERTS doesnt_exist |
| 6086 |
#define SSL_CTRL_GET_MAX_CERT_LIST doesnt_exist |
| 6087 |
#define SSL_CTRL_GET_NEGOTIATED_GROUP doesnt_exist |
| 6088 |
#define SSL_CTRL_GET_NUM_RENEGOTIATIONS doesnt_exist |
| 6089 |
#define SSL_CTRL_GET_READ_AHEAD doesnt_exist |
| 6090 |
#define SSL_CTRL_GET_RI_SUPPORT doesnt_exist |
| 6091 |
#define SSL_CTRL_GET_SERVER_TMP_KEY doesnt_exist |
| 6092 |
#define SSL_CTRL_GET_SESSION_REUSED doesnt_exist |
| 6093 |
#define SSL_CTRL_GET_SESS_CACHE_MODE doesnt_exist |
| 6094 |
#define SSL_CTRL_GET_SESS_CACHE_SIZE doesnt_exist |
| 6095 |
#define SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE doesnt_exist |
| 6096 |
#define SSL_CTRL_GET_TLSEXT_TICKET_KEYS doesnt_exist |
| 6097 |
#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS doesnt_exist |
| 6098 |
#define SSL_CTRL_MODE doesnt_exist |
| 6099 |
#define SSL_CTRL_NEED_TMP_RSA doesnt_exist |
| 6100 |
#define SSL_CTRL_OPTIONS doesnt_exist |
| 6101 |
#define SSL_CTRL_SESS_NUMBER doesnt_exist |
| 6102 |
#define SSL_CTRL_SET_CURVES doesnt_exist |
| 6103 |
#define SSL_CTRL_SET_CURVES_LIST doesnt_exist |
| 6104 |
#define SSL_CTRL_SET_GROUPS doesnt_exist |
| 6105 |
#define SSL_CTRL_SET_GROUPS_LIST doesnt_exist |
| 6106 |
#define SSL_CTRL_SET_ECDH_AUTO doesnt_exist |
| 6107 |
#define SSL_CTRL_SET_MAX_CERT_LIST doesnt_exist |
| 6108 |
#define SSL_CTRL_SET_MAX_SEND_FRAGMENT doesnt_exist |
| 6109 |
#define SSL_CTRL_SET_MSG_CALLBACK doesnt_exist |
| 6110 |
#define SSL_CTRL_SET_MSG_CALLBACK_ARG doesnt_exist |
| 6111 |
#define SSL_CTRL_SET_MTU doesnt_exist |
| 6112 |
#define SSL_CTRL_SET_READ_AHEAD doesnt_exist |
| 6113 |
#define SSL_CTRL_SET_SESS_CACHE_MODE doesnt_exist |
| 6114 |
#define SSL_CTRL_SET_SESS_CACHE_SIZE doesnt_exist |
| 6115 |
#define SSL_CTRL_SET_TLSEXT_HOSTNAME doesnt_exist |
| 6116 |
#define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG doesnt_exist |
| 6117 |
#define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB doesnt_exist |
| 6118 |
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB doesnt_exist |
| 6119 |
#define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE doesnt_exist |
| 6120 |
#define SSL_CTRL_SET_TLSEXT_TICKET_KEYS doesnt_exist |
| 6121 |
#define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB doesnt_exist |
| 6122 |
#define SSL_CTRL_SET_TMP_DH doesnt_exist |
| 6123 |
#define SSL_CTRL_SET_TMP_DH_CB doesnt_exist |
| 6124 |
#define SSL_CTRL_SET_TMP_ECDH doesnt_exist |
| 6125 |
#define SSL_CTRL_SET_TMP_ECDH_CB doesnt_exist |
| 6126 |
#define SSL_CTRL_SET_TMP_RSA doesnt_exist |
| 6127 |
#define SSL_CTRL_SET_TMP_RSA_CB doesnt_exist |
| 6128 |
|
| 6129 |
// |BORINGSSL_PREFIX| already makes each of these symbols into macros, so there |
| 6130 |
// is no need to define conflicting macros. |
| 6131 |
#if !defined(BORINGSSL_PREFIX) |
| 6132 |
|
| 6133 |
#define DTLSv1_get_timeout DTLSv1_get_timeout |
| 6134 |
#define DTLSv1_handle_timeout DTLSv1_handle_timeout |
| 6135 |
#define SSL_CTX_add0_chain_cert SSL_CTX_add0_chain_cert |
| 6136 |
#define SSL_CTX_add1_chain_cert SSL_CTX_add1_chain_cert |
| 6137 |
#define SSL_CTX_add_extra_chain_cert SSL_CTX_add_extra_chain_cert |
| 6138 |
#define SSL_CTX_build_cert_chain SSL_CTX_build_cert_chain |
| 6139 |
#define SSL_CTX_clear_extra_chain_certs SSL_CTX_clear_extra_chain_certs |
| 6140 |
#define SSL_CTX_clear_chain_certs SSL_CTX_clear_chain_certs |
| 6141 |
#define SSL_CTX_clear_mode SSL_CTX_clear_mode |
| 6142 |
#define SSL_CTX_clear_options SSL_CTX_clear_options |
| 6143 |
#define SSL_CTX_get0_chain_certs SSL_CTX_get0_chain_certs |
| 6144 |
#define SSL_CTX_get_extra_chain_certs SSL_CTX_get_extra_chain_certs |
| 6145 |
#define SSL_CTX_get_max_cert_list SSL_CTX_get_max_cert_list |
| 6146 |
#define SSL_CTX_get_mode SSL_CTX_get_mode |
| 6147 |
#define SSL_CTX_get_options SSL_CTX_get_options |
| 6148 |
#define SSL_CTX_get_read_ahead SSL_CTX_get_read_ahead |
| 6149 |
#define SSL_CTX_get_session_cache_mode SSL_CTX_get_session_cache_mode |
| 6150 |
#define SSL_CTX_get_tlsext_status_cb SSL_CTX_get_tlsext_status_cb |
| 6151 |
#define SSL_CTX_get_tlsext_ticket_keys SSL_CTX_get_tlsext_ticket_keys |
| 6152 |
#define SSL_CTX_need_tmp_RSA SSL_CTX_need_tmp_RSA |
| 6153 |
#define SSL_CTX_sess_get_cache_size SSL_CTX_sess_get_cache_size |
| 6154 |
#define SSL_CTX_sess_number SSL_CTX_sess_number |
| 6155 |
#define SSL_CTX_sess_set_cache_size SSL_CTX_sess_set_cache_size |
| 6156 |
#define SSL_CTX_set0_chain SSL_CTX_set0_chain |
| 6157 |
#define SSL_CTX_set1_chain SSL_CTX_set1_chain |
| 6158 |
#define SSL_CTX_set1_curves SSL_CTX_set1_curves |
| 6159 |
#define SSL_CTX_set1_groups SSL_CTX_set1_groups |
| 6160 |
#define SSL_CTX_set_max_cert_list SSL_CTX_set_max_cert_list |
| 6161 |
#define SSL_CTX_set_max_send_fragment SSL_CTX_set_max_send_fragment |
| 6162 |
#define SSL_CTX_set_min_proto_version SSL_CTX_set_min_proto_version |
| 6163 |
#define SSL_CTX_set_mode SSL_CTX_set_mode |
| 6164 |
#define SSL_CTX_set_msg_callback_arg SSL_CTX_set_msg_callback_arg |
| 6165 |
#define SSL_CTX_set_options SSL_CTX_set_options |
| 6166 |
#define SSL_CTX_set_read_ahead SSL_CTX_set_read_ahead |
| 6167 |
#define SSL_CTX_set_session_cache_mode SSL_CTX_set_session_cache_mode |
| 6168 |
#define SSL_CTX_set_tlsext_servername_arg SSL_CTX_set_tlsext_servername_arg |
| 6169 |
#define SSL_CTX_set_tlsext_servername_callback \ |
| 6170 |
SSL_CTX_set_tlsext_servername_callback |
| 6171 |
#define SSL_CTX_set_tlsext_ticket_key_cb SSL_CTX_set_tlsext_ticket_key_cb |
| 6172 |
#define SSL_CTX_set_tlsext_ticket_keys SSL_CTX_set_tlsext_ticket_keys |
| 6173 |
#define SSL_CTX_set_tmp_dh SSL_CTX_set_tmp_dh |
| 6174 |
#define SSL_CTX_set_tmp_ecdh SSL_CTX_set_tmp_ecdh |
| 6175 |
#define SSL_CTX_set_tmp_rsa SSL_CTX_set_tmp_rsa |
| 6176 |
#define SSL_add0_chain_cert SSL_add0_chain_cert |
| 6177 |
#define SSL_add1_chain_cert SSL_add1_chain_cert |
| 6178 |
#define SSL_build_cert_chain SSL_build_cert_chain |
| 6179 |
#define SSL_clear_chain_certs SSL_clear_chain_certs |
| 6180 |
#define SSL_clear_num_renegotiations SSL_clear_num_renegotiations |
| 6181 |
#define SSL_clear_mode SSL_clear_mode |
| 6182 |
#define SSL_clear_options SSL_clear_options |
| 6183 |
#define SSL_get0_certificate_types SSL_get0_certificate_types |
| 6184 |
#define SSL_get0_chain_certs SSL_get0_chain_certs |
| 6185 |
#define SSL_get_max_cert_list SSL_get_max_cert_list |
| 6186 |
#define SSL_get_mode SSL_get_mode |
| 6187 |
#define SSL_get_negotiated_group SSL_get_negotiated_group |
| 6188 |
#define SSL_get_options SSL_get_options |
| 6189 |
#define SSL_get_secure_renegotiation_support \ |
| 6190 |
SSL_get_secure_renegotiation_support |
| 6191 |
#define SSL_need_tmp_RSA SSL_need_tmp_RSA |
| 6192 |
#define SSL_num_renegotiations SSL_num_renegotiations |
| 6193 |
#define SSL_session_reused SSL_session_reused |
| 6194 |
#define SSL_set0_chain SSL_set0_chain |
| 6195 |
#define SSL_set1_chain SSL_set1_chain |
| 6196 |
#define SSL_set1_curves SSL_set1_curves |
| 6197 |
#define SSL_set1_groups SSL_set1_groups |
| 6198 |
#define SSL_set_max_cert_list SSL_set_max_cert_list |
| 6199 |
#define SSL_set_max_send_fragment SSL_set_max_send_fragment |
| 6200 |
#define SSL_set_mode SSL_set_mode |
| 6201 |
#define SSL_set_msg_callback_arg SSL_set_msg_callback_arg |
| 6202 |
#define SSL_set_mtu SSL_set_mtu |
| 6203 |
#define SSL_set_options SSL_set_options |
| 6204 |
#define SSL_set_tlsext_host_name SSL_set_tlsext_host_name |
| 6205 |
#define SSL_set_tmp_dh SSL_set_tmp_dh |
| 6206 |
#define SSL_set_tmp_ecdh SSL_set_tmp_ecdh |
| 6207 |
#define SSL_set_tmp_rsa SSL_set_tmp_rsa |
| 6208 |
#define SSL_total_renegotiations SSL_total_renegotiations |
| 6209 |
#define SSL_in_connect_init SSL_in_connect_init |
| 6210 |
#define SSL_in_accept_init SSL_in_accept_init |
| 6211 |
|
| 6212 |
#endif // !defined(BORINGSSL_PREFIX) |
| 6213 |
|
| 6214 |
|
| 6215 |
#if defined(__cplusplus) |
| 6216 |
} // extern C |
| 6217 |
|
| 6218 |
#if !defined(BORINGSSL_NO_CXX) |
| 6219 |
|
| 6220 |
extern "C++" { |
| 6221 |
|
| 6222 |
BSSL_NAMESPACE_BEGIN |
| 6223 |
|
| 6224 |
BORINGSSL_MAKE_DELETER(SSL, SSL_free) |
| 6225 |
BORINGSSL_MAKE_DELETER(SSL_CTX, SSL_CTX_free) |
| 6226 |
BORINGSSL_MAKE_UP_REF(SSL_CTX, SSL_CTX_up_ref) |
| 6227 |
BORINGSSL_MAKE_DELETER(SSL_ECH_KEYS, SSL_ECH_KEYS_free) |
| 6228 |
BORINGSSL_MAKE_UP_REF(SSL_ECH_KEYS, SSL_ECH_KEYS_up_ref) |
| 6229 |
BORINGSSL_MAKE_DELETER(SSL_SESSION, SSL_SESSION_free) |
| 6230 |
BORINGSSL_MAKE_UP_REF(SSL_SESSION, SSL_SESSION_up_ref) |
| 6231 |
|
| 6232 |
|
| 6233 |
// *** DEPRECATED EXPERIMENT — DO NOT USE *** |
| 6234 |
// |
| 6235 |
// Split handshakes. |
| 6236 |
// |
| 6237 |
// WARNING: This mechanism is deprecated and should not be used. It is very |
| 6238 |
// fragile and difficult to use correctly. The relationship between |
| 6239 |
// configuration options across the two halves is ill-defined and not |
| 6240 |
// self-consistent. Additionally, version skew across the two halves risks |
| 6241 |
// unusual behavior and connection failure. New development should use the |
| 6242 |
// handshake hints API. Existing deployments should migrate to handshake hints |
| 6243 |
// to reduce the risk of service outages. |
| 6244 |
// |
| 6245 |
// Split handshakes allows the handshake part of a TLS connection to be |
| 6246 |
// performed in a different process (or on a different machine) than the data |
| 6247 |
// exchange. This only applies to servers. |
| 6248 |
// |
| 6249 |
// In the first part of a split handshake, an |SSL| (where the |SSL_CTX| has |
| 6250 |
// been configured with |SSL_CTX_set_handoff_mode|) is used normally. Once the |
| 6251 |
// ClientHello message has been received, the handshake will stop and |
| 6252 |
// |SSL_get_error| will indicate |SSL_ERROR_HANDOFF|. At this point (and only |
| 6253 |
// at this point), |SSL_serialize_handoff| can be called to write the “handoff” |
| 6254 |
// state of the connection. |
| 6255 |
// |
| 6256 |
// Elsewhere, a fresh |SSL| can be used with |SSL_apply_handoff| to continue |
| 6257 |
// the connection. The connection from the client is fed into this |SSL|, and |
| 6258 |
// the handshake resumed. When the handshake stops again and |SSL_get_error| |
| 6259 |
// indicates |SSL_ERROR_HANDBACK|, |SSL_serialize_handback| should be called to |
| 6260 |
// serialize the state of the handshake again. |
| 6261 |
// |
| 6262 |
// Back at the first location, a fresh |SSL| can be used with |
| 6263 |
// |SSL_apply_handback|. Then the client's connection can be processed mostly |
| 6264 |
// as normal. |
| 6265 |
// |
| 6266 |
// Lastly, when a connection is in the handoff state, whether or not |
| 6267 |
// |SSL_serialize_handoff| is called, |SSL_decline_handoff| will move it back |
| 6268 |
// into a normal state where the connection can proceed without impact. |
| 6269 |
// |
| 6270 |
// WARNING: Currently only works with TLS 1.0–1.2. |
| 6271 |
// WARNING: The serialisation formats are not yet stable: version skew may be |
| 6272 |
// fatal. |
| 6273 |
// WARNING: The handback data contains sensitive key material and must be |
| 6274 |
// protected. |
| 6275 |
// WARNING: Some calls on the final |SSL| will not work. Just as an example, |
| 6276 |
// calls like |SSL_get0_session_id_context| and |SSL_get_privatekey| won't |
| 6277 |
// work because the certificate used for handshaking isn't available. |
| 6278 |
// WARNING: |SSL_apply_handoff| may trigger “msg” callback calls. |
| 6279 |
|
| 6280 |
OPENSSL_EXPORT void SSL_CTX_set_handoff_mode(SSL_CTX *ctx, bool on); |
| 6281 |
OPENSSL_EXPORT void SSL_set_handoff_mode(SSL *SSL, bool on); |
| 6282 |
OPENSSL_EXPORT bool SSL_serialize_handoff(const SSL *ssl, CBB *out, |
| 6283 |
SSL_CLIENT_HELLO *out_hello); |
| 6284 |
OPENSSL_EXPORT bool SSL_decline_handoff(SSL *ssl); |
| 6285 |
OPENSSL_EXPORT bool SSL_apply_handoff(SSL *ssl, Span<const uint8_t> handoff); |
| 6286 |
OPENSSL_EXPORT bool SSL_serialize_handback(const SSL *ssl, CBB *out); |
| 6287 |
OPENSSL_EXPORT bool SSL_apply_handback(SSL *ssl, Span<const uint8_t> handback); |
| 6288 |
|
| 6289 |
// SSL_get_traffic_secrets sets |*out_read_traffic_secret| and |
| 6290 |
// |*out_write_traffic_secret| to reference the TLS 1.3 traffic secrets for |
| 6291 |
// |ssl|. This function is only valid on TLS 1.3 connections that have |
| 6292 |
// completed the handshake. It returns true on success and false on error. |
| 6293 |
OPENSSL_EXPORT bool SSL_get_traffic_secrets( |
| 6294 |
const SSL *ssl, Span<const uint8_t> *out_read_traffic_secret, |
| 6295 |
Span<const uint8_t> *out_write_traffic_secret); |
| 6296 |
|
| 6297 |
// SSL_CTX_set_aes_hw_override_for_testing sets |override_value| to |
| 6298 |
// override checking for aes hardware support for testing. If |override_value| |
| 6299 |
// is set to true, the library will behave as if aes hardware support is |
| 6300 |
// present. If it is set to false, the library will behave as if aes hardware |
| 6301 |
// support is not present. |
| 6302 |
OPENSSL_EXPORT void SSL_CTX_set_aes_hw_override_for_testing( |
| 6303 |
SSL_CTX *ctx, bool override_value); |
| 6304 |
|
| 6305 |
// SSL_set_aes_hw_override_for_testing acts the same as |
| 6306 |
// |SSL_CTX_set_aes_override_for_testing| but only configures a single |SSL*|. |
| 6307 |
OPENSSL_EXPORT void SSL_set_aes_hw_override_for_testing(SSL *ssl, |
| 6308 |
bool override_value); |
| 6309 |
|
| 6310 |
BSSL_NAMESPACE_END |
| 6311 |
|
| 6312 |
} // extern C++ |
| 6313 |
|
| 6314 |
#endif // !defined(BORINGSSL_NO_CXX) |
| 6315 |
|
| 6316 |
#endif |
| 6317 |
|
| 6318 |
// Define some reason codes from OpenSSL to ease compilation against AWS-LC. |
| 6319 |
// None of these reason codes are actually returned by AWS-LC. |
| 6320 |
// Code paths that condition on these codes might break. Grep for |
| 6321 |
// |ERR_GET_REASON| and |ERR_GET_FUNC| to inspect. |
| 6322 |
|
| 6323 |
// Per C99 standard 6.8.4.2.1 the controlling expression in the switch statement |
| 6324 |
// has integer type. Hence it can handle quite large offset values assuming just |
| 6325 |
// two bytes. Just pick a somewhat large random value to prevent collisions on |
| 6326 |
// later macro definitions from upstream. |
| 6327 |
#define SSL_R_BACKWARDS_COMPATABILITY_OFFSET 0x5D21 |
| 6328 |
|
| 6329 |
// See CryptoAlg-954. |
| 6330 |
#define SSL_R_NO_PROTOCOLS_AVAILABLE (SSL_R_BACKWARDS_COMPATABILITY_OFFSET + 1) |
| 6331 |
#define SSL_R_BAD_PROTOCOL_VERSION_NUMBER \ |
| 6332 |
(SSL_R_BACKWARDS_COMPATABILITY_OFFSET + 2) |
| 6333 |
#define SSL_R_UNSUPPORTED_SSL_VERSION (SSL_R_BACKWARDS_COMPATABILITY_OFFSET + 3) |
| 6334 |
#define SSL_R_VERSION_TOO_HIGH (SSL_R_BACKWARDS_COMPATABILITY_OFFSET + 4) |
| 6335 |
#define SSL_R_VERSION_TOO_LOW (SSL_R_BACKWARDS_COMPATABILITY_OFFSET + 5) |
| 6336 |
|
| 6337 |
#define SSL_R_APP_DATA_IN_HANDSHAKE 100 |
| 6338 |
#define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 101 |
| 6339 |
#define SSL_R_BAD_ALERT 102 |
| 6340 |
#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 |
| 6341 |
#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 104 |
| 6342 |
#define SSL_R_BAD_DH_P_LENGTH 105 |
| 6343 |
#define SSL_R_BAD_DIGEST_LENGTH 106 |
| 6344 |
#define SSL_R_BAD_ECC_CERT 107 |
| 6345 |
#define SSL_R_BAD_ECPOINT 108 |
| 6346 |
#define SSL_R_BAD_HANDSHAKE_RECORD 109 |
| 6347 |
#define SSL_R_BAD_HELLO_REQUEST 110 |
| 6348 |
#define SSL_R_BAD_LENGTH 111 |
| 6349 |
#define SSL_R_BAD_PACKET_LENGTH 112 |
| 6350 |
#define SSL_R_BAD_RSA_ENCRYPT 113 |
| 6351 |
#define SSL_R_BAD_SIGNATURE 114 |
| 6352 |
#define SSL_R_BAD_SRTP_MKI_VALUE 115 |
| 6353 |
#define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST 116 |
| 6354 |
#define SSL_R_BAD_SSL_FILETYPE 117 |
| 6355 |
#define SSL_R_BAD_WRITE_RETRY 118 |
| 6356 |
#define SSL_R_BIO_NOT_SET 119 |
| 6357 |
#define SSL_R_BN_LIB 120 |
| 6358 |
#define SSL_R_BUFFER_TOO_SMALL 121 |
| 6359 |
#define SSL_R_CA_DN_LENGTH_MISMATCH 122 |
| 6360 |
#define SSL_R_CA_DN_TOO_LONG 123 |
| 6361 |
#define SSL_R_CCS_RECEIVED_EARLY 124 |
| 6362 |
#define SSL_R_CERTIFICATE_VERIFY_FAILED 125 |
| 6363 |
#define SSL_R_CERT_CB_ERROR 126 |
| 6364 |
#define SSL_R_CERT_LENGTH_MISMATCH 127 |
| 6365 |
#define SSL_R_CHANNEL_ID_NOT_P256 128 |
| 6366 |
#define SSL_R_CHANNEL_ID_SIGNATURE_INVALID 129 |
| 6367 |
#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 130 |
| 6368 |
#define SSL_R_CLIENTHELLO_PARSE_FAILED 131 |
| 6369 |
#define SSL_R_CLIENTHELLO_TLSEXT 132 |
| 6370 |
#define SSL_R_CONNECTION_REJECTED 133 |
| 6371 |
#define SSL_R_CONNECTION_TYPE_NOT_SET 134 |
| 6372 |
#define SSL_R_CUSTOM_EXTENSION_ERROR 135 |
| 6373 |
#define SSL_R_DATA_LENGTH_TOO_LONG 136 |
| 6374 |
#define SSL_R_DECODE_ERROR 137 |
| 6375 |
#define SSL_R_DECRYPTION_FAILED 138 |
| 6376 |
#define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 139 |
| 6377 |
#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 140 |
| 6378 |
#define SSL_R_DH_P_TOO_LONG 141 |
| 6379 |
#define SSL_R_DIGEST_CHECK_FAILED 142 |
| 6380 |
#define SSL_R_DTLS_MESSAGE_TOO_BIG 143 |
| 6381 |
#define SSL_R_ECC_CERT_NOT_FOR_SIGNING 144 |
| 6382 |
#define SSL_R_EMS_STATE_INCONSISTENT 145 |
| 6383 |
#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 146 |
| 6384 |
#define SSL_R_ERROR_ADDING_EXTENSION 147 |
| 6385 |
#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 148 |
| 6386 |
#define SSL_R_ERROR_PARSING_EXTENSION 149 |
| 6387 |
#define SSL_R_EXCESSIVE_MESSAGE_SIZE 150 |
| 6388 |
#define SSL_R_EXTRA_DATA_IN_MESSAGE 151 |
| 6389 |
#define SSL_R_FRAGMENT_MISMATCH 152 |
| 6390 |
#define SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION 153 |
| 6391 |
#define SSL_R_HANDSHAKE_FAILURE_ON_CLIENT_HELLO 154 |
| 6392 |
#define SSL_R_HTTPS_PROXY_REQUEST 155 |
| 6393 |
#define SSL_R_HTTP_REQUEST 156 |
| 6394 |
#define SSL_R_INAPPROPRIATE_FALLBACK 157 |
| 6395 |
#define SSL_R_INVALID_COMMAND 158 |
| 6396 |
#define SSL_R_INVALID_MESSAGE 159 |
| 6397 |
#define SSL_R_INVALID_SSL_SESSION 160 |
| 6398 |
#define SSL_R_INVALID_TICKET_KEYS_LENGTH 161 |
| 6399 |
#define SSL_R_LENGTH_MISMATCH 162 |
| 6400 |
#define SSL_R_MISSING_EXTENSION 164 |
| 6401 |
#define SSL_R_MISSING_RSA_CERTIFICATE 165 |
| 6402 |
#define SSL_R_MISSING_TMP_DH_KEY 166 |
| 6403 |
#define SSL_R_MISSING_TMP_ECDH_KEY 167 |
| 6404 |
#define SSL_R_MIXED_SPECIAL_OPERATOR_WITH_GROUPS 168 |
| 6405 |
#define SSL_R_MTU_TOO_SMALL 169 |
| 6406 |
#define SSL_R_NEGOTIATED_BOTH_NPN_AND_ALPN 170 |
| 6407 |
#define SSL_R_NESTED_GROUP 171 |
| 6408 |
#define SSL_R_NO_CERTIFICATES_RETURNED 172 |
| 6409 |
#define SSL_R_NO_CERTIFICATE_ASSIGNED 173 |
| 6410 |
#define SSL_R_NO_CERTIFICATE_SET 174 |
| 6411 |
#define SSL_R_NO_CIPHERS_AVAILABLE 175 |
| 6412 |
#define SSL_R_NO_CIPHERS_PASSED 176 |
| 6413 |
#define SSL_R_NO_CIPHER_MATCH 177 |
| 6414 |
#define SSL_R_NO_COMPRESSION_SPECIFIED 178 |
| 6415 |
#define SSL_R_NO_METHOD_SPECIFIED 179 |
| 6416 |
#define SSL_R_NO_PRIVATE_KEY_ASSIGNED 181 |
| 6417 |
#define SSL_R_NO_RENEGOTIATION 182 |
| 6418 |
#define SSL_R_NO_REQUIRED_DIGEST 183 |
| 6419 |
#define SSL_R_NO_SHARED_CIPHER 184 |
| 6420 |
#define SSL_R_NULL_SSL_CTX 185 |
| 6421 |
#define SSL_R_NULL_SSL_METHOD_PASSED 186 |
| 6422 |
#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 187 |
| 6423 |
#define SSL_R_OLD_SESSION_VERSION_NOT_RETURNED 188 |
| 6424 |
#define SSL_R_OUTPUT_ALIASES_INPUT 189 |
| 6425 |
#define SSL_R_PARSE_TLSEXT 190 |
| 6426 |
#define SSL_R_PATH_TOO_LONG 191 |
| 6427 |
#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 192 |
| 6428 |
#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 193 |
| 6429 |
#define SSL_R_PROTOCOL_IS_SHUTDOWN 194 |
| 6430 |
#define SSL_R_PSK_IDENTITY_NOT_FOUND 195 |
| 6431 |
#define SSL_R_PSK_NO_CLIENT_CB 196 |
| 6432 |
#define SSL_R_PSK_NO_SERVER_CB 197 |
| 6433 |
#define SSL_R_READ_TIMEOUT_EXPIRED 198 |
| 6434 |
#define SSL_R_RECORD_LENGTH_MISMATCH 199 |
| 6435 |
#define SSL_R_RECORD_TOO_LARGE 200 |
| 6436 |
#define SSL_R_RENEGOTIATION_ENCODING_ERR 201 |
| 6437 |
#define SSL_R_RENEGOTIATION_MISMATCH 202 |
| 6438 |
#define SSL_R_REQUIRED_CIPHER_MISSING 203 |
| 6439 |
#define SSL_R_RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION 204 |
| 6440 |
#define SSL_R_RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION 205 |
| 6441 |
#define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING 206 |
| 6442 |
#define SSL_R_SERVERHELLO_TLSEXT 207 |
| 6443 |
#define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 208 |
| 6444 |
#define SSL_R_SESSION_MAY_NOT_BE_CREATED 209 |
| 6445 |
#define SSL_R_SIGNATURE_ALGORITHMS_EXTENSION_SENT_BY_SERVER 210 |
| 6446 |
#define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES 211 |
| 6447 |
#define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE 212 |
| 6448 |
#define SSL_R_SSL3_EXT_INVALID_SERVERNAME 213 |
| 6449 |
#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 214 |
| 6450 |
#define SSL_R_SSL_HANDSHAKE_FAILURE 215 |
| 6451 |
#define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 216 |
| 6452 |
#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 217 |
| 6453 |
#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 218 |
| 6454 |
#define SSL_R_TOO_MANY_EMPTY_FRAGMENTS 219 |
| 6455 |
#define SSL_R_TOO_MANY_WARNING_ALERTS 220 |
| 6456 |
#define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 221 |
| 6457 |
#define SSL_R_UNEXPECTED_EXTENSION 222 |
| 6458 |
#define SSL_R_UNEXPECTED_MESSAGE 223 |
| 6459 |
#define SSL_R_UNEXPECTED_OPERATOR_IN_GROUP 224 |
| 6460 |
#define SSL_R_UNEXPECTED_RECORD 225 |
| 6461 |
#define SSL_R_UNINITIALIZED 226 |
| 6462 |
#define SSL_R_UNKNOWN_ALERT_TYPE 227 |
| 6463 |
#define SSL_R_UNKNOWN_CERTIFICATE_TYPE 228 |
| 6464 |
#define SSL_R_UNKNOWN_CIPHER_RETURNED 229 |
| 6465 |
#define SSL_R_UNKNOWN_CIPHER_TYPE 230 |
| 6466 |
#define SSL_R_UNKNOWN_DIGEST 231 |
| 6467 |
#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 232 |
| 6468 |
#define SSL_R_UNKNOWN_PROTOCOL 233 |
| 6469 |
#define SSL_R_UNKNOWN_SSL_VERSION 234 |
| 6470 |
#define SSL_R_UNKNOWN_STATE 235 |
| 6471 |
#define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED 236 |
| 6472 |
#define SSL_R_UNSUPPORTED_CIPHER 237 |
| 6473 |
#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 238 |
| 6474 |
#define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 239 |
| 6475 |
#define SSL_R_UNSUPPORTED_PROTOCOL 240 |
| 6476 |
#define SSL_R_WRONG_CERTIFICATE_TYPE 241 |
| 6477 |
#define SSL_R_WRONG_CIPHER_RETURNED 242 |
| 6478 |
#define SSL_R_WRONG_CURVE 243 |
| 6479 |
#define SSL_R_WRONG_MESSAGE_TYPE 244 |
| 6480 |
#define SSL_R_WRONG_SIGNATURE_TYPE 245 |
| 6481 |
#define SSL_R_WRONG_SSL_VERSION 246 |
| 6482 |
#define SSL_R_WRONG_VERSION_NUMBER 247 |
| 6483 |
#define SSL_R_X509_LIB 248 |
| 6484 |
#define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 249 |
| 6485 |
#define SSL_R_SHUTDOWN_WHILE_IN_INIT 250 |
| 6486 |
#define SSL_R_INVALID_OUTER_RECORD_TYPE 251 |
| 6487 |
#define SSL_R_UNSUPPORTED_PROTOCOL_FOR_CUSTOM_KEY 252 |
| 6488 |
#define SSL_R_NO_COMMON_SIGNATURE_ALGORITHMS 253 |
| 6489 |
#define SSL_R_DOWNGRADE_DETECTED 254 |
| 6490 |
#define SSL_R_EXCESS_HANDSHAKE_DATA 255 |
| 6491 |
#define SSL_R_INVALID_COMPRESSION_LIST 256 |
| 6492 |
#define SSL_R_DUPLICATE_EXTENSION 257 |
| 6493 |
#define SSL_R_MISSING_KEY_SHARE 258 |
| 6494 |
#define SSL_R_INVALID_ALPN_PROTOCOL 259 |
| 6495 |
#define SSL_R_TOO_MANY_KEY_UPDATES 260 |
| 6496 |
#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 261 |
| 6497 |
#define SSL_R_NO_CIPHERS_SPECIFIED 262 |
| 6498 |
#define SSL_R_RENEGOTIATION_EMS_MISMATCH 263 |
| 6499 |
#define SSL_R_DUPLICATE_KEY_SHARE 264 |
| 6500 |
#define SSL_R_NO_GROUPS_SPECIFIED 265 |
| 6501 |
#define SSL_R_NO_SHARED_GROUP 266 |
| 6502 |
#define SSL_R_PRE_SHARED_KEY_MUST_BE_LAST 267 |
| 6503 |
#define SSL_R_OLD_SESSION_PRF_HASH_MISMATCH 268 |
| 6504 |
#define SSL_R_INVALID_SCT_LIST 269 |
| 6505 |
#define SSL_R_TOO_MUCH_SKIPPED_EARLY_DATA 270 |
| 6506 |
#define SSL_R_PSK_IDENTITY_BINDER_COUNT_MISMATCH 271 |
| 6507 |
#define SSL_R_CANNOT_PARSE_LEAF_CERT 272 |
| 6508 |
#define SSL_R_SERVER_CERT_CHANGED 273 |
| 6509 |
#define SSL_R_CERTIFICATE_AND_PRIVATE_KEY_MISMATCH 274 |
| 6510 |
#define SSL_R_CANNOT_HAVE_BOTH_PRIVKEY_AND_METHOD 275 |
| 6511 |
#define SSL_R_TICKET_ENCRYPTION_FAILED 276 |
| 6512 |
#define SSL_R_ALPN_MISMATCH_ON_EARLY_DATA 277 |
| 6513 |
#define SSL_R_WRONG_VERSION_ON_EARLY_DATA 278 |
| 6514 |
#define SSL_R_UNEXPECTED_EXTENSION_ON_EARLY_DATA 279 |
| 6515 |
#define SSL_R_NO_SUPPORTED_VERSIONS_ENABLED 280 |
| 6516 |
#define SSL_R_APPLICATION_DATA_INSTEAD_OF_HANDSHAKE 281 |
| 6517 |
#define SSL_R_EMPTY_HELLO_RETRY_REQUEST 282 |
| 6518 |
#define SSL_R_EARLY_DATA_NOT_IN_USE 283 |
| 6519 |
#define SSL_R_HANDSHAKE_NOT_COMPLETE 284 |
| 6520 |
#define SSL_R_NEGOTIATED_TB_WITHOUT_EMS_OR_RI 285 |
| 6521 |
#define SSL_R_SERVER_ECHOED_INVALID_SESSION_ID 286 |
| 6522 |
#define SSL_R_PRIVATE_KEY_OPERATION_FAILED 287 |
| 6523 |
#define SSL_R_SECOND_SERVERHELLO_VERSION_MISMATCH 288 |
| 6524 |
#define SSL_R_OCSP_CB_ERROR 289 |
| 6525 |
#define SSL_R_SSL_SESSION_ID_TOO_LONG 290 |
| 6526 |
#define SSL_R_APPLICATION_DATA_ON_SHUTDOWN 291 |
| 6527 |
#define SSL_R_CERT_DECOMPRESSION_FAILED 292 |
| 6528 |
#define SSL_R_UNCOMPRESSED_CERT_TOO_LARGE 293 |
| 6529 |
#define SSL_R_UNKNOWN_CERT_COMPRESSION_ALG 294 |
| 6530 |
#define SSL_R_INVALID_SIGNATURE_ALGORITHM 295 |
| 6531 |
#define SSL_R_DUPLICATE_SIGNATURE_ALGORITHM 296 |
| 6532 |
#define SSL_R_TLS13_DOWNGRADE 297 |
| 6533 |
#define SSL_R_QUIC_INTERNAL_ERROR 298 |
| 6534 |
#define SSL_R_WRONG_ENCRYPTION_LEVEL_RECEIVED 299 |
| 6535 |
#define SSL_R_TOO_MUCH_READ_EARLY_DATA 300 |
| 6536 |
#define SSL_R_INVALID_DELEGATED_CREDENTIAL 301 |
| 6537 |
#define SSL_R_KEY_USAGE_BIT_INCORRECT 302 |
| 6538 |
#define SSL_R_INCONSISTENT_CLIENT_HELLO 303 |
| 6539 |
#define SSL_R_CIPHER_MISMATCH_ON_EARLY_DATA 304 |
| 6540 |
#define SSL_R_QUIC_TRANSPORT_PARAMETERS_MISCONFIGURED 305 |
| 6541 |
#define SSL_R_UNEXPECTED_COMPATIBILITY_MODE 306 |
| 6542 |
#define SSL_R_NO_APPLICATION_PROTOCOL 307 |
| 6543 |
#define SSL_R_NEGOTIATED_ALPS_WITHOUT_ALPN 308 |
| 6544 |
#define SSL_R_ALPS_MISMATCH_ON_EARLY_DATA 309 |
| 6545 |
#define SSL_R_ECH_SERVER_CONFIG_AND_PRIVATE_KEY_MISMATCH 310 |
| 6546 |
#define SSL_R_ECH_SERVER_CONFIG_UNSUPPORTED_EXTENSION 311 |
| 6547 |
#define SSL_R_UNSUPPORTED_ECH_SERVER_CONFIG 312 |
| 6548 |
#define SSL_R_ECH_SERVER_WOULD_HAVE_NO_RETRY_CONFIGS 313 |
| 6549 |
#define SSL_R_INVALID_CLIENT_HELLO_INNER 314 |
| 6550 |
#define SSL_R_INVALID_ALPN_PROTOCOL_LIST 315 |
| 6551 |
#define SSL_R_COULD_NOT_PARSE_HINTS 316 |
| 6552 |
#define SSL_R_INVALID_ECH_PUBLIC_NAME 317 |
| 6553 |
#define SSL_R_INVALID_ECH_CONFIG_LIST 318 |
| 6554 |
#define SSL_R_ECH_REJECTED 319 |
| 6555 |
#define SSL_R_INVALID_OUTER_EXTENSION 320 |
| 6556 |
#define SSL_R_INCONSISTENT_ECH_NEGOTIATION 321 |
| 6557 |
#define SSL_R_INVALID_ALPS_CODEPOINT 322 |
| 6558 |
#define SSL_R_NOT_REPLACING_CERTIFICATE 323 |
| 6559 |
#define SSL_R_SERIALIZATION_UNSUPPORTED 500 |
| 6560 |
#define SSL_R_SERIALIZATION_INVALID_SSL 501 |
| 6561 |
#define SSL_R_SERIALIZATION_INVALID_SSL_CONFIG 502 |
| 6562 |
#define SSL_R_SERIALIZATION_INVALID_SSL3_STATE 503 |
| 6563 |
#define SSL_R_SERIALIZATION_INVALID_SSL_BUFFER 505 |
| 6564 |
#define SSL_R_SERIALIZATION_INVALID_SSL_AEAD_CONTEXT 506 |
| 6565 |
#define SSL_R_BAD_HYBRID_KEYSHARE 507 |
| 6566 |
#define SSL_R_BAD_KEM_CIPHERTEXT 508 |
| 6567 |
#define SSL_R_SSLV3_ALERT_CLOSE_NOTIFY 1000 |
| 6568 |
#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 |
| 6569 |
#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 |
| 6570 |
#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 |
| 6571 |
#define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 |
| 6572 |
#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 |
| 6573 |
#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 |
| 6574 |
#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 |
| 6575 |
#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 |
| 6576 |
#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 |
| 6577 |
#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 |
| 6578 |
#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 |
| 6579 |
#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 |
| 6580 |
#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 |
| 6581 |
#define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 |
| 6582 |
#define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 |
| 6583 |
#define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 |
| 6584 |
#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 |
| 6585 |
#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 |
| 6586 |
#define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 |
| 6587 |
#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 |
| 6588 |
#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 |
| 6589 |
#define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086 |
| 6590 |
#define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 |
| 6591 |
#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 |
| 6592 |
#define SSL_R_TLSV1_ALERT_UNSUPPORTED_EXTENSION 1110 |
| 6593 |
#define SSL_R_TLSV1_ALERT_CERTIFICATE_UNOBTAINABLE 1111 |
| 6594 |
#define SSL_R_TLSV1_ALERT_UNRECOGNIZED_NAME 1112 |
| 6595 |
#define SSL_R_TLSV1_ALERT_BAD_CERTIFICATE_STATUS_RESPONSE 1113 |
| 6596 |
#define SSL_R_TLSV1_ALERT_BAD_CERTIFICATE_HASH_VALUE 1114 |
| 6597 |
#define SSL_R_TLSV1_ALERT_UNKNOWN_PSK_IDENTITY 1115 |
| 6598 |
#define SSL_R_TLSV1_ALERT_CERTIFICATE_REQUIRED 1116 |
| 6599 |
#define SSL_R_TLSV1_ALERT_NO_APPLICATION_PROTOCOL 1120 |
| 6600 |
#define SSL_R_TLSV1_ALERT_ECH_REQUIRED 1121 |
| 6601 |
#define SSL_R_SERIALIZATION_INVALID_SERDE_VERSION 1122 |
| 6602 |
|
| 6603 |
#endif // OPENSSL_HEADER_SSL_H |