Skip to main content

mbedtls_ssl_session_load

Function mbedtls_ssl_session_load 

Source
pub unsafe extern "C" fn mbedtls_ssl_session_load(
    session: *mut mbedtls_ssl_session,
    buf: *const c_uchar,
    len: usize,
) -> c_int
Expand description

\brief Load serialized session data into a session structure. On client, this can be used for loading saved sessions before resuming them with mbedtls_ssl_set_session(). On server, this can be used for alternative implementations of session cache or session tickets.

\warning The serialized data contains highly sensitive material, including a resumption key (TLS 1.3) or the master secret (TLS 1.2) from which the session’s traffic keys are derived.

            The serialized data is not cryptographically protected.
            It is the responsibility of the user of the
            mbedtls_ssl_session_save() and
            mbedtls_ssl_session_load() APIs to ensure both its
            confidentiality and integrity while stored or transported.

            A breach of confidentiality could result in full compromise
            of the associated TLS session, including loss of
            confidentiality and integrity of past and future
            application data protected under that session.

            A breach of integrity may allow modification of the
            serialized data prior to restoration. As it represents
            trusted internal context, tampering could potentially result
            in arbitrary code execution or other severe compromise of
            the hosting process.

\warning If a peer certificate chain is associated with the session, the serialized state will only contain the peer’s end-entity certificate and the result of the chain verification (unless verification was disabled), but not the rest of the chain.

\see mbedtls_ssl_session_save() \see mbedtls_ssl_set_session()

\param session The session structure to be populated. It must have been initialised with mbedtls_ssl_session_init() but not populated yet. \param buf The buffer holding the serialized session data. It must be a readable buffer of at least \p len bytes. \param len The size of the serialized data in bytes.

\return \c 0 if successful. \return #MBEDTLS_ERR_SSL_ALLOC_FAILED if memory allocation failed. \return #MBEDTLS_ERR_SSL_BAD_INPUT_DATA if input data is invalid. \return #MBEDTLS_ERR_SSL_VERSION_MISMATCH if the serialized data was generated in a different version or configuration of Mbed TLS. \return Another negative value for other kinds of errors (for example, unsupported features in the embedded certificate).