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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! # HTTP Signature Error Types
//!
//! This module defines the error types used throughout the HTTP signature functionality.
//! All signature operations return a [`Result<T, HttpSignatureError>`] which provides
//! detailed error information for different failure scenarios.
//!
//! ## Error Categories
//!
//! - **I/O Errors**: File system and network I/O problems
//! - **Parsing Errors**: Key format and data parsing failures
//! - **Cryptographic Errors**: Signature creation and validation issues
//! - **JWK Errors**: JSON Web Key format and processing problems
//!
//! ## Example Usage
//!
//! ```rust
//! use open_payments::http_signature::{HttpSignatureError, Result};
//!
//! fn handle_signature_error(result: Result<()>) {
//! match result {
//! Ok(()) => println!("Signature operation successful"),
//! Err(HttpSignatureError::Io(err)) => eprintln!("I/O error: {}", err),
//! Err(HttpSignatureError::Signature(msg)) => eprintln!("Signature error: {}", msg),
//! Err(HttpSignatureError::Validation(msg)) => eprintln!("Validation error: {}", msg),
//! Err(e) => eprintln!("Unexpected error: {:?}", e),
//! }
//! }
//! ```
use DecodeError;
use io;
use Error;
/// Error type for HTTP signature operations.
///
/// This enum provides detailed error information for different types of failures
/// that can occur during HTTP signature creation, validation, and key management.
/// Each variant includes context-specific error messages to help with debugging
/// and error handling.
///
/// ## Error Variants
///
/// - `Io` - File system and I/O errors
/// - `Base64` - Base64 encoding/decoding errors
/// - `Pem` - PEM format parsing errors
/// - `Pkcs8` - PKCS8 key format errors
/// - `InvalidPrivateKeyLength` - Private key length validation errors
/// - `Utf8` - UTF-8 encoding/decoding errors
/// - `Jwk` - JSON Web Key format errors
/// - `Signature` - Signature creation and verification errors
/// - `Validation` - Signature validation and verification errors
/// - `Other` - Miscellaneous errors
/// Result type for HTTP signature operations.
///
/// This is a type alias for `Result<T, HttpSignatureError>` that provides a convenient
/// way to handle signature operation results with detailed error information.
pub type Result<T> = Result;