You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-06 17:25:19 +00:00
Bump mbedTLS to version 2.16 (LTS version)
This commit is contained in:
382
thirdparty/mbedtls/include/mbedtls/ssl.h
vendored
382
thirdparty/mbedtls/include/mbedtls/ssl.h
vendored
@@ -121,6 +121,8 @@
|
||||
#define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600 /**< Couldn't set the hash for verifying CertificateVerify */
|
||||
#define MBEDTLS_ERR_SSL_CONTINUE_PROCESSING -0x6580 /**< Internal-only message signaling that further message-processing should be done */
|
||||
#define MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS -0x6500 /**< The asynchronous operation is not completed yet. */
|
||||
#define MBEDTLS_ERR_SSL_EARLY_MESSAGE -0x6480 /**< Internal-only message signaling that a message arrived early. */
|
||||
#define MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS -0x7000 /**< A cryptographic operation is in progress. Try again later. */
|
||||
|
||||
/*
|
||||
* Various constants
|
||||
@@ -242,6 +244,14 @@
|
||||
#define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Maximum number of heap-allocated bytes for the purpose of
|
||||
* DTLS handshake message reassembly and future message buffering.
|
||||
*/
|
||||
#if !defined(MBEDTLS_SSL_DTLS_MAX_BUFFERING)
|
||||
#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768
|
||||
#endif
|
||||
|
||||
/* \} name SECTION: Module settings */
|
||||
|
||||
/*
|
||||
@@ -1022,14 +1032,14 @@ struct mbedtls_ssl_context
|
||||
int renego_records_seen; /*!< Records since renego request, or with DTLS,
|
||||
number of retransmissions of request if
|
||||
renego_max_records is < 0 */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
||||
|
||||
int major_ver; /*!< equal to MBEDTLS_SSL_MAJOR_VERSION_3 */
|
||||
int minor_ver; /*!< either 0 (SSL3) or 1 (TLS1.0) */
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT)
|
||||
unsigned badmac_seen; /*!< records with a bad MAC received */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
|
||||
|
||||
mbedtls_ssl_send_t *f_send; /*!< Callback for network send */
|
||||
mbedtls_ssl_recv_t *f_recv; /*!< Callback for network receive */
|
||||
@@ -1085,11 +1095,11 @@ struct mbedtls_ssl_context
|
||||
uint16_t in_epoch; /*!< DTLS epoch for incoming records */
|
||||
size_t next_record_offset; /*!< offset of the next record in datagram
|
||||
(equal to in_left if none) */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
|
||||
uint64_t in_window_top; /*!< last validated record seq_num */
|
||||
uint64_t in_window; /*!< bitmask for replay detection */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */
|
||||
|
||||
size_t in_hslen; /*!< current handshake message length,
|
||||
including the handshake header */
|
||||
@@ -1098,6 +1108,11 @@ struct mbedtls_ssl_context
|
||||
int keep_current_message; /*!< drop or reuse current message
|
||||
on next call to record layer? */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
uint8_t disable_datagram_packing; /*!< Disable packing multiple records
|
||||
* within a single datagram. */
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
/*
|
||||
* Record layer (outgoing data)
|
||||
*/
|
||||
@@ -1112,12 +1127,18 @@ struct mbedtls_ssl_context
|
||||
size_t out_msglen; /*!< record header: message length */
|
||||
size_t out_left; /*!< amount of data not yet written */
|
||||
|
||||
unsigned char cur_out_ctr[8]; /*!< Outgoing record sequence number. */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
uint16_t mtu; /*!< path mtu, used to fragment outgoing messages */
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
#if defined(MBEDTLS_ZLIB_SUPPORT)
|
||||
unsigned char *compress_buf; /*!< zlib data buffer */
|
||||
#endif
|
||||
#endif /* MBEDTLS_ZLIB_SUPPORT */
|
||||
#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
|
||||
signed char split_done; /*!< current record already splitted? */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
|
||||
|
||||
/*
|
||||
* PKI layer
|
||||
@@ -1130,11 +1151,11 @@ struct mbedtls_ssl_context
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
char *hostname; /*!< expected peer CN for verification
|
||||
(and SNI if available) */
|
||||
#endif
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_ALPN)
|
||||
const char *alpn_chosen; /*!< negotiated protocol */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_ALPN */
|
||||
|
||||
/*
|
||||
* Information for DTLS hello verify
|
||||
@@ -1142,7 +1163,7 @@ struct mbedtls_ssl_context
|
||||
#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C)
|
||||
unsigned char *cli_id; /*!< transport-level ID of the client */
|
||||
size_t cli_id_len; /*!< length of cli_id */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */
|
||||
|
||||
/*
|
||||
* Secure renegotiation
|
||||
@@ -1154,7 +1175,7 @@ struct mbedtls_ssl_context
|
||||
size_t verify_data_len; /*!< length of verify data stored */
|
||||
char own_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]; /*!< previous handshake verify data */
|
||||
char peer_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]; /*!< previous handshake verify data */
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
||||
};
|
||||
|
||||
#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
|
||||
@@ -1374,6 +1395,52 @@ void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl,
|
||||
mbedtls_ssl_recv_t *f_recv,
|
||||
mbedtls_ssl_recv_timeout_t *f_recv_timeout );
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
/**
|
||||
* \brief Set the Maximum Tranport Unit (MTU).
|
||||
* Special value: 0 means unset (no limit).
|
||||
* This represents the maximum size of a datagram payload
|
||||
* handled by the transport layer (usually UDP) as determined
|
||||
* by the network link and stack. In practice, this controls
|
||||
* the maximum size datagram the DTLS layer will pass to the
|
||||
* \c f_send() callback set using \c mbedtls_ssl_set_bio().
|
||||
*
|
||||
* \note The limit on datagram size is converted to a limit on
|
||||
* record payload by subtracting the current overhead of
|
||||
* encapsulation and encryption/authentication if any.
|
||||
*
|
||||
* \note This can be called at any point during the connection, for
|
||||
* example when a Path Maximum Transfer Unit (PMTU)
|
||||
* estimate becomes available from other sources,
|
||||
* such as lower (or higher) protocol layers.
|
||||
*
|
||||
* \note This setting only controls the size of the packets we send,
|
||||
* and does not restrict the size of the datagrams we're
|
||||
* willing to receive. Client-side, you can request the
|
||||
* server to use smaller records with \c
|
||||
* mbedtls_ssl_conf_max_frag_len().
|
||||
*
|
||||
* \note If both a MTU and a maximum fragment length have been
|
||||
* configured (or negotiated with the peer), the resulting
|
||||
* lower limit on record payload (see first note) is used.
|
||||
*
|
||||
* \note This can only be used to decrease the maximum size
|
||||
* of datagrams (hence records, see first note) sent. It
|
||||
* cannot be used to increase the maximum size of records over
|
||||
* the limit set by #MBEDTLS_SSL_OUT_CONTENT_LEN.
|
||||
*
|
||||
* \note Values lower than the current record layer expansion will
|
||||
* result in an error when trying to send data.
|
||||
*
|
||||
* \note Using record compression together with a non-zero MTU value
|
||||
* will result in an error when trying to send data.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param mtu Value of the path MTU in bytes
|
||||
*/
|
||||
void mbedtls_ssl_set_mtu( mbedtls_ssl_context *ssl, uint16_t mtu );
|
||||
#endif /* MBEDTLS_SSL_PROTO_DTLS */
|
||||
|
||||
/**
|
||||
* \brief Set the timeout period for mbedtls_ssl_read()
|
||||
* (Default: no timeout.)
|
||||
@@ -1757,6 +1824,38 @@ void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limi
|
||||
#endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
|
||||
/**
|
||||
* \brief Allow or disallow packing of multiple handshake records
|
||||
* within a single datagram.
|
||||
*
|
||||
* \param ssl The SSL context to configure.
|
||||
* \param allow_packing This determines whether datagram packing may
|
||||
* be used or not. A value of \c 0 means that every
|
||||
* record will be sent in a separate datagram; a
|
||||
* value of \c 1 means that, if space permits,
|
||||
* multiple handshake messages (including CCS) belonging to
|
||||
* a single flight may be packed within a single datagram.
|
||||
*
|
||||
* \note This is enabled by default and should only be disabled
|
||||
* for test purposes, or if datagram packing causes
|
||||
* interoperability issues with peers that don't support it.
|
||||
*
|
||||
* \note Allowing datagram packing reduces the network load since
|
||||
* there's less overhead if multiple messages share the same
|
||||
* datagram. Also, it increases the handshake efficiency
|
||||
* since messages belonging to a single datagram will not
|
||||
* be reordered in transit, and so future message buffering
|
||||
* or flight retransmission (if no buffering is used) as
|
||||
* means to deal with reordering are needed less frequently.
|
||||
*
|
||||
* \note Application records are not affected by this option and
|
||||
* are currently always sent in separate datagrams.
|
||||
*
|
||||
*/
|
||||
void mbedtls_ssl_set_datagram_packing( mbedtls_ssl_context *ssl,
|
||||
unsigned allow_packing );
|
||||
|
||||
/**
|
||||
* \brief Set retransmit timeout values for the DTLS handshake.
|
||||
* (DTLS only, no effect on TLS.)
|
||||
@@ -1945,6 +2044,14 @@ void mbedtls_ssl_conf_ca_chain( mbedtls_ssl_config *conf,
|
||||
* whether it matches those preferences - the server can then
|
||||
* decide what it wants to do with it.
|
||||
*
|
||||
* \note The provided \p pk_key needs to match the public key in the
|
||||
* first certificate in \p own_cert, or all handshakes using
|
||||
* that certificate will fail. It is your responsibility
|
||||
* to ensure that; this function will not perform any check.
|
||||
* You may use mbedtls_pk_check_pair() in order to perform
|
||||
* this check yourself, but be aware that this function can
|
||||
* be computationally expensive on some key types.
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param own_cert own public certificate chain
|
||||
* \param pk_key own private key
|
||||
@@ -2433,6 +2540,18 @@ void mbedtls_ssl_conf_cert_req_ca_list( mbedtls_ssl_config *conf,
|
||||
* (Client: set maximum fragment length to emit *and*
|
||||
* negotiate with the server during handshake)
|
||||
*
|
||||
* \note With TLS, this currently only affects ApplicationData (sent
|
||||
* with \c mbedtls_ssl_read()), not handshake messages.
|
||||
* With DTLS, this affects both ApplicationData and handshake.
|
||||
*
|
||||
* \note This sets the maximum length for a record's payload,
|
||||
* excluding record overhead that will be added to it, see
|
||||
* \c mbedtls_ssl_get_record_expansion().
|
||||
*
|
||||
* \note For DTLS, it is also possible to set a limit for the total
|
||||
* size of daragrams passed to the transport layer, including
|
||||
* record overhead, see \c mbedtls_ssl_set_mtu().
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param mfl_code Code for maximum fragment length (allowed values:
|
||||
* MBEDTLS_SSL_MAX_FRAG_LEN_512, MBEDTLS_SSL_MAX_FRAG_LEN_1024,
|
||||
@@ -2663,13 +2782,14 @@ size_t mbedtls_ssl_get_bytes_avail( const mbedtls_ssl_context *ssl );
|
||||
/**
|
||||
* \brief Return the result of the certificate verification
|
||||
*
|
||||
* \param ssl SSL context
|
||||
* \param ssl The SSL context to use.
|
||||
*
|
||||
* \return 0 if successful,
|
||||
* -1 if result is not available (eg because the handshake was
|
||||
* aborted too early), or
|
||||
* a combination of BADCERT_xxx and BADCRL_xxx flags, see
|
||||
* x509.h
|
||||
* \return \c 0 if the certificate verification was successful.
|
||||
* \return \c -1u if the result is not available. This may happen
|
||||
* e.g. if the handshake aborts early, or a verification
|
||||
* callback returned a fatal error.
|
||||
* \return A bitwise combination of \c MBEDTLS_X509_BADCERT_XXX
|
||||
* and \c MBEDTLS_X509_BADCRL_XXX failure flags; see x509.h.
|
||||
*/
|
||||
uint32_t mbedtls_ssl_get_verify_result( const mbedtls_ssl_context *ssl );
|
||||
|
||||
@@ -2695,6 +2815,9 @@ const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl );
|
||||
* \brief Return the (maximum) number of bytes added by the record
|
||||
* layer: header + encryption/MAC overhead (inc. padding)
|
||||
*
|
||||
* \note This function is not available (always returns an error)
|
||||
* when record compression is enabled.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return Current maximum record expansion in bytes, or
|
||||
@@ -2709,12 +2832,8 @@ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl );
|
||||
* This is the value negotiated with peer if any,
|
||||
* or the locally configured value.
|
||||
*
|
||||
* \note With DTLS, \c mbedtls_ssl_write() will return an error if
|
||||
* called with a larger length value.
|
||||
* With TLS, \c mbedtls_ssl_write() will fragment the input if
|
||||
* necessary and return the number of bytes written; it is up
|
||||
* to the caller to call \c mbedtls_ssl_write() again in
|
||||
* order to send the remaining bytes if any.
|
||||
* \sa mbedtls_ssl_conf_max_frag_len()
|
||||
* \sa mbedtls_ssl_get_max_record_payload()
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
@@ -2723,6 +2842,34 @@ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl );
|
||||
size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl );
|
||||
#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
|
||||
|
||||
/**
|
||||
* \brief Return the current maximum outgoing record payload in bytes.
|
||||
* This takes into account the config.h setting \c
|
||||
* MBEDTLS_SSL_OUT_CONTENT_LEN, the configured and negotiated
|
||||
* max fragment length extension if used, and for DTLS the
|
||||
* path MTU as configured and current record expansion.
|
||||
*
|
||||
* \note With DTLS, \c mbedtls_ssl_write() will return an error if
|
||||
* called with a larger length value.
|
||||
* With TLS, \c mbedtls_ssl_write() will fragment the input if
|
||||
* necessary and return the number of bytes written; it is up
|
||||
* to the caller to call \c mbedtls_ssl_write() again in
|
||||
* order to send the remaining bytes if any.
|
||||
*
|
||||
* \note This function is not available (always returns an error)
|
||||
* when record compression is enabled.
|
||||
*
|
||||
* \sa mbedtls_ssl_set_mtu()
|
||||
* \sa mbedtls_ssl_get_max_frag_len()
|
||||
* \sa mbedtls_ssl_get_record_expansion()
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return Current maximum payload for an outgoing record,
|
||||
* or a negative error code.
|
||||
*/
|
||||
int mbedtls_ssl_get_max_out_record_payload( const mbedtls_ssl_context *ssl );
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
/**
|
||||
* \brief Return the peer certificate from the current connection
|
||||
@@ -2776,35 +2923,50 @@ int mbedtls_ssl_get_session( const mbedtls_ssl_context *ssl, mbedtls_ssl_session
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return 0 if successful, or
|
||||
* MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE, or
|
||||
* MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED (see below), or
|
||||
* a specific SSL error code.
|
||||
* \return \c 0 if successful.
|
||||
* \return #MBEDTLS_ERR_SSL_WANT_READ or #MBEDTLS_ERR_SSL_WANT_WRITE
|
||||
* if the handshake is incomplete and waiting for data to
|
||||
* be available for reading from or writing to the underlying
|
||||
* transport - in this case you must call this function again
|
||||
* when the underlying transport is ready for the operation.
|
||||
* \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if an asynchronous
|
||||
* operation is in progress (see
|
||||
* mbedtls_ssl_conf_async_private_cb()) - in this case you
|
||||
* must call this function again when the operation is ready.
|
||||
* \return #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS if a cryptographic
|
||||
* operation is in progress (see mbedtls_ecp_set_max_ops()) -
|
||||
* in this case you must call this function again to complete
|
||||
* the handshake when you're done attending other tasks.
|
||||
* \return #MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED if DTLS is in use
|
||||
* and the client did not demonstrate reachability yet - in
|
||||
* this case you must stop using the context (see below).
|
||||
* \return Another SSL error code - in this case you must stop using
|
||||
* the context (see below).
|
||||
*
|
||||
* If this function returns MBEDTLS_ERR_SSL_WANT_READ, the
|
||||
* handshake is unfinished and no further data is available
|
||||
* from the underlying transport. In this case, you must call
|
||||
* the function again at some later stage.
|
||||
* \warning If this function returns something other than
|
||||
* \c 0,
|
||||
* #MBEDTLS_ERR_SSL_WANT_READ,
|
||||
* #MBEDTLS_ERR_SSL_WANT_WRITE,
|
||||
* #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or
|
||||
* #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS,
|
||||
* you must stop using the SSL context for reading or writing,
|
||||
* and either free it or call \c mbedtls_ssl_session_reset()
|
||||
* on it before re-using it for a new connection; the current
|
||||
* connection must be closed.
|
||||
*
|
||||
* \note If DTLS is in use, then you may choose to handle
|
||||
* #MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED specially for logging
|
||||
* purposes, as it is an expected return value rather than an
|
||||
* actual error, but you still need to reset/free the context.
|
||||
*
|
||||
* \note Remarks regarding event-driven DTLS:
|
||||
* If the function returns MBEDTLS_ERR_SSL_WANT_READ, no datagram
|
||||
* If the function returns #MBEDTLS_ERR_SSL_WANT_READ, no datagram
|
||||
* from the underlying transport layer is currently being processed,
|
||||
* and it is safe to idle until the timer or the underlying transport
|
||||
* signal a new event. This is not true for a successful handshake,
|
||||
* in which case the datagram of the underlying transport that is
|
||||
* currently being processed might or might not contain further
|
||||
* DTLS records.
|
||||
*
|
||||
* \note If this function returns something other than 0 or
|
||||
* MBEDTLS_ERR_SSL_WANT_READ/WRITE, you must stop using
|
||||
* the SSL context for reading or writing, and either free it or
|
||||
* call \c mbedtls_ssl_session_reset() on it before re-using it
|
||||
* for a new connection; the current connection must be closed.
|
||||
*
|
||||
* \note If DTLS is in use, then you may choose to handle
|
||||
* MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED specially for logging
|
||||
* purposes, as it is an expected return value rather than an
|
||||
* actual error, but you still need to reset/free the context.
|
||||
*/
|
||||
int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl );
|
||||
|
||||
@@ -2812,20 +2974,21 @@ int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl );
|
||||
* \brief Perform a single step of the SSL handshake
|
||||
*
|
||||
* \note The state of the context (ssl->state) will be at
|
||||
* the next state after execution of this function. Do not
|
||||
* the next state after this function returns \c 0. Do not
|
||||
* call this function if state is MBEDTLS_SSL_HANDSHAKE_OVER.
|
||||
*
|
||||
* \note If this function returns something other than 0 or
|
||||
* MBEDTLS_ERR_SSL_WANT_READ/WRITE, you must stop using
|
||||
* the SSL context for reading or writing, and either free it or
|
||||
* call \c mbedtls_ssl_session_reset() on it before re-using it
|
||||
* for a new connection; the current connection must be closed.
|
||||
*
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return 0 if successful, or
|
||||
* MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE, or
|
||||
* a specific SSL error code.
|
||||
* \return See mbedtls_ssl_handshake().
|
||||
*
|
||||
* \warning If this function returns something other than \c 0,
|
||||
* #MBEDTLS_ERR_SSL_WANT_READ, #MBEDTLS_ERR_SSL_WANT_WRITE,
|
||||
* #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or
|
||||
* #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, you must stop using
|
||||
* the SSL context for reading or writing, and either free it
|
||||
* or call \c mbedtls_ssl_session_reset() on it before
|
||||
* re-using it for a new connection; the current connection
|
||||
* must be closed.
|
||||
*/
|
||||
int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl );
|
||||
|
||||
@@ -2840,13 +3003,18 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl );
|
||||
* \param ssl SSL context
|
||||
*
|
||||
* \return 0 if successful, or any mbedtls_ssl_handshake() return
|
||||
* value.
|
||||
* value except #MBEDTLS_ERR_SSL_CLIENT_RECONNECT that can't
|
||||
* happen during a renegotiation.
|
||||
*
|
||||
* \warning If this function returns something other than \c 0,
|
||||
* #MBEDTLS_ERR_SSL_WANT_READ, #MBEDTLS_ERR_SSL_WANT_WRITE,
|
||||
* #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or
|
||||
* #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, you must stop using
|
||||
* the SSL context for reading or writing, and either free it
|
||||
* or call \c mbedtls_ssl_session_reset() on it before
|
||||
* re-using it for a new connection; the current connection
|
||||
* must be closed.
|
||||
*
|
||||
* \note If this function returns something other than 0 or
|
||||
* MBEDTLS_ERR_SSL_WANT_READ/WRITE, you must stop using
|
||||
* the SSL context for reading or writing, and either free it or
|
||||
* call \c mbedtls_ssl_session_reset() on it before re-using it
|
||||
* for a new connection; the current connection must be closed.
|
||||
*/
|
||||
int mbedtls_ssl_renegotiate( mbedtls_ssl_context *ssl );
|
||||
#endif /* MBEDTLS_SSL_RENEGOTIATION */
|
||||
@@ -2858,42 +3026,56 @@ int mbedtls_ssl_renegotiate( mbedtls_ssl_context *ssl );
|
||||
* \param buf buffer that will hold the data
|
||||
* \param len maximum number of bytes to read
|
||||
*
|
||||
* \return One of the following:
|
||||
* - 0 if the read end of the underlying transport was closed,
|
||||
* - the (positive) number of bytes read, or
|
||||
* - a negative error code on failure.
|
||||
* \return The (positive) number of bytes read if successful.
|
||||
* \return \c 0 if the read end of the underlying transport was closed
|
||||
* - in this case you must stop using the context (see below).
|
||||
* \return #MBEDTLS_ERR_SSL_WANT_READ or #MBEDTLS_ERR_SSL_WANT_WRITE
|
||||
* if the handshake is incomplete and waiting for data to
|
||||
* be available for reading from or writing to the underlying
|
||||
* transport - in this case you must call this function again
|
||||
* when the underlying transport is ready for the operation.
|
||||
* \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if an asynchronous
|
||||
* operation is in progress (see
|
||||
* mbedtls_ssl_conf_async_private_cb()) - in this case you
|
||||
* must call this function again when the operation is ready.
|
||||
* \return #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS if a cryptographic
|
||||
* operation is in progress (see mbedtls_ecp_set_max_ops()) -
|
||||
* in this case you must call this function again to complete
|
||||
* the handshake when you're done attending other tasks.
|
||||
* \return #MBEDTLS_ERR_SSL_CLIENT_RECONNECT if we're at the server
|
||||
* side of a DTLS connection and the client is initiating a
|
||||
* new connection using the same source port. See below.
|
||||
* \return Another SSL error code - in this case you must stop using
|
||||
* the context (see below).
|
||||
*
|
||||
* If MBEDTLS_ERR_SSL_WANT_READ is returned, no application data
|
||||
* is available from the underlying transport. In this case,
|
||||
* the function needs to be called again at some later stage.
|
||||
* \warning If this function returns something other than
|
||||
* a positive value,
|
||||
* #MBEDTLS_ERR_SSL_WANT_READ,
|
||||
* #MBEDTLS_ERR_SSL_WANT_WRITE,
|
||||
* #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS,
|
||||
* #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS or
|
||||
* #MBEDTLS_ERR_SSL_CLIENT_RECONNECT,
|
||||
* you must stop using the SSL context for reading or writing,
|
||||
* and either free it or call \c mbedtls_ssl_session_reset()
|
||||
* on it before re-using it for a new connection; the current
|
||||
* connection must be closed.
|
||||
*
|
||||
* If MBEDTLS_ERR_SSL_WANT_WRITE is returned, a write is pending
|
||||
* but the underlying transport isn't available for writing. In this
|
||||
* case, the function needs to be called again at some later stage.
|
||||
*
|
||||
* When this function return MBEDTLS_ERR_SSL_CLIENT_RECONNECT
|
||||
* \note When this function returns #MBEDTLS_ERR_SSL_CLIENT_RECONNECT
|
||||
* (which can only happen server-side), it means that a client
|
||||
* is initiating a new connection using the same source port.
|
||||
* You can either treat that as a connection close and wait
|
||||
* for the client to resend a ClientHello, or directly
|
||||
* continue with \c mbedtls_ssl_handshake() with the same
|
||||
* context (as it has beeen reset internally). Either way, you
|
||||
* should make sure this is seen by the application as a new
|
||||
* context (as it has been reset internally). Either way, you
|
||||
* must make sure this is seen by the application as a new
|
||||
* connection: application state, if any, should be reset, and
|
||||
* most importantly the identity of the client must be checked
|
||||
* again. WARNING: not validating the identity of the client
|
||||
* again, or not transmitting the new identity to the
|
||||
* application layer, would allow authentication bypass!
|
||||
*
|
||||
* \note If this function returns something other than a positive value
|
||||
* or MBEDTLS_ERR_SSL_WANT_READ/WRITE or MBEDTLS_ERR_SSL_CLIENT_RECONNECT,
|
||||
* you must stop using the SSL context for reading or writing,
|
||||
* and either free it or call \c mbedtls_ssl_session_reset() on it
|
||||
* before re-using it for a new connection; the current connection
|
||||
* must be closed.
|
||||
*
|
||||
* \note Remarks regarding event-driven DTLS:
|
||||
* - If the function returns MBEDTLS_ERR_SSL_WANT_READ, no datagram
|
||||
* - If the function returns #MBEDTLS_ERR_SSL_WANT_READ, no datagram
|
||||
* from the underlying transport layer is currently being processed,
|
||||
* and it is safe to idle until the timer or the underlying transport
|
||||
* signal a new event.
|
||||
@@ -2922,21 +3104,39 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
|
||||
* \param buf buffer holding the data
|
||||
* \param len how many bytes must be written
|
||||
*
|
||||
* \return the number of bytes actually written (may be less than len),
|
||||
* or MBEDTLS_ERR_SSL_WANT_WRITE or MBEDTLS_ERR_SSL_WANT_READ,
|
||||
* or another negative error code.
|
||||
* \return The (non-negative) number of bytes actually written if
|
||||
* successful (may be less than \p len).
|
||||
* \return #MBEDTLS_ERR_SSL_WANT_READ or #MBEDTLS_ERR_SSL_WANT_WRITE
|
||||
* if the handshake is incomplete and waiting for data to
|
||||
* be available for reading from or writing to the underlying
|
||||
* transport - in this case you must call this function again
|
||||
* when the underlying transport is ready for the operation.
|
||||
* \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if an asynchronous
|
||||
* operation is in progress (see
|
||||
* mbedtls_ssl_conf_async_private_cb()) - in this case you
|
||||
* must call this function again when the operation is ready.
|
||||
* \return #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS if a cryptographic
|
||||
* operation is in progress (see mbedtls_ecp_set_max_ops()) -
|
||||
* in this case you must call this function again to complete
|
||||
* the handshake when you're done attending other tasks.
|
||||
* \return Another SSL error code - in this case you must stop using
|
||||
* the context (see below).
|
||||
*
|
||||
* \note If this function returns something other than 0, a positive
|
||||
* value or MBEDTLS_ERR_SSL_WANT_READ/WRITE, you must stop
|
||||
* using the SSL context for reading or writing, and either
|
||||
* free it or call \c mbedtls_ssl_session_reset() on it before
|
||||
* re-using it for a new connection; the current connection
|
||||
* must be closed.
|
||||
* \warning If this function returns something other than
|
||||
* a non-negative value,
|
||||
* #MBEDTLS_ERR_SSL_WANT_READ,
|
||||
* #MBEDTLS_ERR_SSL_WANT_WRITE,
|
||||
* #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or
|
||||
* #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS,
|
||||
* you must stop using the SSL context for reading or writing,
|
||||
* and either free it or call \c mbedtls_ssl_session_reset()
|
||||
* on it before re-using it for a new connection; the current
|
||||
* connection must be closed.
|
||||
*
|
||||
* \note When this function returns MBEDTLS_ERR_SSL_WANT_WRITE/READ,
|
||||
* \note When this function returns #MBEDTLS_ERR_SSL_WANT_WRITE/READ,
|
||||
* it must be called later with the *same* arguments,
|
||||
* until it returns a value greater that or equal to 0. When
|
||||
* the function returns MBEDTLS_ERR_SSL_WANT_WRITE there may be
|
||||
* the function returns #MBEDTLS_ERR_SSL_WANT_WRITE there may be
|
||||
* some partial data in the output buffer, however this is not
|
||||
* yet sent.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user