|
@ -4,6 +4,9 @@ use std::str::FromStr; |
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
|
pub enum JwsSignatureAlgorithm {
|
|
|
pub enum JwsSignatureAlgorithm {
|
|
|
|
|
|
Hs256,
|
|
|
|
|
|
Hs384,
|
|
|
|
|
|
Hs512,
|
|
|
Rs256,
|
|
|
Rs256,
|
|
|
Es256,
|
|
|
Es256,
|
|
|
Es384,
|
|
|
Es384,
|
|
@ -18,6 +21,9 @@ impl FromStr for JwsSignatureAlgorithm { |
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Error> {
|
|
|
fn from_str(s: &str) -> Result<Self, Error> {
|
|
|
match s.to_lowercase().as_str() {
|
|
|
match s.to_lowercase().as_str() {
|
|
|
|
|
|
"hs256" => Ok(JwsSignatureAlgorithm::Hs256),
|
|
|
|
|
|
"hs384" => Ok(JwsSignatureAlgorithm::Hs384),
|
|
|
|
|
|
"hs512" => Ok(JwsSignatureAlgorithm::Hs512),
|
|
|
"rs256" => Ok(JwsSignatureAlgorithm::Rs256),
|
|
|
"rs256" => Ok(JwsSignatureAlgorithm::Rs256),
|
|
|
"es256" => Ok(JwsSignatureAlgorithm::Es256),
|
|
|
"es256" => Ok(JwsSignatureAlgorithm::Es256),
|
|
|
"es384" => Ok(JwsSignatureAlgorithm::Es384),
|
|
|
"es384" => Ok(JwsSignatureAlgorithm::Es384),
|
|
@ -33,6 +39,9 @@ impl FromStr for JwsSignatureAlgorithm { |
|
|
impl fmt::Display for JwsSignatureAlgorithm {
|
|
|
impl fmt::Display for JwsSignatureAlgorithm {
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
let s = match self {
|
|
|
let s = match self {
|
|
|
|
|
|
JwsSignatureAlgorithm::Hs256 => "HS256",
|
|
|
|
|
|
JwsSignatureAlgorithm::Hs384 => "HS384",
|
|
|
|
|
|
JwsSignatureAlgorithm::Hs512 => "HS512",
|
|
|
JwsSignatureAlgorithm::Rs256 => "RS256",
|
|
|
JwsSignatureAlgorithm::Rs256 => "RS256",
|
|
|
JwsSignatureAlgorithm::Es256 => "ES256",
|
|
|
JwsSignatureAlgorithm::Es256 => "ES256",
|
|
|
JwsSignatureAlgorithm::Es384 => "ES384",
|
|
|
JwsSignatureAlgorithm::Es384 => "ES384",
|
|
|