1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! `cose2` — CBOR Object Signing and Encryption (COSE, RFC 9052) and CBOR
//! Web Token (CWT, RFC 8392) for Rust, built on [`cbor2`].
//!
//! This crate models COSE structures (messages, headers, keys) and CWT
//! claims, and delegates cryptography to caller-supplied implementations of
//! the [`Signer`], [`Verifier`], [`Macer`] and [`Encryptor`] traits — so it
//! ships no cryptographic dependencies of its own.
//!
//! # Example: COSE_Sign1 round trip
//!
//! ```
//! use cose2::{iana, Sign1Message, Signer, Verifier, Error};
//!
//! // A trivial (insecure) signer/verifier for illustration.
//! struct Demo;
//! impl Signer for Demo {
//! fn alg(&self) -> i64 { iana::AlgorithmEdDSA }
//! fn kid(&self) -> &[u8] { b"key-1" }
//! fn sign(&self, data: &[u8]) -> Result<Vec<u8>, Error> { Ok(data.to_vec()) }
//! }
//! impl Verifier for Demo {
//! fn alg(&self) -> i64 { iana::AlgorithmEdDSA }
//! fn verify(&self, data: &[u8], sig: &[u8]) -> Result<(), Error> {
//! if sig == data { Ok(()) } else { Err(Error::verify("bad signature")) }
//! }
//! }
//!
//! let mut msg = Sign1Message::new(Some(b"This is the content".to_vec()));
//! let encoded = msg.sign_and_encode(&Demo, None).unwrap();
//!
//! let verified = Sign1Message::verify_and_decode(&Demo, &encoded, None).unwrap();
//! assert_eq!(verified.payload.as_deref(), Some(&b"This is the content"[..]));
//! ```
pub use Error;
pub use Header;
pub use ;
pub use Label;
pub use CoseMap;
pub use ;
pub use ;
pub use EncryptMessage;
pub use Encrypt0Message;
pub use MacMessage;
pub use Mac0Message;
pub use Recipient;
pub use ;
pub use Sign1Message;
/// The CBOR value type used for header, key and claim values.
///
/// Re-exported from [`cbor2`].
pub use Value;