diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-06-28 10:01:17 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-06-28 10:18:10 +0200 |
commit | 1f1d83d5687a7e2ff21f250117e6f5256fcc38e6 (patch) | |
tree | 919d1fe7a035aaeab1cee0d2d6d5a6327bd91828 /openpgp/src/parse/mpis.rs | |
parent | 06eac62a0619003a317ccc2cccee4c0abcc3eacd (diff) |
openpgp: Add `MPIs::Unknown` for parameters of unknown algorithms.
- Fixes #8.
Diffstat (limited to 'openpgp/src/parse/mpis.rs')
-rw-r--r-- | openpgp/src/parse/mpis.rs | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/openpgp/src/parse/mpis.rs b/openpgp/src/parse/mpis.rs index bf82caa8..99311dc7 100644 --- a/openpgp/src/parse/mpis.rs +++ b/openpgp/src/parse/mpis.rs @@ -125,8 +125,17 @@ impl MPIs { }) } - Unknown(p) | Private(p) => { - Err(Error::UnknownPublicKeyAlgorithm(p.into()).into()) + Unknown(_) | Private(_) => { + let mut mpis = Vec::new(); + while let Ok(mpi) = MPI::parse("unknown_parameter", php) { + mpis.push(mpi); + } + let mut rest = php.parse_bytes_eof("rest")?; + + Ok(MPIs::Unknown { + mpis: mpis.into_boxed_slice(), + rest: rest.into_boxed_slice(), + }) } } } @@ -243,8 +252,17 @@ impl MPIs { scalar: MPI::parse("ecdh_secret", php)? }) } - Unknown(p) | Private(p) => { - Err(Error::UnknownPublicKeyAlgorithm(p.into()).into()) + Unknown(_) | Private(_) => { + let mut mpis = Vec::new(); + while let Ok(mpi) = MPI::parse("unknown_parameter", php) { + mpis.push(mpi); + } + let mut rest = php.parse_bytes_eof("rest")?; + + Ok(MPIs::Unknown { + mpis: mpis.into_boxed_slice(), + rest: rest.into_boxed_slice(), + }) } } } @@ -308,8 +326,17 @@ impl MPIs { }) } - Unknown(p) | Private(p) => { - Err(Error::UnknownPublicKeyAlgorithm(p.into()).into()) + Unknown(_) | Private(_) => { + let mut mpis = Vec::new(); + while let Ok(mpi) = MPI::parse("unknown_parameter", php) { + mpis.push(mpi); + } + let mut rest = php.parse_bytes_eof("rest")?; + + Ok(MPIs::Unknown { + mpis: mpis.into_boxed_slice(), + rest: rest.into_boxed_slice(), + }) } RSASign | DSA | EdDSA | ECDSA => { @@ -398,8 +425,17 @@ impl MPIs { }) } - Unknown(p) | Private(p) => { - Err(Error::UnknownPublicKeyAlgorithm(p.into()).into()) + Unknown(_) | Private(_) => { + let mut mpis = Vec::new(); + while let Ok(mpi) = MPI::parse("unknown_parameter", php) { + mpis.push(mpi); + } + let mut rest = php.parse_bytes_eof("rest")?; + + Ok(MPIs::Unknown { + mpis: mpis.into_boxed_slice(), + rest: rest.into_boxed_slice(), + }) } RSAEncrypt | ElgamalEncrypt | ECDH => { |