aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/crypto/memcmp.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-10-22 09:16:38 -0700
committerSteven Fackler <[email protected]>2016-10-22 09:16:38 -0700
commit98b7f2f9352e4d92b44245d0737f9a45adb4ae2b (patch)
tree983929f8b6cd8be9e42e226ac74a5ddc5f29ccd5 /openssl/src/crypto/memcmp.rs
parentProperly propagate panics (diff)
downloadrust-openssl-98b7f2f9352e4d92b44245d0737f9a45adb4ae2b.tar.xz
rust-openssl-98b7f2f9352e4d92b44245d0737f9a45adb4ae2b.zip
Flatten crypto module
Diffstat (limited to 'openssl/src/crypto/memcmp.rs')
-rw-r--r--openssl/src/crypto/memcmp.rs39
1 files changed, 0 insertions, 39 deletions
diff --git a/openssl/src/crypto/memcmp.rs b/openssl/src/crypto/memcmp.rs
deleted file mode 100644
index cf08bdb5..00000000
--- a/openssl/src/crypto/memcmp.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-use libc::size_t;
-use ffi;
-
-/// Returns `true` iff `a` and `b` contain the same bytes.
-///
-/// This operation takes an amount of time dependent on the length of the two
-/// arrays given, but is independent of the contents of a and b.
-///
-/// # Failure
-///
-/// This function will panic the current task if `a` and `b` do not have the same
-/// length.
-pub fn eq(a: &[u8], b: &[u8]) -> bool {
- assert!(a.len() == b.len());
- let ret = unsafe {
- ffi::CRYPTO_memcmp(a.as_ptr() as *const _,
- b.as_ptr() as *const _,
- a.len() as size_t)
- };
- ret == 0
-}
-
-#[cfg(test)]
-mod tests {
- use super::eq;
-
- #[test]
- fn test_eq() {
- assert!(eq(&[], &[]));
- assert!(eq(&[1], &[1]));
- assert!(!eq(&[1, 2, 3], &[1, 2, 4]));
- }
-
- #[test]
- #[should_panic]
- fn test_diff_lens() {
- eq(&[], &[1]);
- }
-}