Function s2n_quic::provider::tls::default::ffi::s2n_connection_serialize

source ·
pub unsafe extern "C" fn s2n_connection_serialize(
    conn: *mut s2n_connection,
    buffer: *mut u8,
    buffer_length: u32
) -> i32
Expand description

Serializes the s2n_connection into the provided buffer.

This API takes an established s2n-tls connection object and “serializes” it into a transferable object to be sent off-box or to another process. This transferable object can then be “deserialized” using the s2n_connection_deserialize method to instantiate an s2n-tls connection object that can talk to the original peer with the same encryption keys.

@warning This feature is dangerous because it provides cryptographic material from a TLS session in plaintext. Users MUST both encrypt and MAC the contents of the outputted material to provide secrecy and integrity if this material is transported off-box. DO NOT store or send this material off-box without encryption.

@note You MUST have used s2n_config_set_serialization_version() to set a version on the s2n_config object associated with this connection before this connection began its TLS handshake. @note Call s2n_connection_serialization_length to retrieve the amount of memory needed for the buffer parameter. @note This API will error if the handshake is not yet complete.

@param conn A pointer to the connection object. @param buffer A pointer to the buffer where the serialized connection will be written. @param buffer_length Maximum amount of data that can be written to the buffer param. @returns S2N_SUCCESS on success, S2N_FAILURE on error.