pub fn derive_auth_key(secret: &[u8], password: Option<&str>, url: Option<&Url>) -> Vec<u8> {
    // Nothing, or both a password and URL must be given
    assert_eq!(
        password.is_none(),
        url.is_none(),
        "unable to derive authentication key, missing password or URL",
    );

    // Derive a key without a password
    if password.is_none() {
        return hkdf(None, KEY_AUTH_SIZE, secret, Some(b"authentication"));
    }

    // Derive a key with a password and URL
    // TODO: do not expect/unwrap here
    let mut key = vec![0u8; KEY_AUTH_SIZE];
    pbkdf2_hmac(
        password.unwrap().as_bytes(),
        url.unwrap().as_str().as_bytes(),
        KEY_AUTH_ITERATIONS,
        MessageDigest::sha256(),
        &mut key,
    )
    .expect("failed to derive passworded authentication key");

    key
}
/// Derive a key used for authentication, based on the given `secret`.
///
/// A `password` and `url` may be given for special key deriving.
/// At this time this is not implemented however.
Derive a key used for authentication, based on the given `secret`.
A `password` and `url` may be given for special key deriving.
At this time this is not implemented however.
Derive a key used for authentication based on the given ` secret ` . A ` password ` and ` url ` may be given for special key deriving . At this time this is not implemented however .
pub fn derive_auth_key(secret: &[u8], password: Option<&str>, url: Option<&Url>) -> Vec<u8> {
    // Nothing, or both a password and URL must be given
    assert_eq!(
        password.is_none(),
        url.is_none(),
        "unable to derive authentication key, missing password or URL",
    );
    // Derive a key without a password
    if password.is_none() {
        return hkdf(None, KEY_AUTH_SIZE, secret, Some(b"authentication"));
    }
    // Derive a key with a password and URL
    // TODO: do not expect/unwrap here
    let mut key = vec![0u8; KEY_AUTH_SIZE];
    pbkdf2_hmac(
        password.unwrap().as_bytes(),
        url.unwrap().as_str().as_bytes(),
        KEY_AUTH_ITERATIONS,
        MessageDigest::sha256(),
        &mut key,
    )
    .expect("failed to derive passworded authentication key");
    key
}
pub fn derive_auth_key ( secret : & [ u8 ] , password : Option < & str > , url : Option < & Url > ) -> Vec < u8 > { // Nothing, or both a password and URL must be given assert_eq ! ( password is_none ( ) url is_none ( ) " " ) ; // Derive a key without a password if password . is_none ( ) { return hkdf ( None , KEY_AUTH_SIZE , secret , Some ( b" " ) ) ; } // Derive a key with a password and URL // TODO: do not expect/unwrap here let mut key = vec ! [ 0u8 KEY_AUTH_SIZE ] ; pbkdf2_hmac ( password . unwrap ( ) . as_bytes ( ) , url . unwrap ( ) . as_str ( ) . as_bytes ( ) , KEY_AUTH_ITERATIONS , MessageDigest :: sha256 ( ) , & mut key , ) . expect ( " " ) ; key }
Derive a key used for authentication, based on the given `secret`.
Derive a key used for authentication based on the given ` secret ` .
secret
&[u8]
password
Option<&str>
url
Option<&Url>
secret
&[u8]
password
Option<&str>
url
Option<&Url>