Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dilithium Support #65

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
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
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 = []
37 changes: 34 additions & 3 deletions src/webauthn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,40 @@ pub enum UnknownPKCredentialParam {
pub const ES256: i32 = -7;
/// EdDSA
pub const ED_DSA: i32 = -8;

pub const COUNT_KNOWN_ALGS: usize = 2;
pub const KNOWN_ALGS: [i32; COUNT_KNOWN_ALGS] = [ES256, ED_DSA];
/// 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;

// 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