Skip to content

Commit

Permalink
Add Dilithium algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKotowick committed Oct 28, 2024
1 parent 8cda810 commit b6f0c5a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
31 changes: 29 additions & 2 deletions src/webauthn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PublicKeyCredentialParameters> for KnownPublicKeyCredentialParameters {
type Error = UnknownPKCredentialParam;
Expand Down

0 comments on commit b6f0c5a

Please sign in to comment.