aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_client/encryption.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/turtle/src/atuin_client/encryption.rs')
-rw-r--r--crates/turtle/src/atuin_client/encryption.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/turtle/src/atuin_client/encryption.rs b/crates/turtle/src/atuin_client/encryption.rs
index 20a0cd90..f5d4f20d 100644
--- a/crates/turtle/src/atuin_client/encryption.rs
+++ b/crates/turtle/src/atuin_client/encryption.rs
@@ -11,7 +11,7 @@
use std::{io::prelude::*, path::PathBuf};
use base64::prelude::{BASE64_STANDARD, Engine};
-pub use crypto_secretbox::Key;
+pub(crate) use crypto_secretbox::Key;
use crypto_secretbox::{
AeadCore, AeadInPlace, KeyInit, XSalsa20Poly1305,
aead::{Nonce, OsRng},
@@ -25,19 +25,19 @@ use time::{OffsetDateTime, format_description::well_known::Rfc3339, macros::form
use crate::atuin_client::{history::History, settings::Settings};
#[derive(Debug, Serialize, Deserialize)]
-pub struct EncryptedHistory {
- pub ciphertext: Vec<u8>,
- pub nonce: Nonce<XSalsa20Poly1305>,
+pub(crate) struct EncryptedHistory {
+ pub(crate) ciphertext: Vec<u8>,
+ pub(crate) nonce: Nonce<XSalsa20Poly1305>,
}
-pub fn generate_encoded_key() -> Result<(Key, String)> {
+pub(crate) fn generate_encoded_key() -> Result<(Key, String)> {
let key = XSalsa20Poly1305::generate_key(&mut OsRng);
let encoded = encode_key(&key)?;
Ok((key, encoded))
}
-pub fn new_key(settings: &Settings) -> Result<Key> {
+pub(crate) fn new_key(settings: &Settings) -> Result<Key> {
let path = settings.key_path.as_str();
let path = PathBuf::from(path);
@@ -54,7 +54,7 @@ pub fn new_key(settings: &Settings) -> Result<Key> {
}
// Loads the secret key, will create + save if it doesn't exist
-pub fn load_key(settings: &Settings) -> Result<Key> {
+pub(crate) fn load_key(settings: &Settings) -> Result<Key> {
let path = settings.key_path.as_str();
let key = if PathBuf::from(path).exists() {
@@ -67,7 +67,7 @@ pub fn load_key(settings: &Settings) -> Result<Key> {
Ok(key)
}
-pub fn encode_key(key: &Key) -> Result<String> {
+pub(crate) fn encode_key(key: &Key) -> Result<String> {
let mut buf = vec![];
rmp::encode::write_array_len(&mut buf, key.len() as u32)
.wrap_err("could not encode key to message pack")?;
@@ -80,7 +80,7 @@ pub fn encode_key(key: &Key) -> Result<String> {
Ok(buf)
}
-pub fn decode_key(key: String) -> Result<Key> {
+pub(crate) fn decode_key(key: String) -> Result<Key> {
use rmp::decode;
let buf = BASE64_STANDARD
@@ -118,7 +118,7 @@ pub fn decode_key(key: String) -> Result<Key> {
}
}
-pub fn encrypt(history: &History, key: &Key) -> Result<EncryptedHistory> {
+pub(crate) fn encrypt(history: &History, key: &Key) -> Result<EncryptedHistory> {
// serialize with msgpack
let mut buf = encode(history)?;
@@ -133,7 +133,7 @@ pub fn encrypt(history: &History, key: &Key) -> Result<EncryptedHistory> {
})
}
-pub fn decrypt(mut encrypted_history: EncryptedHistory, key: &Key) -> Result<History> {
+pub(crate) fn decrypt(mut encrypted_history: EncryptedHistory, key: &Key) -> Result<History> {
XSalsa20Poly1305::new(key)
.decrypt_in_place(
&encrypted_history.nonce,