Skip to content

Commit 4a79e9a

Browse files
committed
algorithms: expose AlgorithmFamily
It is available on `DecodingKey`. Since `Validation` ends up masking out keys based on a single family, allow crates to create a list of supported algorithms based on the family in use. See: #297
1 parent 53a3fc2 commit 4a79e9a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/algorithms.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
44

55
use crate::errors::{Error, ErrorKind, Result};
66

7+
/// Supported families of algorithms.
78
#[derive(Debug, Eq, PartialEq, Copy, Clone, Serialize, Deserialize)]
89
pub enum AlgorithmFamily {
910
Hmac,
@@ -88,7 +89,7 @@ impl FromStr for Algorithm {
8889
}
8990

9091
impl Algorithm {
91-
pub(crate) fn family(self) -> AlgorithmFamily {
92+
pub fn family(self) -> AlgorithmFamily {
9293
match self {
9394
Algorithm::HS256 | Algorithm::HS384 | Algorithm::HS512 => AlgorithmFamily::Hmac,
9495
Algorithm::RS256

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ compile_error!(
1313
#[cfg(not(any(feature = "rust_crypto", feature = "aws_lc_rs")))]
1414
compile_error!("at least one of the features \"rust_crypto\" or \"aws_lc_rs\" must be enabled");
1515

16-
pub use algorithms::Algorithm;
16+
pub use algorithms::{Algorithm, AlgorithmFamily};
1717
pub use decoding::{DecodingKey, TokenData, decode, decode_header};
1818
pub use encoding::{EncodingKey, encode};
1919
pub use header::Header;

0 commit comments

Comments
 (0)