diff options
Diffstat (limited to '')
| -rw-r--r-- | crates/turtle/src/atuin_client/record/encryption.rs | 4 | ||||
| -rw-r--r-- | crates/turtle/src/atuin_client/record/sync.rs | 9 | ||||
| -rw-r--r-- | crates/turtle/src/atuin_client/settings.rs | 7 |
3 files changed, 13 insertions, 7 deletions
diff --git a/crates/turtle/src/atuin_client/record/encryption.rs b/crates/turtle/src/atuin_client/record/encryption.rs index 96ab463e..d8587cf6 100644 --- a/crates/turtle/src/atuin_client/record/encryption.rs +++ b/crates/turtle/src/atuin_client/record/encryption.rs @@ -68,7 +68,6 @@ impl Encryption for PASETO_V4 { // aka content-encryption-key (CEK) let random_key = Key::<V4, Local>::new_os_random(); - // encode the implicit assertions let assertions = Assertions::from(ad).encode(); // build the payload and encrypt the token @@ -145,11 +144,12 @@ impl PASETO_V4 { fn encrypt_cek(cek: Key<V4, Local>, key: &[u8; 32]) -> String { // aka key-encryption-key (KEK) let wrapping_key = Key::<V4, Local>::from_bytes(*key); + let kid = wrapping_key.to_id(); // wrap the random key so we can decrypt it later let wrapped_cek = AtuinFooter { wpk: cek.wrap_pie(&wrapping_key), - kid: wrapping_key.to_id(), + kid, }; serde_json::to_string(&wrapped_cek).expect("could not serialize wrapped cek") } diff --git a/crates/turtle/src/atuin_client/record/sync.rs b/crates/turtle/src/atuin_client/record/sync.rs index 3057bb10..da05533c 100644 --- a/crates/turtle/src/atuin_client/record/sync.rs +++ b/crates/turtle/src/atuin_client/record/sync.rs @@ -23,7 +23,7 @@ pub(crate) enum SyncError { #[error("operational error: {msg:?}")] OperationalError { msg: String }, - #[error("a request to the sync server failed: {msg:?}")] + #[error("a request to the sync server failed: {msg}")] RemoteRequestError { msg: String }, #[error( @@ -347,9 +347,10 @@ pub(crate) async fn check_encryption_key( return Ok(()); }; - record - .decrypt::<PASETO_V4>(encryption_key) - .map_err(|_| SyncError::WrongKey)?; + record.decrypt::<PASETO_V4>(encryption_key).map_err(|err| { + error!("Wrong key error: {err}"); + SyncError::WrongKey + })?; Ok(()) } diff --git a/crates/turtle/src/atuin_client/settings.rs b/crates/turtle/src/atuin_client/settings.rs index 98829529..9e14c4c8 100644 --- a/crates/turtle/src/atuin_client/settings.rs +++ b/crates/turtle/src/atuin_client/settings.rs @@ -834,12 +834,17 @@ impl Sync { pub(crate) fn user_id(&self) -> Result<Option<Uuid>> { Self::try_read_file(self.user_id_path.as_ref())? - .map(|file| Uuid::try_parse(&file).map_err(Into::into)) + .map(|file| { + Uuid::parse_str(file.trim()).context( + "Failed to decode user id as UUID, while trying to decode sync user_id", + ) + }) .transpose() } pub(crate) fn encryption_key(&self) -> Result<Option<Key>> { Self::try_read_file(self.encryption_key_path.as_ref())? .as_deref() + .map(str::trim) .map(decode_key) .transpose() } |
