Merge pull request #41 from untoldwind/master

Ensure that all data of StaticSecret is cleared on drop
This commit is contained in:
Henry de Valence 2019-04-23 10:08:40 -07:00 committed by GitHub
commit 1cc37a1eda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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.