-use ffi;
use libc::c_int;
use std::ptr;
-use cvt;
-use error::ErrorStack;
-use hash::MessageDigest;
-use symm::Cipher;
+use crate::cvt;
+use crate::error::ErrorStack;
+use crate::hash::MessageDigest;
+use crate::symm::Cipher;
+use openssl_macros::corresponds;
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
pub struct KeyIvPair {
///
/// New applications should not use this and instead use
/// `pbkdf2_hmac` or another more modern key derivation algorithm.
-#[allow(clippy::identity_conversion)]
+#[corresponds(EVP_BytesToKey)]
+#[allow(clippy::useless_conversion)]
pub fn bytes_to_key(
cipher: Cipher,
digest: MessageDigest,
}
/// Derives a key from a password and salt using the PBKDF2-HMAC algorithm with a digest function.
+#[corresponds(PKCS5_PBKDF2_HMAC)]
pub fn pbkdf2_hmac(
pass: &[u8],
salt: &[u8],
/// Derives a key from a password and salt using the scrypt algorithm.
///
/// Requires OpenSSL 1.1.0 or newer.
+#[corresponds(EVP_PBE_scrypt)]
#[cfg(any(ossl110))]
pub fn scrypt(
pass: &[u8],
#[cfg(test)]
mod tests {
- use hash::MessageDigest;
- use symm::Cipher;
+ use crate::hash::MessageDigest;
+ use crate::symm::Cipher;
// Test vectors from
// https://git.lysator.liu.se/nettle/nettle/blob/nettle_3.1.1_release_20150424/testsuite/pbkdf2-test.c
#[test]
#[cfg(any(ossl110))]
fn scrypt() {
- use hex;
-
let pass = "pleaseletmein";
let salt = "SodiumChloride";
let expected =