Implement constant time equal check for admin, 2fa recover and 2fa remember tokens

This commit is contained in:
Daniel García
2019-02-11 23:45:55 +01:00
parent bbe2a1b264
commit 9636f33fdb
4 changed files with 13 additions and 3 deletions

View File

@ -36,3 +36,12 @@ pub fn get_random(mut array: Vec<u8>) -> Vec<u8> {
array
}
//
// Constant time compare
//
pub fn ct_eq<T: AsRef<[u8]>, U: AsRef<[u8]>>(a: T, b: U) -> bool {
use ring::constant_time::verify_slices_are_equal;
verify_slices_are_equal(a.as_ref(), b.as_ref()).is_ok()
}