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
//! Application-wide constants.
//!
//! Centralizes every timeout, size limit, and protocol magic value.
use Duration;
/// Package version, sourced from Cargo at compile time.
pub const VERSION: &str = env!;
// -- Timeouts ---------------------------------------------------------------
/// SOAP signing operation timeout.
pub const DEFAULT_TIMEOUT_SOAP: Duration = from_secs;
/// SOAP signing timeout in whole seconds -- the form stored in `config.json`
/// and carried on a [`crate::config::ServerProfile`], where timeouts are
/// integer seconds rather than a `Duration`.
pub const DEFAULT_TIMEOUT_SOAP_SECS: u32 = 120;
/// HTTP GET timeout (discovery / WSDL / TSL fetch).
pub const DEFAULT_TIMEOUT_HTTP_GET: Duration = from_secs;
/// HTTP POST timeout (SOAP requests).
pub const DEFAULT_TIMEOUT_HTTP_POST: Duration = from_secs;
/// Legacy TLS connection timeout.
pub const DEFAULT_TIMEOUT_LEGACY_TLS: Duration = from_secs;
/// Minimum user-configurable timeout (seconds).
pub const MIN_TIMEOUT_SECS: u64 = 1;
/// Maximum user-configurable timeout (seconds).
pub const MAX_TIMEOUT_SECS: u64 = 3600;
// -- Size units and limits --------------------------------------------------
/// Bytes per megabyte.
pub const BYTES_PER_MB: usize = 1024 * 1024;
/// Maximum HTTP/TLS response body size (50 MB).
pub const MAX_RESPONSE_SIZE: usize = 50 * BYTES_PER_MB;
/// Socket receive buffer size.
pub const RECV_BUFFER_SIZE: usize = 8192;
/// PDF size above which signing gets flaky on the appliance (35 MB).
pub const PDF_WARN_SIZE: usize = 35 * BYTES_PER_MB;
// -- Retry ------------------------------------------------------------------
/// Maximum retry attempts on transient failures.
pub const DEFAULT_MAX_RETRIES: u32 = 3;
/// Initial delay between retries.
pub const DEFAULT_RETRY_DELAY: Duration = from_secs;
/// Exponential backoff multiplier for the retry delay.
pub const DEFAULT_RETRY_BACKOFF: f64 = 2.0;
// -- Protocol ---------------------------------------------------------------
/// Minimum base64 length distinguishing a CMS signature from an error string.
pub const MIN_SIGNATURE_B64_LEN: usize = 50;
/// XML preview truncation length for error messages (characters).
pub const XML_PREVIEW_LENGTH: usize = 300;
/// SHA-1 digest size in bytes.
pub const SHA1_DIGEST_SIZE: usize = 20;
/// PDF file magic bytes.
pub const PDF_MAGIC: & = b"%PDF-";
// -- Environment variable names ---------------------------------------------
pub const ENV_URL: &str = "REVENANT_URL";
pub const ENV_TIMEOUT: &str = "REVENANT_TIMEOUT";
pub const ENV_USER: &str = "REVENANT_USER";
pub const ENV_PASS: &str = "REVENANT_PASS";
pub const ENV_NAME: &str = "REVENANT_NAME";
// -- Signature defaults -----------------------------------------------------
/// Default position preset for embedded signatures.
pub const DEFAULT_POSITION: &str = "bottom-right";
// -- TSL / chain validation -------------------------------------------------
/// Trust Service List cache time-to-live (24 hours).
pub const TSL_CACHE_TTL: Duration = from_secs;
/// Maximum age of a cached TSL that may still be used as a fallback when a fresh
/// fetch fails (7 days). Beyond this the stale list is discarded and trust
/// degrades to indeterminate, so a blocked TSL endpoint cannot pin clients to an
/// arbitrarily old trust list indefinitely.
pub const TSL_MAX_STALE: Duration = from_secs;
/// TSL fetch timeout.
pub const TSL_FETCH_TIMEOUT: Duration = from_secs;