fix: report an over-long plaintext as MessageTooLong, not DecryptionFailed

This commit is contained in:
2026-11-25 07:48:55 +01:00
parent e0c6d53a99
commit 853f59ca60
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -57,6 +57,8 @@ pub enum Error {
UnsupportedVersion(u8),
/// A sealed box failed authentication: wrong key, wrong associated data, or tampered.
DecryptionFailed,
/// The plaintext is longer than ChaCha20-Poly1305 allows (about 256 GiB).
MessageTooLong,
}
impl fmt::Display for Error {
@@ -72,6 +74,7 @@ impl fmt::Display for Error {
Error::NonContributory => f.write_str("X25519 value is a low-order point"),
Error::UnsupportedVersion(v) => write!(f, "sealed box version {v} is not supported"),
Error::DecryptionFailed => f.write_str("sealed box could not be opened"),
Error::MessageTooLong => f.write_str("message is too long to seal"),
}
}
}