pub struct Envelope<'a> { /* private fields */ }Expand description
A manifest body next to the signature over exactly those bytes.
Implementations§
Source§impl<'a> Envelope<'a>
impl<'a> Envelope<'a>
Sourcepub fn decode(bytes: &'a [u8]) -> Result<Self>
pub fn decode(bytes: &'a [u8]) -> Result<Self>
Decodes an envelope, borrowing the signed body from the input.
§Arguments
bytes- the encoded envelope.
§Returns
The envelope, whose body is not yet trusted.
§Errors
Returns Refusal::Malformed if the encoding is not a well-formed
envelope.
Sourcepub fn verify(&self, author: &PublicIdentity) -> Result<Manifest>
pub fn verify(&self, author: &PublicIdentity) -> Result<Manifest>
Checks the signature and returns the manifest it vouches for.
The signature is checked before the body is interpreted, so nothing an unknown author wrote reaches the parser.
§Arguments
author- the public key the device trusts to release updates.
§Returns
The manifest, now known to be from author and unaltered.
§Errors
Returns Refusal::Signature if the signature is not this author’s over
this body, or a decoding refusal if the body is not a valid manifest.
Sourcepub fn verified_body(&self, signer: &PublicIdentity) -> Result<&'a [u8]>
pub fn verified_body(&self, signer: &PublicIdentity) -> Result<&'a [u8]>
Checks the signature and returns the bytes it covers.
An envelope carries whatever its author signed, which is a manifest in the usual case and a delegation when authority is being handed on. Checking the signature separately from reading the body lets both share one envelope shape without either having to know about the other.
§Arguments
signer- the public key the body must be signed by.
§Returns
The signed bytes, now known to be from signer and unaltered.
§Errors
Returns Refusal::Signature if the signature is not this signer’s over
this body.