Skip to content

Commit

Permalink
Use const_oid crate (#113)
Browse files Browse the repository at this point in the history
Uses types from the `const-oid` crate to define OIDs (optionally, gated
on the `oid` cargo feature)
  • Loading branch information
tarcieri authored Aug 4, 2020
1 parent 837efaf commit 93edc8b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 9 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion k256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ num-traits = "0.2"
criterion = "0.3"

[features]
default = ["arithmetic", "std"]
default = ["arithmetic", "oid", "std"]
arithmetic = []
digest = ["ecdsa-core/digest"]
ecdsa = ["arithmetic", "ecdsa-core/signer", "ecdsa-core/verifier", "rand", "sha256", "zeroize"]
endomorphism-mul = []
field-montgomery = []
force-32-bit = []
oid = ["elliptic-curve/oid"]
rand = ["elliptic-curve/rand_core"]
sha256 = ["digest", "sha2"]
test-vectors = []
Expand Down
10 changes: 7 additions & 3 deletions k256/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ pub use arithmetic::{
AffinePoint, ProjectivePoint,
};

use elliptic_curve::{consts::U32, ObjectIdentifier};
use elliptic_curve::consts::U32;

#[cfg(feature = "oid")]
use elliptic_curve::oid::ObjectIdentifier;

/// K-256 (secp256k1) elliptic curve.
///
Expand All @@ -56,12 +59,13 @@ impl elliptic_curve::Curve for Secp256k1 {
type ElementSize = U32;
}

impl elliptic_curve::weierstrass::Curve for Secp256k1 {}

#[cfg(feature = "oid")]
impl elliptic_curve::Identifier for Secp256k1 {
const OID: ObjectIdentifier = ObjectIdentifier::new(&[1, 3, 132, 0, 10]);
}

impl elliptic_curve::weierstrass::Curve for Secp256k1 {}

/// K-256 (secp256k1) Secret Key.
pub type SecretKey = elliptic_curve::SecretKey<Secp256k1>;

Expand Down
1 change: 1 addition & 0 deletions p256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ proptest = "0.10"
default = ["arithmetic", "std"]
arithmetic = []
ecdsa = ["arithmetic", "ecdsa-core/signer", "ecdsa-core/verifier", "rand", "sha256", "zeroize"]
oid = ["elliptic-curve/oid"]
rand = ["elliptic-curve/rand_core"]
sha256 = ["ecdsa-core/digest", "ecdsa-core/hazmat", "sha2"]
test-vectors = []
Expand Down
10 changes: 7 additions & 3 deletions p256/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ pub use arithmetic::{
#[cfg(all(feature = "arithmetic", feature = "rand"))]
pub use arithmetic::scalar::blinding::BlindedScalar;

use elliptic_curve::{consts::U32, oid::ObjectIdentifier};
use elliptic_curve::consts::U32;

#[cfg(feature = "oid")]
use elliptic_curve::oid::ObjectIdentifier;

/// NIST P-256 elliptic curve.
///
Expand Down Expand Up @@ -64,12 +67,13 @@ impl elliptic_curve::Curve for NistP256 {
type ElementSize = U32;
}

impl elliptic_curve::weierstrass::Curve for NistP256 {}

#[cfg(feature = "oid")]
impl elliptic_curve::Identifier for NistP256 {
const OID: ObjectIdentifier = ObjectIdentifier::new(&[1, 2, 840, 10045, 3, 1, 7]);
}

impl elliptic_curve::weierstrass::Curve for NistP256 {}

/// NIST P-256 Secret Key
pub type SecretKey = elliptic_curve::SecretKey<NistP256>;

Expand Down
1 change: 1 addition & 0 deletions p384/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ version = "0.9"
optional = true

[features]
oid = ["elliptic-curve/oid"]
sha384 = ["ecdsa/digest", "ecdsa/hazmat", "sha2"]
std = ["elliptic-curve/std"]

Expand Down
6 changes: 5 additions & 1 deletion p384/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ pub mod ecdsa;

pub use elliptic_curve;

use elliptic_curve::{consts::U48, ObjectIdentifier};
use elliptic_curve::consts::U48;

#[cfg(feature = "oid")]
use elliptic_curve::oid::ObjectIdentifier;

/// NIST P-384 elliptic curve.
///
Expand Down Expand Up @@ -49,6 +52,7 @@ impl elliptic_curve::Curve for NistP384 {
type ElementSize = U48;
}

#[cfg(feature = "oid")]
impl elliptic_curve::Identifier for NistP384 {
const OID: ObjectIdentifier = ObjectIdentifier::new(&[1, 3, 132, 0, 34]);
}
Expand Down

0 comments on commit 93edc8b

Please sign in to comment.