#[cfg(feature = "hmac-sha2")]
#[cfg_attr(docsrs, doc(cfg(feature = "hmac-sha2")))]
#[path = "sign/rustcrypto/hmac_sha2.rs"]
pub mod hmac_sha2;
#[cfg(feature = "hmac-sha2")]
#[cfg_attr(docsrs, doc(cfg(feature = "hmac-sha2")))]
pub use hmac_sha2::{HS256, HS384, HS512};
#[cfg(feature = "rsa-pkcs1")]
#[cfg_attr(docsrs, doc(cfg(feature = "rsa-pkcs1")))]
#[path = "sign/rustcrypto/rsa_pkcs1.rs"]
pub mod rsa_pkcs1;
#[cfg(feature = "rsa-pkcs1")]
#[cfg_attr(docsrs, doc(cfg(feature = "rsa-pkcs1")))]
pub use rsa_pkcs1::{RS256Public, RS384Public, RS512Public, RS256, RS384, RS512};
#[cfg(feature = "ecdsa")]
#[cfg_attr(docsrs, doc(cfg(feature = "ecdsa")))]
#[path = "sign/rustcrypto/ecdsa.rs"]
pub mod ecdsa;
use crate::util::algorithms_decl;
use crate::{RecommendHeaderParams, ValidateHeaderParams};
algorithms_decl!(
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[non_exhaustive]
SigningAlgorithm;
#[cfg_attr(docsrs, doc(cfg(feature = "hmac-sha2")))]
HS256 {
cfg: #[cfg(feature = "hmac-sha2")];
},
#[cfg_attr(docsrs, doc(cfg(feature = "hmac-sha2")))]
HS384 {
cfg: #[cfg(feature = "hmac-sha2")];
},
#[cfg_attr(docsrs, doc(cfg(feature = "hmac-sha2")))]
HS512 {
cfg: #[cfg(feature = "hmac-sha2")];
},
#[cfg_attr(docsrs, doc(cfg(feature = "rsa-pkcs1")))]
RS256 {
cfg: #[cfg(feature = "rsa-pkcs1")];
},
#[cfg_attr(docsrs, doc(cfg(feature = "rsa-pkcs1")))]
RS384 {
cfg: #[cfg(feature = "rsa-pkcs1")];
},
#[cfg_attr(docsrs, doc(cfg(feature = "rsa-pkcs1")))]
RS512 {
cfg: #[cfg(feature = "rsa-pkcs1")];
},
#[cfg_attr(docsrs, doc(cfg(feature = "ecdsa")))]
ES256 {
cfg: #[cfg(feature = "ecdsa")];
},
#[cfg_attr(docsrs, doc(cfg(feature = "ecdsa")))]
ES384 {
cfg: #[cfg(feature = "ecdsa")];
}
);
pub trait JwsVerifier: ValidateHeaderParams {
fn verify_signature(&self, data: &[u8], signature: &[u8]) -> bool;
}
pub trait JwsSigner: RecommendHeaderParams {
fn sign(&self, data: &[u8]) -> Vec<u8>;
}