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

#27 in #jose

Download history 41/week @ 2024-04-06 43/week @ 2024-04-13 50/week @ 2024-04-20 45/week @ 2024-04-27 39/week @ 2024-05-04 58/week @ 2024-05-11 53/week @ 2024-05-18 42/week @ 2024-05-25 48/week @ 2024-06-01 42/week @ 2024-06-08 45/week @ 2024-06-15 41/week @ 2024-06-22 32/week @ 2024-06-29 55/week @ 2024-07-06 40/week @ 2024-07-13 37/week @ 2024-07-20

171 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