diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-02-16 11:21:35 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-02-16 16:20:30 +0100 |
commit | 0bba1cc38a87b9f7b0a97854a3a6f2503799dcc7 (patch) | |
tree | c53773c7f71e8088a942bcb91c5fe9e5bb7506ed /openpgp/src/crypto/s2k.rs | |
parent | 95d5ef334352c7dfa2a915c52fd939c3eb2117db (diff) |
openpgp: Fix salt generation in impl Arbitrary for S2K.
Diffstat (limited to 'openpgp/src/crypto/s2k.rs')
-rw-r--r-- | openpgp/src/crypto/s2k.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs index c31d6fa2..d60d15e2 100644 --- a/openpgp/src/crypto/s2k.rs +++ b/openpgp/src/crypto/s2k.rs @@ -372,18 +372,26 @@ impl fmt::Display for S2K { #[cfg(test)] impl Arbitrary for S2K { fn arbitrary(g: &mut Gen) -> Self { - use crate::arbitrary_helper::gen_arbitrary_from_range; + use crate::arbitrary_helper::*; #[allow(deprecated)] match gen_arbitrary_from_range(0..7, g) { 0 => S2K::Simple{ hash: HashAlgorithm::arbitrary(g) }, 1 => S2K::Salted{ hash: HashAlgorithm::arbitrary(g), - salt: [<u8>::arbitrary(g); 8], + salt: { + let mut salt = [0u8; 8]; + arbitrary_slice(g, &mut salt); + salt + }, }, 2 => S2K::Iterated{ hash: HashAlgorithm::arbitrary(g), - salt: [<u8>::arbitrary(g); 8], + salt: { + let mut salt = [0u8; 8]; + arbitrary_slice(g, &mut salt); + salt + }, hash_bytes: S2K::nearest_hash_count(Arbitrary::arbitrary(g)), }, 3 => S2K::Private { |