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
// This is free and unencumbered software released into the public domain.
use alloc::string::String;
/// HTTP integrity construction, parsing, or verification failure.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// A Structured Field is malformed or has the wrong semantic type.
#[error("invalid integrity field: {0}")]
InvalidField(&'static str),
/// A field or derived component is unavailable in this message context.
#[error("missing HTTP signature component: {0}")]
MissingComponent(String),
/// A component identifier or its parameters cannot be processed.
#[error("invalid HTTP signature component: {0}")]
InvalidComponent(String),
/// The message context lacks a valid, absolute HTTP(S) target URI.
#[error("invalid HTTP signature target URI")]
InvalidTargetUri,
/// Covered components must be unique, regardless of parameter ordering.
#[error("duplicate covered component")]
DuplicateComponent,
/// Reusing a signature label would make selection ambiguous.
#[error("duplicate signature label")]
DuplicateLabel,
/// SHA-256 was absent, malformed, or did not match the message content.
#[error("missing or mismatched SHA-256 content digest")]
ContentDigest,
/// An algorithm other than Ed25519 was requested or asserted.
#[error("only Ed25519 HTTP message signatures are supported")]
Algorithm,
/// Ed25519 verification failed.
#[error("invalid HTTP message signature")]
Signature,
/// A required profile constraint was not satisfied.
#[error("HTTP signature policy rejected the message: {0}")]
Policy(&'static str),
/// Integrity metadata exceeded the documented parsing limits.
#[error("HTTP integrity metadata limit exceeded")]
Limit,
/// A frame appeared after trailers, or more than one trailer frame appeared.
#[error("invalid HTTP body frame order")]
FrameOrder,
/// Streaming trailers cannot be used with these HTTP semantics.
#[error("trailers are unavailable for this message")]
TrailersUnavailable,
/// OS entropy could not be obtained.
#[error("failed to generate signature nonce: {0}")]
Random(String),
/// The wall clock cannot be represented as a nonnegative UNIX timestamp.
#[error("invalid signature clock")]
Clock,
}
impl From<sfv::Error> for Error {
fn from(_: sfv::Error) -> Self {
Self::InvalidField("structured field syntax")
}
}