summaryrefslogtreecommitdiffstats
path: root/vendor/commoncrypto/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:47:55 +0000
commit2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4 (patch)
tree033cc839730fda84ff08db877037977be94e5e3a /vendor/commoncrypto/tests
parentInitial commit. (diff)
downloadcargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.tar.xz
cargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.zip
Adding upstream version 0.70.1+ds1.upstream/0.70.1+ds1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/commoncrypto/tests')
-rw-r--r--vendor/commoncrypto/tests/hash.rs18
-rw-r--r--vendor/commoncrypto/tests/pbkdf2.rs16
2 files changed, 34 insertions, 0 deletions
diff --git a/vendor/commoncrypto/tests/hash.rs b/vendor/commoncrypto/tests/hash.rs
new file mode 100644
index 0000000..bccc86c
--- /dev/null
+++ b/vendor/commoncrypto/tests/hash.rs
@@ -0,0 +1,18 @@
+extern crate commoncrypto;
+extern crate hex;
+
+use commoncrypto::hash::{CCDigestAlgorithm, Hasher};
+use hex::ToHex;
+use std::io::Write;
+
+const TO_HASH: &'static str = "The quick brown fox jumps over the lazy dog";
+const TO_HASH_MD5: &'static str = "9e107d9d372bb6826bd81d3542a419d6";
+
+#[test]
+fn md5_hasher() {
+ let mut hasher = Hasher::new(CCDigestAlgorithm::kCCDigestMD5);
+ assert!(hasher.write_all(TO_HASH.as_bytes()).is_ok());
+ let result = hasher.finish();
+ assert!(result.is_ok());
+ assert_eq!(result.expect("Hash failed").to_hex(), TO_HASH_MD5)
+}
diff --git a/vendor/commoncrypto/tests/pbkdf2.rs b/vendor/commoncrypto/tests/pbkdf2.rs
new file mode 100644
index 0000000..179c5ae
--- /dev/null
+++ b/vendor/commoncrypto/tests/pbkdf2.rs
@@ -0,0 +1,16 @@
+extern crate commoncrypto;
+extern crate hex;
+
+use commoncrypto::pbkdf2::{pbkdf2, CCPseudoRandomAlgorithm};
+use hex::ToHex;
+
+#[test]
+fn derive_pbkdf2() {
+ let derived = pbkdf2(b"password",
+ b"salt",
+ CCPseudoRandomAlgorithm::kCCPRFHmacAlgSHA1,
+ 1,
+ 20)
+ .unwrap();
+ assert_eq!("0c60c80f961f0e71f3a9b524af6012062fe037a6", derived.to_hex());
+}