Skip to content

Commit

Permalink
feat(packet): add nids to ecccurve
Browse files Browse the repository at this point in the history
Former-commit-id: a04f37a
  • Loading branch information
dignifiedquire committed Jul 5, 2018
1 parent b175ede commit 23c89e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[macro_use]
extern crate nom;
// extern crate openssl;
extern crate base64;
extern crate byteorder;
extern crate crc24;
extern crate openssl;
#[macro_use]
extern crate enum_primitive;
extern crate chrono;
Expand Down
17 changes: 17 additions & 0 deletions src/packet/types/ecc_curve.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use openssl::nid::Nid;

use super::packet::PublicKeyAlgorithm;

#[derive(Clone, Debug, Eq, PartialEq)]
Expand Down Expand Up @@ -29,6 +31,21 @@ impl ECCCurve {
}
}

/// Returns the matching OpenSSL nid for the curve.
pub fn to_nid(&self) -> Option<Nid> {
match *self {
ECCCurve::Curve25519 => None,
ECCCurve::Ed25519 => None,
ECCCurve::P256 => Some(Nid::X9_62_PRIME256V1),
ECCCurve::P384 => None,
ECCCurve::P521 => None,
ECCCurve::BrainpoolP256r1 => None,
ECCCurve::BrainpoolP384r1 => None,
ECCCurve::BrainpoolP512r1 => None,
ECCCurve::Secp256k1 => Some(Nid::SECP256K1),
}
}

/// IETF formatted OID
pub fn oid_str(&self) -> &str {
match *self {
Expand Down

0 comments on commit 23c89e3

Please sign in to comment.