diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-08-14 10:40:33 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-08-14 10:40:33 +0200 |
commit | 5598be77d1d9bbbbd5347d5f2bf9d1312ebe4a63 (patch) | |
tree | dbc879af7fbdc39541df0b88f719d939ea8fa3b6 /openpgp/src/types | |
parent | 4c34450ef5b6f261f1dedd0117875f03d22e3dc8 (diff) |
openpgp: Fix Curve::arbitrary.
- Make sure not to generate unknown curves with OIDs exceeding 255
bytes as OpenPGP cannot represent those.
- Fixes #542 and #543.
Diffstat (limited to 'openpgp/src/types')
-rw-r--r-- | openpgp/src/types/mod.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs index 8bc4009e..dedc5af7 100644 --- a/openpgp/src/types/mod.rs +++ b/openpgp/src/types/mod.rs @@ -519,7 +519,11 @@ impl Arbitrary for Curve { 4 => Curve::BrainpoolP512, 5 => Curve::Ed25519, 6 => Curve::Cv25519, - 7 => Curve::Unknown(Vec::<u8>::arbitrary(g).into_boxed_slice()), + 7 => Curve::Unknown({ + let mut k = <Vec<u8>>::arbitrary(g); + k.truncate(255); + k.into_boxed_slice() + }), _ => unreachable!(), } } |