summaryrefslogtreecommitdiffstats
path: root/openpgp/src/parse
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-06-28 14:04:03 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-06-28 14:04:03 +0200
commit1027bf4c28ea61f28c3f7aaac941c45388efedc5 (patch)
treec9b6aa651d72090393025801dc0ecc5076d2f786 /openpgp/src/parse
parent1525eec1426a6a34b84809179d784e5cee3e8bfa (diff)
openpgp: Move MPI::decode_point() to crypto::mpis.
Diffstat (limited to 'openpgp/src/parse')
-rw-r--r--openpgp/src/parse/parse.rs62
1 files changed, 0 insertions, 62 deletions
diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs
index 5ff6d599..cb2a1fb7 100644
--- a/openpgp/src/parse/parse.rs
+++ b/openpgp/src/parse/parse.rs
@@ -31,7 +31,6 @@ use {
use constants::{
AEADAlgorithm,
CompressionAlgorithm,
- Curve,
SignatureType,
HashAlgorithm,
PublicKeyAlgorithm,
@@ -1998,67 +1997,6 @@ impl MPI {
php.parse_bytes(name, bytes).expect("worked before");
Ok(value.into())
}
-
- /// Dissects this MPI describing a point into the individual
- /// coordinates.
- ///
- /// # Errors
- ///
- /// Returns `Error::UnsupportedEllipticCurve` if the curve is not
- /// supported, `Error::InvalidArgument` if the point is
- /// formatted incorrectly.
- pub fn decode_point(&self, curve: &Curve) -> Result<(&[u8], &[u8])> {
- use nettle::{ed25519, curve25519};
- use self::Curve::*;
- match &curve {
- Ed25519 | Cv25519 => {
- assert_eq!(curve25519::CURVE25519_SIZE,
- ed25519::ED25519_KEY_SIZE);
- // This curve uses a custom compression format which
- // only contains the X coordinate.
- if self.value().len() != 1 + curve25519::CURVE25519_SIZE {
- return Err(Error::MalformedPacket(
- format!("Bad size of Curve25519 key: {} expected: {}",
- self.value().len(),
- 1 + curve25519::CURVE25519_SIZE)).into());
- }
-
- if self.value().get(0).map(|&b| b != 0x40).unwrap_or(true) {
- return Err(Error::MalformedPacket(
- "Bad encoding of Curve25519 key".into()).into());
- }
-
- Ok((&self.value()[1..], &[]))
- },
-
- _ => {
-
- // Length of one coordinate in bytes, rounded up.
- let coordinate_length = (curve.len()? + 7) / 8;
-
- // Check length of Q.
- let expected_length =
- 1 // 0x04.
- + (2 // (x, y)
- * coordinate_length);
-
- if self.value().len() != expected_length {
- return Err(Error::InvalidArgument(
- format!("Invalid length of MPI: {} (expected {})",
- self.value().len(), expected_length)).into());
- }
-
- if self.value().get(0).map(|&b| b != 0x04).unwrap_or(true) {
- return Err(Error::InvalidArgument(
- format!("Bad prefix: {:?} (expected Some(0x04))",
- self.value().get(0))).into());
- }
-
- Ok((&self.value()[1..1 + coordinate_length],
- &self.value()[1 + coordinate_length..]))
- },
- }
- }
}
impl<'a> Parse<'a, MPI> for MPI {