Skip to main content

ribergshamra_crypto/
lib.rs

1#![forbid(unsafe_code)]
2
3//! Cryptographic algorithm implementations for ribergshamra XML Security library.
4//!
5//! Provides traits and implementations for all crypto operations needed by
6//! XML-DSig and XML-Enc: digests, signatures, block ciphers, key wrapping,
7//! and key transport.
8
9pub mod cipher;
10pub mod digest;
11pub mod kdf;
12pub mod keyagreement;
13pub mod keytransport;
14pub mod keywrap;
15pub mod registry;
16pub mod sign;
17
18pub use digest::DigestAlgorithm;
19pub use registry::AlgorithmRegistry;
20
21/// Convert a `riptering::Error` to a `ribergshamra_core::Error`.
22pub(crate) fn map_riptering_err(e: riptering::Error) -> ribergshamra_core::Error {
23    match e {
24        riptering::Error::Crypto(s) => ribergshamra_core::Error::Crypto(s),
25        err @ riptering::Error::UnsupportedAlgorithm { .. } => {
26            ribergshamra_core::Error::UnsupportedAlgorithm(err.to_string())
27        }
28        riptering::Error::Key(s) => ribergshamra_core::Error::Key(s),
29        riptering::Error::Io(e) => ribergshamra_core::Error::Io(e),
30        // Handle additional error variants (e.g., Pkcs11) when the riptering
31        // crate is compiled with optional features.
32        #[allow(unreachable_patterns)]
33        other => ribergshamra_core::Error::Crypto(other.to_string()),
34    }
35}