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
//! Error types for AES Crypt operations.
//!
//! Every fallible function in this crate returns
//! [`Result<T, AescryptError>`](AescryptError). [`AescryptError`] discriminates between
//! I/O failures, cryptographic failures, header / extension parsing failures, and
//! unsupported file format versions.
//!
//! # Variant → API table
//!
//! | Variant | Typical producer |
//! | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
//! | [`AescryptError::Io`] | [`encrypt`], [`decrypt`], [`read_version`], every reader/writer helper in [`crate::encryption`] / [`crate::decryption`] |
//! | [`AescryptError::Crypto`] | [`derive_ackdf_key`], [`derive_pbkdf2_key`], [`Pbkdf2Builder::derive_secure`], [`utf8_to_utf16le`] |
//! | [`AescryptError::Header`] | [`encrypt`], [`decrypt`], [`read_version`], [`derive_setup_key`], [`write_header`] / [`write_extensions`] / [`write_iterations`], [`read_file_version`], [`read_kdf_iterations`], [`consume_all_extensions`], [`extract_session_data`], [`decrypt_ciphertext_stream`] |
//! | [`AescryptError::UnsupportedVersion`] | [`write_header`], [`write_extensions`], [`write_iterations`], [`read_file_version`] |
//!
//! [`encrypt`]: crate::encrypt()
//! [`decrypt`]: crate::decrypt()
//! [`read_version`]: crate::read_version
//! [`derive_ackdf_key`]: crate::derive_ackdf_key
//! [`derive_pbkdf2_key`]: crate::derive_pbkdf2_key
//! [`Pbkdf2Builder::derive_secure`]: crate::Pbkdf2Builder::derive_secure
//! [`utf8_to_utf16le`]: crate::utilities::utf8_to_utf16le
//! [`derive_setup_key`]: crate::encryption::derive_setup_key
//! [`write_header`]: crate::encryption::write_header
//! [`write_extensions`]: crate::encryption::write_extensions
//! [`write_iterations`]: crate::encryption::write_iterations
//! [`read_file_version`]: crate::decryption::read_file_version
//! [`read_kdf_iterations`]: crate::decryption::read_kdf_iterations
//! [`consume_all_extensions`]: crate::decryption::consume_all_extensions
//! [`extract_session_data`]: crate::decryption::extract_session_data
//! [`decrypt_ciphertext_stream`]: crate::decryption::decrypt_ciphertext_stream
use Error;
/// The error type returned by every fallible AES Crypt operation in this crate.
///
/// `AescryptError` is non-exhaustive in spirit: it discriminates four classes of
/// failure (I/O, cryptographic, header/format, unsupported version) but the
/// human-readable message inside [`Crypto`](Self::Crypto) and
/// [`Header`](Self::Header) is part of the error display, not the structured API,
/// and may be refined in patch releases.
///
/// # Errors
///
/// All four variants are constructed by code inside this crate; downstream callers
/// generally pattern-match on the variant and surface a friendly message based on
/// the [`Display`](std::fmt::Display) impl provided by [`thiserror`].
///
/// See the [variant → API table](self) at the module level for which public APIs
/// produce each variant.
///
/// # Security
///
/// Error messages are written for human diagnostics. They never embed the
/// password, derived keys, IVs, salts, or plaintext. Untrusted callers may safely
/// log the [`Display`](std::fmt::Display) form. Wrap-and-`?` is the recommended
/// pattern; do not attempt to recover from [`Header`](Self::Header) by retrying
/// with different inputs.