diff options
author | Ellie Huxtable <ellie@elliehuxtable.com> | 2023-05-11 16:18:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-11 20:18:20 +0000 |
commit | b53ca357cdd6a1b3236cbcadff8626f6bfc37748 (patch) | |
tree | 9d629c4330e0fed5deaf303febafa5fb48b6dc53 /atuin-client/src/encryption.rs | |
parent | bf7432f3924f81c5edcc7ff39f1fc3cba021eea4 (diff) |
Fix key regression introduced (#974)
Diffstat (limited to 'atuin-client/src/encryption.rs')
-rw-r--r-- | atuin-client/src/encryption.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/atuin-client/src/encryption.rs b/atuin-client/src/encryption.rs index 9145a11df..7ed640a5d 100644 --- a/atuin-client/src/encryption.rs +++ b/atuin-client/src/encryption.rs @@ -85,10 +85,19 @@ pub fn decode_key(key: String) -> Result<Key> { let buf = BASE64_STANDARD .decode(key.trim_end()) .wrap_err("encryption key is not a valid base64 encoding")?; - let buf: &[u8] = rmp_serde::from_slice(&buf) - .wrap_err("encryption key is not a valid message pack encoding")?; - Ok(*Key::from_slice(buf)) + let mbuf: Result<[u8; 32]> = + rmp_serde::from_slice(&buf).wrap_err("encryption key is not a valid message pack encoding"); + + match mbuf { + Ok(b) => Ok(*Key::from_slice(&b)), + Err(_) => { + let buf: &[u8] = rmp_serde::from_slice(&buf) + .wrap_err("encryption key is not a valid message pack encoding")?; + + Ok(*Key::from_slice(buf)) + } + } } pub fn encrypt(history: &History, key: &Key) -> Result<EncryptedHistory> { |