Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ hmac-sha1 = []
hmac-sha256 = []
hmac-sha512 = []
mldsa44 = []
mldsa65 = []
mldsa87 = []
mlkem512 = []
mlkem768 = []
mlkem1024 = []
p256 = []
p384 = []
p521 = []
Expand Down
14 changes: 7 additions & 7 deletions core/src/mechanisms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,13 @@ pub trait Ed255: CryptoClient {
}

#[cfg(feature = "mldsa44")]
pub trait Mldsa44: CryptoClient {
pub trait MlDsa44: CryptoClient {
fn generate_mldsa44_private_key(
&mut self,
persistence: Location,
) -> ClientResult<'_, reply::GenerateKey, Self> {
self.generate_key(
Mechanism::Mldsa44,
Mechanism::MlDsa44,
StorageAttributes::new().set_persistence(persistence),
)
}
Expand All @@ -398,7 +398,7 @@ pub trait Mldsa44: CryptoClient {
persistence: Location,
) -> ClientResult<'_, reply::DeriveKey, Self> {
self.derive_key(
Mechanism::Mldsa44,
Mechanism::MlDsa44,
private_key,
None,
StorageAttributes::new().set_persistence(persistence),
Expand All @@ -411,15 +411,15 @@ pub trait Mldsa44: CryptoClient {
format: KeySerialization,
attributes: StorageAttributes,
) -> ClientResult<'c, reply::DeserializeKey, Self> {
self.deserialize_key(Mechanism::Mldsa44, serialized_key, format, attributes)
self.deserialize_key(Mechanism::MlDsa44, serialized_key, format, attributes)
}

fn serialize_mldsa44_key(
&mut self,
key: KeyId,
format: KeySerialization,
) -> ClientResult<'_, reply::SerializeKey, Self> {
self.serialize_key(Mechanism::Mldsa44, key, format)
self.serialize_key(Mechanism::MlDsa44, key, format)
}

fn sign_mldsa44<'c>(
Expand All @@ -428,7 +428,7 @@ pub trait Mldsa44: CryptoClient {
message: &[u8],
) -> ClientResult<'c, reply::Sign, Self> {
self.sign(
Mechanism::Mldsa44,
Mechanism::MlDsa44,
key,
message,
SignatureSerialization::Raw,
Expand All @@ -442,7 +442,7 @@ pub trait Mldsa44: CryptoClient {
signature: &[u8],
) -> ClientResult<'c, reply::Verify, Self> {
self.verify(
Mechanism::Mldsa44,
Mechanism::MlDsa44,
key,
message,
signature,
Expand Down
14 changes: 12 additions & 2 deletions core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ pub enum Location {
External,
}

#[derive(Clone, Eq, PartialEq, Debug)]
#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize)]
#[non_exhaustive]
pub struct StorageAttributes {
// each object must have a unique ID
Expand Down Expand Up @@ -531,7 +531,17 @@ generate_mechanism! {
#[cfg(feature = "hmac-sha512")]
HmacSha512,
#[cfg(feature = "mldsa44")]
Mldsa44,
MlDsa44,
#[cfg(feature = "mldsa65")]
MlDsa65,
#[cfg(feature = "mldsa87")]
MlDsa87,
#[cfg(feature = "mlkem512")]
MlKem512,
#[cfg(feature = "mlkem768")]
MlKem768,
#[cfg(feature = "mlkem1024")]
MlKem1024,
// P256XSha256,
#[cfg(feature = "p256")]
P256,
Expand Down
18 changes: 18 additions & 0 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ pub enum Kind {
BrainpoolP512R1,
X255,
Secp256k1,
MlDsa44,
MlDsa65,
MlDsa87,
MlKem512,
MlKem768,
MlKem1024,
}

bitflags::bitflags! {
Expand Down Expand Up @@ -219,6 +225,12 @@ impl Kind {
Kind::BrainpoolP384R1 => 13,
Kind::BrainpoolP512R1 => 14,
Kind::Secp256k1 => 15,
Kind::MlDsa44 => 16,
Kind::MlDsa65 => 17,
Kind::MlDsa87 => 18,
Kind::MlKem512 => 19,
Kind::MlKem768 => 20,
Kind::MlKem1024 => 21,
}
}

Expand All @@ -239,6 +251,12 @@ impl Kind {
13 => Kind::BrainpoolP384R1,
14 => Kind::BrainpoolP512R1,
15 => Kind::Secp256k1,
16 => Kind::MlDsa44,
17 => Kind::MlDsa65,
18 => Kind::MlDsa87,
19 => Kind::MlKem512,
20 => Kind::MlKem768,
21 => Kind::MlKem1024,
_ => return Err(Error::InvalidSerializedKey),
})
}
Expand Down
Loading