From 8cda810ce19e77387af89aa9edda2d5481098432 Mon Sep 17 00:00:00 2001 From: Kyle Kotowick Date: Mon, 30 Sep 2024 17:05:02 +0000 Subject: [PATCH 1/3] Add Dilithium COSE algorithm IDs --- src/webauthn.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/webauthn.rs b/src/webauthn.rs index 48d4dc6..37c3f94 100644 --- a/src/webauthn.rs +++ b/src/webauthn.rs @@ -158,9 +158,13 @@ pub enum UnknownPKCredentialParam { pub const ES256: i32 = -7; /// EdDSA pub const ED_DSA: i32 = -8; +/// Dilithium2 +pub const DILITHIUM2: i32 = -87; +pub const DILITHIUM3: i32 = -88; +pub const DILITHIUM5: i32 = -89; -pub const COUNT_KNOWN_ALGS: usize = 2; -pub const KNOWN_ALGS: [i32; COUNT_KNOWN_ALGS] = [ES256, ED_DSA]; +pub const COUNT_KNOWN_ALGS: usize = 5; +pub const KNOWN_ALGS: [i32; COUNT_KNOWN_ALGS] = [ES256, ED_DSA, DILITHIUM2, DILITHIUM3, DILITHIUM5]; impl TryFrom for KnownPublicKeyCredentialParameters { type Error = UnknownPKCredentialParam; From b6f0c5a265f5b21711da3a63ae1afa5191753129 Mon Sep 17 00:00:00 2001 From: Kyle Kotowick Date: Tue, 1 Oct 2024 03:18:56 +0000 Subject: [PATCH 2/3] Add Dilithium algorithms --- Cargo.toml | 6 +++++- src/webauthn.rs | 31 +++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e3a43cf..e9b8b66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,9 +36,13 @@ get-info-full = [] large-blobs = [] third-party-payment = [] +backend-dilithium2 = [] +backend-dilithium3 = [] +backend-dilithium5 = [] + log-all = [] log-none = [] log-info = [] log-debug = [] log-warn = [] -log-error = [] +log-error = [] \ No newline at end of file diff --git a/src/webauthn.rs b/src/webauthn.rs index 37c3f94..072b929 100644 --- a/src/webauthn.rs +++ b/src/webauthn.rs @@ -159,12 +159,39 @@ pub const ES256: i32 = -7; /// EdDSA pub const ED_DSA: i32 = -8; /// Dilithium2 +#[cfg(feature = "backend-dilithium2")] pub const DILITHIUM2: i32 = -87; +#[cfg(feature = "backend-dilithium3")] pub const DILITHIUM3: i32 = -88; +#[cfg(feature = "backend-dilithium5")] pub const DILITHIUM5: i32 = -89; -pub const COUNT_KNOWN_ALGS: usize = 5; -pub const KNOWN_ALGS: [i32; COUNT_KNOWN_ALGS] = [ES256, ED_DSA, DILITHIUM2, DILITHIUM3, DILITHIUM5]; +// Dynamically calculate the number of different known algorithms +pub const COUNT_KNOWN_ALGS: usize = + 2 + (if cfg!(feature = "backend-dilithium2") { + 1 + } else { + 0 + }) + (if cfg!(feature = "backend-dilithium3") { + 1 + } else { + 0 + }) + (if cfg!(feature = "backend-dilithium5") { + 1 + } else { + 0 + }); + +pub const KNOWN_ALGS: [i32; COUNT_KNOWN_ALGS] = [ + ES256, + ED_DSA, + #[cfg(feature = "backend-dilithium2")] + DILITHIUM2, + #[cfg(feature = "backend-dilithium3")] + DILITHIUM3, + #[cfg(feature = "backend-dilithium5")] + DILITHIUM5, +]; impl TryFrom for KnownPublicKeyCredentialParameters { type Error = UnknownPKCredentialParam; From b7a4259d07bd2064c7eadb0aa985ecfac155c6b1 Mon Sep 17 00:00:00 2001 From: Kyle Kotowick Date: Sun, 27 Oct 2024 22:39:23 -0400 Subject: [PATCH 3/3] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e9b8b66..629cb23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,4 +45,4 @@ log-none = [] log-info = [] log-debug = [] log-warn = [] -log-error = [] \ No newline at end of file +log-error = []