Tests: quickcheck secure_cmp
@@ -103,6 +103,10 @@ pub fn secure_cmp(a: &[u8], b: &[u8]) -> Result<(), errors::UnknownCryptoError>
}
}
+#[cfg(test)]
+mod tests {
+ use super::*;
+
#[cfg(feature = "safe_api")]
#[test]
fn rand_key_len_ok() {
@@ -154,3 +158,15 @@ fn test_ct_ne_reg() {
assert!(secure_cmp(&[0], &[0, 1]).is_err());
assert!(secure_cmp(&[0, 1], &[0]).is_err());
}
+
+ #[cfg(feature = "safe_api")]
+ quickcheck! {
+ fn prop_secure_cmp(a: Vec<u8>, b: Vec<u8>) -> bool {
+ if a == b {
+ secure_cmp(&a, &b).is_ok()
+ } else {
+ secure_cmp(&a, &b).is_err()
+ }
+ }
+ }
+}
