Skip to content

Commit 7a73aad

Browse files
committed
ecdsa: bring support for k256, p224 and p384
Signed-off-by: Arthur Gautier <[email protected]>
1 parent 30e1d77 commit 7a73aad

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

Cargo.lock

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cryptoki-rustcrypto/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ repository = "https://github.com/parallaxsecond/rust-cryptoki"
1414
cryptoki = { path = "../cryptoki", version = "0.6.1" }
1515
der = "0.7.8"
1616
ecdsa = "0.16.9"
17+
p224 = { version = "0.13.2", features = ["pkcs8"] }
1718
p256 = { version = "0.13.2", features = ["pkcs8"] }
19+
p384 = { version = "0.13.0", features = ["pkcs8"] }
20+
k256 = { version = "0.13.2", features = ["pkcs8"] }
1821
rsa = "0.9"
1922
signature = { version = "2.2.0", features = ["digest"] }
2023
sha1 = { version = "0.10", features = ["oid"] }

cryptoki-rustcrypto/src/ecdsa.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,21 @@ pub trait SignAlgorithm: PrimeCurve + CurveArithmetic + AssociatedOid + DigestPr
8888
fn sign_mechanism() -> Mechanism<'static>;
8989
}
9090

91-
impl SignAlgorithm for p256::NistP256 {
92-
fn sign_mechanism() -> Mechanism<'static> {
93-
Mechanism::Ecdsa
94-
}
91+
macro_rules! impl_sign_algorithm {
92+
($ec:ty) => {
93+
impl SignAlgorithm for $ec {
94+
fn sign_mechanism() -> Mechanism<'static> {
95+
Mechanism::Ecdsa
96+
}
97+
}
98+
};
9599
}
96100

101+
impl_sign_algorithm!(p224::NistP224);
102+
impl_sign_algorithm!(p256::NistP256);
103+
impl_sign_algorithm!(p384::NistP384);
104+
impl_sign_algorithm!(k256::Secp256k1);
105+
97106
pub struct Signer<C: SignAlgorithm, S: SessionLike> {
98107
session: S,
99108
private_key: ObjectHandle,

0 commit comments

Comments
 (0)