Struct bearssl::br_ssl_server_policy_class_ [] [src]

#[repr(C)]
pub struct br_ssl_server_policy_class_ { pub context_size: usize, pub choose: Option<unsafe extern "C" fn(_: *mut *const br_ssl_server_policy_class, _: *const br_ssl_server_context, _: *mut br_ssl_server_choices) -> c_int>, pub do_keyx: Option<unsafe extern "C" fn(_: *mut *const br_ssl_server_policy_class, _: *mut c_uchar, _: *mut usize) -> u32>, pub do_sign: Option<unsafe extern "C" fn(_: *mut *const br_ssl_server_policy_class, _: c_uint, _: *mut c_uchar, _: usize, _: usize) -> usize>, }

Fields

\brief Context size (in bytes).

\brief Select algorithms and certificates for this connection.

This callback function shall fill the provided choices structure with the policy choices for this connection. This entails selecting the cipher suite, hash function for signing the ServerKeyExchange (applicable only to ECDHE cipher suites), and certificate chain to send.

The callback receives a pointer to the server context that contains the relevant data. In particular, the functions br_ssl_server_get_client_suites(), br_ssl_server_get_client_hashes() and br_ssl_server_get_client_curves() can be used to obtain the cipher suites, hash functions and elliptic curves supported by both the client and server, respectively. The br_ssl_engine_get_version() and br_ssl_engine_get_server_name() functions yield the protocol version and requested server name (SNI), respectively.

This function may modify its context structure (pctx) in arbitrary ways to keep track of its own choices.

This function shall return 1 if appropriate policy choices could be made, or 0 if this connection cannot be pursued.

\param pctx policy context. \param cc SSL server context. \param choices destination structure for the policy choices. \return 1 on success, 0 on error.

\brief Perform key exchange (server part).

This callback is invoked to perform the server-side cryptographic operation for a key exchange that is not ECDHE. This callback uses the private key.

For RSA key exchange, the provided data (of length *len bytes) shall be decrypted with the server's private key, and the 48-byte premaster secret copied back to the first 48 bytes of data.

  • The caller makes sure that *len is at least 59 bytes.

  • This callback MUST check that the provided length matches that of the key modulus; it shall report an error otherwise.

  • If the length matches that of the RSA key modulus, then processing MUST be constant-time, even if decryption fails, or the padding is incorrect, or the plaintext message length is not exactly 48 bytes.

  • This callback needs not check the two first bytes of the obtained pre-master secret (the caller will do that).

  • If an error is reported (0), then what the callback put in the first 48 bytes of data is unimportant (the caller will use random bytes instead).

For ECDH key exchange, the provided data (of length *len bytes) is the elliptic curve point from the client. The callback shall multiply it with its private key, and store the resulting X coordinate in data, starting at offset 0, and set *len to the length of the X coordinate.

  • If the input array does not have the proper length for an encoded curve point, then an error (0) shall be reported.

  • If the input array has the proper length, then processing MUST be constant-time, even if the data is not a valid encoded point.

  • This callback MUST check that the input point is valid.

Returned value is 1 on success, 0 on error.

\param pctx policy context. \param data key exchange data from the client. \param len key exchange data length (in bytes). \return 1 on success, 0 on error.

\brief Perform a signature (for a ServerKeyExchange message).

This callback function is invoked for ECDHE cipher suites. On input, the hash value or message to sign is in data, of size hv_len; the involved hash function or algorithm is identified by algo_id. The signature shall be computed and written back into data; the total size of that buffer is len bytes.

This callback shall verify that the signature length does not exceed len bytes, and abstain from writing the signature if it does not fit.

The algo_id value matches that which was written in the choices structures by the choose() callback. This will be one of the following:

  • 0xFF00 + id for a hash function identifier id. In that case, the data buffer contains a hash value already computed over the data that is to be signed, of length hv_len. The id may be 0 to designate the special MD5+SHA-1 concatenation (old-style RSA signing).

  • Another value, lower than 0xFF00. The data buffer then contains the raw, non-hashed data to be signed (concatenation of the client and server randoms and ECDH parameters). The callback is responsible to apply any relevant hashing as part of the signing process.

Returned value is the signature length (in bytes), or 0 on error.

\param pctx policy context. \param algo_id hash function / algorithm identifier. \param data input/output buffer (message/hash, then signature). \param hv_len hash value or message length (in bytes). \param len total buffer length (in bytes). \return signature length (in bytes) on success, or 0 on error.

Trait Implementations

impl Debug for br_ssl_server_policy_class_
[src]

[src]

Formats the value using the given formatter.

impl Copy for br_ssl_server_policy_class_
[src]

impl Clone for br_ssl_server_policy_class_
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more