summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/mod.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2018-10-23 16:27:01 +0200
committerJustus Winter <justus@sequoia-pgp.org>2018-10-23 16:27:01 +0200
commit3cc85231c0fa10718967be314854ee6b50a75cde (patch)
tree689975a672538a1df999b08bba14118466201eec /openpgp/src/crypto/mod.rs
parent194e2a8f63f38bd44340090f2fc121d4dcd24cd7 (diff)
openpgp: Move sequre_eq to openpgp::crypto.
Diffstat (limited to 'openpgp/src/crypto/mod.rs')
-rw-r--r--openpgp/src/crypto/mod.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs
index ce9dfbca..edfe98bf 100644
--- a/openpgp/src/crypto/mod.rs
+++ b/openpgp/src/crypto/mod.rs
@@ -161,3 +161,8 @@ fn hash_file_test() {
}
}
+/// Time-constant comparison.
+fn secure_eq(a: &[u8], b: &[u8]) -> bool {
+ a.len() == b.len() &&
+ unsafe { memsec::memeq(a.as_ptr(), b.as_ptr(), a.len()) }
+}