Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ecdsa: bring support for k256, p224 and p384
Signed-off-by: Arthur Gautier <baloo@superbaloo.net>
  • Loading branch information
baloo committed Nov 10, 2024
commit f33323999f46cfddaeff1dba8e2a77bb5933772e
3 changes: 3 additions & 0 deletions cryptoki-rustcrypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ repository = "https://github.com/parallaxsecond/rust-cryptoki"
cryptoki = { path = "../cryptoki", version = "0.6.1" }
der = "0.7.8"
ecdsa = "0.16.9"
p224 = { version = "0.13.2", features = ["pkcs8"] }
p256 = { version = "0.13.2", features = ["pkcs8"] }
p384 = { version = "0.13.0", features = ["pkcs8"] }
k256 = { version = "0.13.2", features = ["pkcs8"] }
rsa = "0.9"
signature = { version = "2.2.0", features = ["digest"] }
sha1 = { version = "0.10", features = ["oid"] }
Expand Down
17 changes: 13 additions & 4 deletions cryptoki-rustcrypto/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,21 @@ pub trait SignAlgorithm: PrimeCurve + CurveArithmetic + AssociatedOid + DigestPr
fn sign_mechanism() -> Mechanism<'static>;
}

impl SignAlgorithm for p256::NistP256 {
fn sign_mechanism() -> Mechanism<'static> {
Mechanism::Ecdsa
}
macro_rules! impl_sign_algorithm {
($ec:ty) => {
impl SignAlgorithm for $ec {
fn sign_mechanism() -> Mechanism<'static> {
Mechanism::Ecdsa
}
}
};
}

impl_sign_algorithm!(p224::NistP224);
impl_sign_algorithm!(p256::NistP256);
impl_sign_algorithm!(p384::NistP384);
impl_sign_algorithm!(k256::Secp256k1);

pub struct Signer<C: SignAlgorithm, S: SessionLike> {
session: S,
private_key: ObjectHandle,
Expand Down