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
171 downloads per month
Used in cose-c
49KB
826 lines
cose-rust
A Rust library for COSE using NSS.
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;
}
}