pub fn suit_decode<H, C>(
data: &[u8],
handler: &mut H,
crypto: &mut C,
) -> Result<(), SuitError>where
H: SuitStartHandler,
C: SuitCrypto,Expand description
Decodes a SUIT manifest from CBOR bytes and dispatches to a handler.
This is the primary public API for manifest processing. It handles both authenticated manifests (SUIT_Envelope with COSE signatures) and bare manifests (for testing).
§Parameters
-
data- Raw CBOR-encoded bytes containing either:- SUIT_Envelope (Tag 107): Authenticated manifest with optional severable elements
- SUIT_Manifest (Tag 1070): Bare manifest (testing only, no signature verification)
-
handler- Struct implementinghandler::SuitStartHandlerto process the decoded manifest. The handler is called with either the envelope or manifest depending on the input format. -
key_buf- COSE KeySet encoded as CBOR bytes for signature verification. This must be a CBOR-encoded array of COSE_Key objects (built usingcose_minicbor::cose_keys::CoseKeySetBuilderas shown in Cryptographic Signature Verification).- Required for authenticated manifests (SUIT_Envelope, Tag 107)
- Ignored for bare manifests (SUIT_Manifest, Tag 1070)
- Must not be empty for authenticated manifests or
SuitError::KeysDecodeErroris returned
§Returns
Ok(())- Successfully decoded and verified the manifestErr(SuitError)- Decoding, verification, or processing failed (seeSuitErrorvariants)
§Security Requirements
For authenticated manifests:
- CBOR decoding is performed safely with type validation
- Signature is verified against trusted keys in
key_buf - Digest verification occurs before cryptographic operations (TOCTOU protection)
- Handler rejects the manifest on any error
§Handler Implementation
Implement handler::SuitStartHandler:
use suit_validator::handler::*;
use suit_validator::suit_manifest::*;
use suit_validator::SuitError;
struct MyManifestProcessor;
impl SuitStartHandler for MyManifestProcessor {
fn on_envelope<'a>(&mut self, envelope: SuitEnvelope<'a>) -> Result<(), SuitError> {
// Process authenticated signed manifest
Ok(())
}
fn on_manifest<'a>(&mut self, manifest: SuitManifest<'a>) -> Result<(), SuitError> {
// Process bare manifest
Ok(())
}
}