Skip to main content

CoseVerifierResolver

Trait CoseVerifierResolver 

Source
pub trait CoseVerifierResolver: MaybeSendSync + 'static {
    // Required method
    fn resolve<'life0, 'life1, 'async_trait>(
        &'life0 self,
        kid: &'life1 [u8],
        alg: CoseAlg,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<CoseVerifyKey>, CratestackError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

Finds the keys that may have produced a message.

Contract, which the envelope’s error mapping depends on:

  • An unknown kid is Ok(vec![]), never Err. Every Err is treated as a backend outage and becomes a 500. A resolver that answered “no such key” with Err would turn an unknown kid into a distinguishable response, the oracle §10 forbids.
  • Several candidates are normal. Eight bytes of thumbprint collide at about 2³² keys, so a resolver returns every key whose kid matches, and the opener tries each (§3, Q5).
  • Resolve by (kid, alg). One device may hold a classical key and a hybrid key side by side during a migration (Q5).

Returning too much is harmless, but wasteful. The opener accepts a candidate only if the candidate’s own kid (computed from the key) is the one in the header and the candidate’s algorithm is the header’s, and the principal it records is the thumbprint of the key that verified. So a resolver that ignores kid or alg (say, one that returns every active key of a tenant) cannot let one key sign as another, or an HMAC secret stand in for a public key. It only costs a thumbprint comparison per extra candidate, and a lookup that should have been indexed.

Required Methods§

Source

fn resolve<'life0, 'life1, 'async_trait>( &'life0 self, kid: &'life1 [u8], alg: CoseAlg, ) -> Pin<Box<dyn Future<Output = Result<Vec<CoseVerifyKey>, CratestackError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Every key whose kid is kid and which verifies alg; Ok(vec![]) if there is none. Err only for a backend failure.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CoseVerifierResolver for DeviceKeyCoseResolver

Source§

impl CoseVerifierResolver for KeyProviderMacKeys

Every loaded key whose kid and algorithm match; an unknown kid is Ok(vec![]), as the resolver contract requires. Never Err: the secrets were resolved at construction, so there is no backend left to fail.

Source§

impl CoseVerifierResolver for RegistryVerifierResolver

Source§

impl CoseVerifierResolver for StaticVerifierResolver