Skip to content

Commit 0883198

Browse files
committed
ecdsa: bring support for k256, p224 and p384
Signed-off-by: Arthur Gautier <baloo@superbaloo.net>
1 parent a248888 commit 0883198

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
@@ -89,12 +89,21 @@ pub trait SignAlgorithm: PrimeCurve + CurveArithmetic + AssociatedOid + DigestPr
8989
fn sign_mechanism() -> Mechanism<'static>;
9090
}
9191

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

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

0 commit comments

Comments
 (0)