pub fn derive_key(
    out: &mut Secret,
    password: &Secret,
    salt: &Salt,
    ops_limit: usize,
    mem_limit: usize,
) -> Result<()> {
    if unsafe {
        halite_sys::crypto_pwhash_scryptsalsa208sha256(
            out.slice_ptr(),
            out.len() as c_ulonglong,
            password.slice_ptr() as *const c_char,
            password.len() as c_ulonglong,
            salt.0.as_ptr(),
            ops_limit as c_ulonglong,
            mem_limit as c_ulonglong,
        )
    } == 0
    {
        Ok(())
    } else {
        // NOTE: We handle this error gracefully, but in reality (by inspecting the
        // libsodium source code) the only way this can actually fail is if the input
        // password is *enormous*. So, this won't really fail in practice.
        Err(Error::Internal(format!(
            "deriving key from password failed"
        )))
    }
}
/// Hash the given password using the given salt and ops limits, placing the result in the given
/// buffer. Note that the length of "out" is mostly arbitrary.
///
/// The purpose of this is basically to take a password of arbitrary length, and to generate a key
/// of some other length from it.
///
/// Both the input and output here are Secrets, because the key derivation algorithm is not secret.
/// The output, the key, is ostensibly going to be used for encryption, or whatever, so it needs to
/// remain secret. The key derivation algorithm isn't secret, so the output can be trivially
/// derived from the input. Therefore, the input needs to be a Secret as well.
Hash the given password using the given salt and ops limits, placing the result in the given
buffer. Note that the length of "out" is mostly arbitrary.

The purpose of this is basically to take a password of arbitrary length, and to generate a key
of some other length from it.

Both the input and output here are Secrets, because the key derivation algorithm is not secret.
The output, the key, is ostensibly going to be used for encryption, or whatever, so it needs to
remain secret. The key derivation algorithm isn't secret, so the output can be trivially
derived from the input. Therefore, the input needs to be a Secret as well.
Hash the given password using the given salt and ops limits placing the result in the given buffer . Note that the length of " out " is mostly arbitrary . The purpose of this is basically to take a password of arbitrary length and to generate a key of some other length from it . Both the input and output here are Secrets because the key derivation algorithm is not secret . The output the key is ostensibly going to be used for encryption or whatever so it needs to remain secret . The key derivation algorithm isn ' t secret so the output can be trivially derived from the input . Therefore the input needs to be a Secret as well .
pub fn derive_key(
    out: &mut Secret,
    password: &Secret,
    salt: &Salt,
    ops_limit: usize,
    mem_limit: usize,
) -> Result<()> {
    if unsafe {
        halite_sys::crypto_pwhash_scryptsalsa208sha256(
            out.slice_ptr(),
            out.len() as c_ulonglong,
            password.slice_ptr() as *const c_char,
            password.len() as c_ulonglong,
            salt.0.as_ptr(),
            ops_limit as c_ulonglong,
            mem_limit as c_ulonglong,
        )
    } == 0
    {
        Ok(())
    } else {
        // NOTE: We handle this error gracefully, but in reality (by inspecting the
        // libsodium source code) the only way this can actually fail is if the input
        // password is *enormous*. So, this won't really fail in practice.
        Err(Error::Internal(format!(
            "deriving key from password failed"
        )))
    }
}
pub fn derive_key ( out : & mut Secret , password : & Secret , salt : & Salt , ops_limit : usize , mem_limit : usize , ) -> Result < ( ) > { if unsafe { halite_sys :: crypto_pwhash_scryptsalsa208sha256 ( out . slice_ptr ( ) , out . len ( ) as c_ulonglong , password . slice_ptr ( ) as * const c_char , password . len ( ) as c_ulonglong , salt . 0 . as_ptr ( ) , ops_limit as c_ulonglong , mem_limit as c_ulonglong , ) } == 0 { Ok ( ( ) ) } else { // NOTE: We handle this error gracefully, but in reality (by inspecting the // libsodium source code) the only way this can actually fail is if the input // password is *enormous*. So, this won't really fail in practice. Err ( Error :: Internal ( format ! ( " " ) ) ) } }
Hash the given password using the given salt and ops limits, placing the result in the given
buffer.
Hash the given password using the given salt and ops limits placing the result in the given buffer .
out
&mut Secret
password
&Secret
salt
&Salt
ops_limit
usize
mem_limit
usize
out
&mut Secret
password
&Secret
salt
&Salt
ops_limit
usize
mem_limit
usize