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.