Use GocryptFS in linux EncryptedFs

This commit is contained in:
oupson 2022-10-03 14:47:39 +02:00
parent 6702757eaa
commit 75540ba718
Signed by: oupson
GPG Key ID: 3BD88615552EFCB7
1 changed files with 5 additions and 19 deletions

View File

@ -1,13 +1,12 @@
use std::{fs, path::Path};
use std::path::Path;
use fuser::Filesystem;
use rustcryptfs_lib::{config::CryptConf, filename::FilenameDecoder};
use rustcryptfs_lib::GocryptFs;
use crate::error::Result;
pub struct EncryptedFs {
master_key: Vec<u8>,
filename_decoder: FilenameDecoder,
fs: GocryptFs,
}
impl EncryptedFs {
@ -15,22 +14,9 @@ impl EncryptedFs {
where
P: AsRef<Path>,
{
let path = path.as_ref();
let fs = GocryptFs::open(path, password)?;
let conf_path = path.join("gocryptfs.conf");
let content = fs::read_to_string(conf_path)?;
let conf: CryptConf = serde_json::from_str(&content)?;
let master_key = conf.get_master_key(password.as_bytes())?;
let filename_decoder = FilenameDecoder::new(&master_key)?;
Ok(Self {
master_key,
filename_decoder,
})
Ok(Self { fs })
}
pub fn mount<P>(self, mountpoint: P)