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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Pluggable signing for [`Attestation`](super::Attestation) structs.
//!
//! path_jail does not vendor a crypto implementation — bring your own by
//! implementing [`Signer`] (and [`Verifier`] on the enforcement side). This
//! keeps the crate zero-dependency while letting callers wire up
//! `ed25519-dalek`, `ring`, an HSM client, AWS KMS, GCP KMS, etc.
//!
//! # Wire format
//!
//! The signature covers the bytes returned by
//! [`Attestation::signing_bytes`](super::Attestation::signing_bytes), which is
//! the canonical fixed-layout encoding of every attestation field including
//! `opened_at`. The format is deterministic and free of length-ambiguity:
//! see the doc on `signing_bytes` for the exact layout.
//!
//! # Example: ed25519-dalek
//!
//! ```ignore
//! use ed25519_dalek::{Signature, Signer as DalekSigner, SigningKey, Verifier as DalekVerifier, VerifyingKey};
//! use path_jail::guard::{Signer, Verifier};
//!
//! struct DalekS(SigningKey);
//! impl Signer for DalekS {
//! type Error = std::convert::Infallible;
//! fn sign(&self, msg: &[u8]) -> Result<[u8; 64], Self::Error> {
//! Ok(self.0.sign(msg).to_bytes())
//! }
//! }
//!
//! struct DalekV(VerifyingKey);
//! impl Verifier for DalekV {
//! type Error = ed25519_dalek::SignatureError;
//! fn verify(&self, msg: &[u8], sig: &[u8; 64]) -> Result<(), Self::Error> {
//! self.0.verify(msg, &Signature::from_bytes(sig))
//! }
//! }
//! ```
/// Produces a 64-byte signature over a byte slice.
///
/// Implementations typically wrap a key handle (in-process key material, an
/// HSM session, a KMS client, etc.). Failures may come from the underlying
/// crypto provider (network errors talking to KMS, HSM unavailable, etc.).
/// Verifies a 64-byte signature over a byte slice.
///
/// On the enforcement-point side. Implementations wrap a verifying key.
/// Error returned by [`Attestation::verify`](super::Attestation::verify).
///
/// Distinguishes "attestation is unsigned" from "signature is invalid", so
/// enforcement points can choose to reject both or only the latter.