mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Merge pull request #41 from untoldwind/master
Ensure that all data of StaticSecret is cleared on drop
This commit is contained in:
commit
1cc37a1eda
1 changed files with 5 additions and 7 deletions
|
|
@ -164,14 +164,12 @@ impl SharedSecret {
|
||||||
/// # Returns
|
/// # Returns
|
||||||
///
|
///
|
||||||
/// A `Scalar`.
|
/// A `Scalar`.
|
||||||
fn clamp_scalar(scalar: [u8; 32]) -> Scalar {
|
fn clamp_scalar(mut scalar: [u8; 32]) -> Scalar {
|
||||||
let mut s: [u8; 32] = scalar.clone();
|
scalar[0] &= 248;
|
||||||
|
scalar[31] &= 127;
|
||||||
|
scalar[31] |= 64;
|
||||||
|
|
||||||
s[0] &= 248;
|
Scalar::from_bits(scalar)
|
||||||
s[31] &= 127;
|
|
||||||
s[31] |= 64;
|
|
||||||
|
|
||||||
Scalar::from_bits(s)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The bare, byte-oriented x25519 function, exactly as specified in RFC7748.
|
/// The bare, byte-oriented x25519 function, exactly as specified in RFC7748.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue