5 releases

Uses old Rust 2015

0.1.4 Jan 5, 2018
0.1.3 Dec 4, 2017
0.1.2 Nov 22, 2017
0.1.1 Nov 14, 2017
0.1.0 Sep 20, 2017

#2607 in Parser implementations

Download history 22/week @ 2023-12-03 23/week @ 2023-12-10 24/week @ 2023-12-17 17/week @ 2023-12-24 15/week @ 2023-12-31 27/week @ 2024-01-07 25/week @ 2024-01-14 18/week @ 2024-01-21 27/week @ 2024-01-28 24/week @ 2024-02-04 34/week @ 2024-02-11 52/week @ 2024-02-18 59/week @ 2024-02-25 54/week @ 2024-03-03 47/week @ 2024-03-10 46/week @ 2024-03-17

211 downloads per month
Used in cose-c

MPL-2.0 license

49KB
826 lines

cose-rust

A Rust library for COSE using NSS.

Build Status Maturity Level

THIS IS WORK IN PROGRESS. DO NOT USE YET.

Build instructions

If NSS is not installed in the path, use NSS_LIB_DIR to set the library path where we can find the NSS libraries.

cargo build

Run Tests and Examples

To run tests and examples you need NSS in your library path. Tests can be run with

cargo test

and examples with

cargo run --example sign_verify

lib.rs:

This crate implements COSE signature parsing. Verification has to be performed by the caller.

Example usage: Let payload and cose_signature be variables holding the signed payload and the COSE signature bytes respectively. Let further verify_callback be a function callback that implements signature verification.

 use cose::decoder::decode_signature;

 // Parse the incoming signature.
 let cose_signatures = decode_signature(cose_signature, &payload);
 let cose_signatures = match cose_signatures {
     Ok(signature) => signature,
     Err(_) => Vec::new(),
 };
 if cose_signatures.len() < 1 {
     return false;
 }

 let mut result = true;
 for cose_signature in cose_signatures {
     // Call callback to verify the parsed signatures.
     result &= verify_callback(cose_signature);

     // We can stop early. The cose_signature is not valid.
     if !result {
         return result;
     }
 }

Dependencies