fix: report an over-long plaintext as MessageTooLong, not DecryptionFailed
This commit is contained in:
@@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user