]> git.proxmox.com Git - cargo.git/blobdiff - vendor/openssl/src/pkcs5.rs
New upstream version 0.63.1
[cargo.git] / vendor / openssl / src / pkcs5.rs
index d21a98b1d7f9d4af0657b265708f2dae14c49c25..c15ce477613e41d2fcd4bb5f1302644e1e543056 100644 (file)
@@ -1,11 +1,11 @@
-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 {
@@ -23,7 +23,8 @@ 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,
@@ -81,6 +82,7 @@ pub fn bytes_to_key(
 }
 
 /// 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],
@@ -111,6 +113,7 @@ pub fn pbkdf2_hmac(
 /// 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],
@@ -141,8 +144,8 @@ pub fn scrypt(
 
 #[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
@@ -281,8 +284,6 @@ mod tests {
     #[test]
     #[cfg(any(ossl110))]
     fn scrypt() {
-        use hex;
-
         let pass = "pleaseletmein";
         let salt = "SodiumChloride";
         let expected =