Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: don't stop with invalid key #1612

Merged
merged 1 commit into from
Jan 22, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion atuin-client/src/history/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,16 @@ impl HistoryStore {
for record in records.into_iter() {
let hist = match record.version.as_str() {
HISTORY_VERSION => {
let decrypted = record.decrypt::<PASETO_V4>(&self.encryption_key)?;
let decrypted = record.decrypt::<PASETO_V4>(&self.encryption_key);

let decrypted = match decrypted {
Ok(d) => d,
Err(e) => {
println!("failed to decrypt history: {e}");
continue;
}
};

HistoryRecord::deserialize(&decrypted.data, HISTORY_VERSION)
}
version => bail!("unknown history version {version:?}"),
Expand Down
1 change: 1 addition & 0 deletions atuin-client/src/record/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ impl PASETO_V4 {
// For now though we will only support the one key and key rotation will
// have to be a hard reset
let current_kid = wrapping_key.to_id();

ensure!(
current_kid == kid,
"attempting to decrypt with incorrect key. currently using {current_kid}, expecting {kid}"
Expand Down