Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions protocol/src/encryption/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub fn decrypt_message(
match_choice |= eq;
}
if match_choice.unwrap_u8() == 0 {
return Err(KeyError::InvalidSignature);
return Err(KeyError::RecipientNotFound);
}

let wrapping = parsed
Expand Down Expand Up @@ -208,7 +208,7 @@ pub fn decrypt_message(
aad: FILE_AAD,
},
)
.map_err(|_| KeyError::InvalidSignature)
.map_err(|_| KeyError::DecryptionFailed)
}

#[cfg(test)]
Expand Down
10 changes: 10 additions & 0 deletions protocol/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ pub enum KeyError {
#[error("Invalid signature")]
InvalidSignature,

/// Decryption failed - message was encrypted with different key material
#[error(
"Decryption failed: message was encrypted for a different key (recipient may have regenerated keys)"
)]
DecryptionFailed,

/// Recipient identity not found in envelope
#[error("Recipient not found: this message was not encrypted for your identity")]
RecipientNotFound,

/// Serialization or deserialization error
#[error("Serialization error: {0}")]
SerializationError(String),
Expand Down