Skip to content

Commit

Permalink
add test for fn eq_const_time
Browse files Browse the repository at this point in the history
  • Loading branch information
Taowyoo committed Feb 5, 2024
1 parent c7a596b commit afeb644
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mbedtls/src/ecp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,19 @@ mod tests {
assert_eq!(xr, r);
}

#[test]
fn test_ecp_const_eq() {
let secp256r1 = EcGroup::new(EcGroupId::SecP256R1).unwrap();
let g = secp256r1.generator().unwrap();
let zero = EcPoint::new().unwrap();
assert!(g.eq(&g).unwrap());
assert!(zero.eq(&zero).unwrap());
assert!(!g.eq(&zero).unwrap());
assert!(g.eq_const_time(&g));
assert!(zero.eq_const_time(&zero));
assert!(!g.eq_const_time(&zero));
}

#[test]
fn test_ecp_mul() {
let mut secp256r1 = EcGroup::new(EcGroupId::SecP256R1).unwrap();
Expand Down

0 comments on commit afeb644

Please sign in to comment.