pub struct CoseVerifyKey { /* private fields */ }Expand description
A key a message may be verified with, bound to exactly one algorithm.
Opaque: built from bytes (ed25519,
p256_sec1, hmac,
hmac_from_secret) and read back as
bytes (ed25519_bytes,
p256_sec1_uncompressed), so no
ed25519-dalek or p256 type is part of this crate’s public API and
either can be upgraded without a breaking change.
Internally an enum over key types, not a bag of bytes, so the classic COSE/JOSE mistake is unrepresentable: an Ed25519 public key can never be used as an HMAC secret (an attacker who knows the public key could otherwise MAC anything with it), and a P-256 key can never verify an Ed25519 signature.
One key, one algorithm. An HMAC key carries the algorithm it was
configured for, and supports matches it exactly:
a secret deployed for HMAC 256/256 never accepts a 64-bit HMAC 256/64
tag, which a sender could otherwise pick to cut a forger’s work from
2²⁵⁶ to 2⁶⁴ online attempts. (The two share a kid: RFC 9679’s
symmetric thumbprint covers only the secret. A deployment that wants
both lists the secret twice, once per algorithm.)
The RFC 9679 thumbprint is computed once, at construction.
Implementations§
Source§impl CoseVerifyKey
impl CoseVerifyKey
Sourcepub fn ed25519(public: &[u8; 32]) -> Result<CoseVerifyKey, CratestackError>
pub fn ed25519(public: &[u8; 32]) -> Result<CoseVerifyKey, CratestackError>
An Ed25519 (-19) public key from its 32 bytes. Fails with
CratestackError::Validation for bytes that are not a point
encoding.
Sourcepub fn p256_sec1(sec1: &[u8]) -> Result<CoseVerifyKey, CratestackError>
pub fn p256_sec1(sec1: &[u8]) -> Result<CoseVerifyKey, CratestackError>
A P-256 (-9) public key from its SEC1 encoding (compressed or
not). Fails with CratestackError::Validation for a point not on the
curve.
Sourcepub fn hmac(
alg: CoseAlg,
secret: impl Into<Vec<u8>>,
) -> Result<CoseVerifyKey, CratestackError>
pub fn hmac( alg: CoseAlg, secret: impl Into<Vec<u8>>, ) -> Result<CoseVerifyKey, CratestackError>
An HMAC secret for exactly alg (CoseAlg::Hmac256_64 or
CoseAlg::Hmac256_256). Fails with CratestackError::Validation
for another algorithm or a secret below 32 bytes (see
HmacSecret).
Sourcepub fn hmac_from_secret(
alg: CoseAlg,
secret: HmacSecret,
) -> Result<CoseVerifyKey, CratestackError>
pub fn hmac_from_secret( alg: CoseAlg, secret: HmacSecret, ) -> Result<CoseVerifyKey, CratestackError>
As hmac, from an already validated HmacSecret
(the counterpart of HmacSigner::from_secret), so a secret loaded
once can back a signer and a verification key without its bytes
passing through a plain Vec again. Fails with
CratestackError::Validation for a non-HMAC alg.
Sourcepub fn supports(&self, alg: CoseAlg) -> bool
pub fn supports(&self, alg: CoseAlg) -> bool
Whether this key can verify messages of alg: exactly
alg.
Sourcepub fn thumbprint(&self) -> [u8; 32]
pub fn thumbprint(&self) -> [u8; 32]
The key’s RFC 9679 thumbprint.
Sourcepub fn ed25519_bytes(&self) -> Option<[u8; 32]>
pub fn ed25519_bytes(&self) -> Option<[u8; 32]>
The 32-byte Ed25519 public key, or None for another key type.
Sourcepub fn p256_sec1_uncompressed(&self) -> Option<[u8; 65]>
pub fn p256_sec1_uncompressed(&self) -> Option<[u8; 65]>
The uncompressed SEC1 P-256 point (0x04 ‖ x ‖ y, 65 bytes), or
None for another key type.
Trait Implementations§
Source§impl Clone for CoseVerifyKey
impl Clone for CoseVerifyKey
Source§fn clone(&self) -> CoseVerifyKey
fn clone(&self) -> CoseVerifyKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CoseVerifyKey
impl Debug for CoseVerifyKey
impl Eq for CoseVerifyKey
Source§impl PartialEq for CoseVerifyKey
impl PartialEq for CoseVerifyKey
Source§fn eq(&self, other: &CoseVerifyKey) -> bool
fn eq(&self, other: &CoseVerifyKey) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for CoseVerifyKey
Auto Trait Implementations§
impl Freeze for CoseVerifyKey
impl RefUnwindSafe for CoseVerifyKey
impl Send for CoseVerifyKey
impl Sync for CoseVerifyKey
impl Unpin for CoseVerifyKey
impl UnsafeUnpin for CoseVerifyKey
impl UnwindSafe for CoseVerifyKey
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<T> MaybeSend for T
impl<T> MaybeSendSync for T
impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].