cose

Library to use COSE (https://tools.ietf.org/html/rfc8152) in Rust

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
Download history 44/week @ 2024-07-21 36/week @ 2024-07-28 36/week @ 2024-08-04 34/week @ 2024-08-11 35/week @ 2024-08-18 33/week @ 2024-08-25 31/week @ 2024-09-01 40/week @ 2024-09-08 36/week @ 2024-09-15 49/week @ 2024-09-22 43/week @ 2024-09-29 44/week @ 2024-10-06 56/week @ 2024-10-13 38/week @ 2024-10-20 32/week @ 2024-10-27 57/week @ 2024-11-03

188 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