Skip to content

Commit

Permalink
Merge pull request #106 from ANSSI-FR/curve-deps
Browse files Browse the repository at this point in the history
Update curve-25519parser dependencies
  • Loading branch information
commial authored Oct 8, 2021
2 parents b0ebf73 + 76ccdf8 commit fee24fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 6 additions & 6 deletions curve25519-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "0"
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"
Expand Down
10 changes: 9 additions & 1 deletion curve25519-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<der_parser::error::BerError>),
UnknownOid,
Expand All @@ -39,6 +41,12 @@ impl From<der_parser::error::BerError> for Curve25519ParserError {
}
}

impl From<pem::PemError> for Curve25519ParserError {
fn from(error: pem::PemError) -> Self {
Curve25519ParserError::PemError(error)
}
}

impl From<nom::Err<der_parser::error::BerError>> for Curve25519ParserError {
fn from(error: nom::Err<der_parser::error::BerError>) -> Self {
Curve25519ParserError::NomError(error)
Expand Down Expand Up @@ -253,7 +261,7 @@ pub fn parse_openssl_25519_pubkeys_pem_many(
data: &[u8],
) -> Result<Vec<PublicKey>, 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);
}
Expand Down

0 comments on commit fee24fd

Please sign in to comment.