Ensure that all data of StaticSecret is cleared on drop

This commit is contained in:
Bodo Junglas 2019-04-12 08:34:41 +02:00
parent 9567e021c5
commit 0f187b4670
No known key found for this signature in database
GPG key ID: A7C4E6F450E47C3A

View file

@ -164,14 +164,12 @@ impl SharedSecret {
/// # Returns
///
/// A `Scalar`.
fn clamp_scalar(scalar: [u8; 32]) -> Scalar {
let mut s: [u8; 32] = scalar.clone();
fn clamp_scalar(mut scalar: [u8; 32]) -> Scalar {
scalar[0] &= 248;
scalar[31] &= 127;
scalar[31] |= 64;
s[0] &= 248;
s[31] &= 127;
s[31] |= 64;
Scalar::from_bits(s)
Scalar::from_bits(scalar)
}
/// The bare, byte-oriented x25519 function, exactly as specified in RFC7748.