Function bearssl::br_rsa_ssl_decrypt [] [src]

pub unsafe extern "C" fn br_rsa_ssl_decrypt(
    core: br_rsa_private,
    sk: *const br_rsa_private_key,
    data: *mut c_uchar,
    len: usize
) -> u32

\brief RSA decryption helper, for SSL/TLS.

This function performs the RSA decryption for a RSA-based key exchange in a SSL/TLS server. The provided RSA engine is used. The data parameter points to the value to decrypt, of length len bytes. On success, the 48-byte pre-master secret is copied into data, starting at the first byte of that buffer; on error, the contents of data become indeterminate.

This function first checks that the provided value length (len) is not lower than 59 bytes, and matches the RSA modulus length; if neither of this property is met, then this function returns 0 and the buffer is unmodified.

Otherwise, decryption and then padding verification are performed, both in constant-time. A decryption error, or a bad padding, or an incorrect decrypted value length are reported with a returned value of 0; on success, 1 is returned. The caller (SSL server engine) is supposed to proceed with a random pre-master secret in case of error.

\param core RSA private key engine. \param sk RSA private key. \param data input/output buffer. \param len length (in bytes) of the data to decrypt. \return 1 on success, 0 on error.