diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-08-14 10:43:10 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-08-14 10:43:10 +0200 |
commit | b9593c117c02219248727b664475027d6c4d50d5 (patch) | |
tree | 3c44aeb746fc863063e9aa6f202d28a2b1a28664 /openpgp/src/crypto/mpi.rs | |
parent | 5598be77d1d9bbbbd5347d5f2bf9d1312ebe4a63 (diff) |
openpgp: Fix Ciphertext::arbitrary.
- Make sure not to generate ciphertexts with encrypted session keys
255 bytes as OpenPGP cannot represent those.
- Fixes #544.
Diffstat (limited to 'openpgp/src/crypto/mpi.rs')
-rw-r--r-- | openpgp/src/crypto/mpi.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs index beda6f86..61613a3c 100644 --- a/openpgp/src/crypto/mpi.rs +++ b/openpgp/src/crypto/mpi.rs @@ -897,7 +897,11 @@ impl Arbitrary for Ciphertext { 2 => Ciphertext::ECDH { e: MPI::arbitrary(g), - key: <Vec<u8>>::arbitrary(g).into_boxed_slice() + key: { + let mut k = <Vec<u8>>::arbitrary(g); + k.truncate(255); + k.into_boxed_slice() + }, }, _ => unreachable!(), } |