Struct jwt_compact::alg::StrongKey
source · pub struct StrongKey<T>(/* private fields */);
Expand description
Wrapper around keys allowing to enforce key strength requirements.
The wrapper signifies that the key has supported strength as per the corresponding
algorithm spec. For example, RSA keys must have length at least 2,048 bits per RFC 7518.
Likewise, HS*
keys must have at least the length of the hash output
(e.g., 32 bytes for HS256
). Since these requirements sometimes clash with backward
compatibility (and sometimes a lesser level of security is enough),
notion of key strength is implemented in such an opt-in, composable way.
It’s easy to convert a StrongKey<T>
to T
via into_inner()
or to
access &T
via AsRef
impl. In contrast, the reverse transformation is fallible, and
is defined with the help of TryFrom
. The error type for TryFrom
is WeakKeyError
,
a simple wrapper around a weak key.
Examples
See StrongAlg
docs for an example of usage.
Implementations§
source§impl StrongKey<RsaPrivateKey>
impl StrongKey<RsaPrivateKey>
sourcepub fn to_public_key(&self) -> StrongKey<RsaPublicKey>
pub fn to_public_key(&self) -> StrongKey<RsaPublicKey>
Converts this private key to a public key.
source§impl<T> StrongKey<T>
impl<T> StrongKey<T>
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Returns the wrapped value.
Trait Implementations§
source§impl<T: PartialEq> PartialEq for StrongKey<T>
impl<T: PartialEq> PartialEq for StrongKey<T>
source§impl TryFrom<RsaPrivateKey> for StrongKey<RsaPrivateKey>
impl TryFrom<RsaPrivateKey> for StrongKey<RsaPrivateKey>
§type Error = WeakKeyError<RsaPrivateKey>
type Error = WeakKeyError<RsaPrivateKey>
source§impl TryFrom<RsaPublicKey> for StrongKey<RsaPublicKey>
impl TryFrom<RsaPublicKey> for StrongKey<RsaPublicKey>
§type Error = WeakKeyError<RsaPublicKey>
type Error = WeakKeyError<RsaPublicKey>
impl<T: Copy> Copy for StrongKey<T>
impl<T: Eq> Eq for StrongKey<T>
impl<T> StructuralEq for StrongKey<T>
impl<T> StructuralPartialEq for StrongKey<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for StrongKey<T>where
T: RefUnwindSafe,
impl<T> Send for StrongKey<T>where
T: Send,
impl<T> Sync for StrongKey<T>where
T: Sync,
impl<T> Unpin for StrongKey<T>where
T: Unpin,
impl<T> UnwindSafe for StrongKey<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> ToHex for T
impl<T> ToHex for T
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Lower case
letters are used (e.g. f9b4ca
)source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
)