From 99a29526a501fc8453df5df1342e303f118289ee Mon Sep 17 00:00:00 2001 From: Camille Mougey Date: Thu, 7 Oct 2021 18:22:45 +0200 Subject: [PATCH 1/2] Bump `pem` dependency, introducing PemError --- curve25519-parser/Cargo.toml | 2 +- curve25519-parser/src/lib.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/curve25519-parser/Cargo.toml b/curve25519-parser/Cargo.toml index 9e4fc330..378f3524 100644 --- a/curve25519-parser/Cargo.toml +++ b/curve25519-parser/Cargo.toml @@ -18,7 +18,7 @@ nom = "5" x25519-dalek = "1" curve25519-dalek = "3" sha2 = "0" -pem = "0" +pem = "1" [dependencies.rand_core] version = "0.5" diff --git a/curve25519-parser/src/lib.rs b/curve25519-parser/src/lib.rs index ff0655e6..215292f3 100644 --- a/curve25519-parser/src/lib.rs +++ b/curve25519-parser/src/lib.rs @@ -27,6 +27,8 @@ const X_25519_OID: Oid<'static> = oid!(1.3.101 .110); pub enum Curve25519ParserError { /// BER Parsing error (wrong tag, not enough DER elements, etc.) BerError(der_parser::error::BerError), + /// PEM Parsing error + PemError(pem::PemError), /// Nom parsing error (wrong format, unexpected elements, etc.) NomError(nom::Err), UnknownOid, @@ -39,6 +41,12 @@ impl From for Curve25519ParserError { } } +impl From for Curve25519ParserError { + fn from(error: pem::PemError) -> Self { + Curve25519ParserError::PemError(error) + } +} + impl From> for Curve25519ParserError { fn from(error: nom::Err) -> Self { Curve25519ParserError::NomError(error) @@ -253,7 +261,7 @@ pub fn parse_openssl_25519_pubkeys_pem_many( data: &[u8], ) -> Result, Curve25519ParserError> { let mut output = Vec::new(); - for pem_data in pem::parse_many(data) { + for pem_data in pem::parse_many(data)? { if pem_data.tag.as_bytes() != PUBLIC_TAG { return Err(Curve25519ParserError::InvalidPEMTag); } From 76ccdf82d3e8d29b6880946b8a823311e4324cc4 Mon Sep 17 00:00:00 2001 From: Camille Mougey Date: Thu, 7 Oct 2021 18:23:12 +0200 Subject: [PATCH 2/2] Disable features of dependencies by default --- curve25519-parser/Cargo.toml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/curve25519-parser/Cargo.toml b/curve25519-parser/Cargo.toml index 378f3524..2211b4f3 100644 --- a/curve25519-parser/Cargo.toml +++ b/curve25519-parser/Cargo.toml @@ -12,13 +12,13 @@ readme = "../README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -der-parser = "4" +der-parser = { version = "4", default-features = false} # 'nom' dependency from 'der-parser' -nom = "5" -x25519-dalek = "1" -curve25519-dalek = "3" -sha2 = "0" -pem = "1" +nom = { version = "5", default-features = false} +x25519-dalek = { version = "1", default-features = false} +curve25519-dalek = { version = "3", default-features = false, features = ["u64_backend"]} +sha2 = { version = "0", default-features = false} +pem = { version = "1", default-features = false} [dependencies.rand_core] version = "0.5"