Use GocryptFS in linux EncryptedFs
This commit is contained in:
parent
6702757eaa
commit
75540ba718
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue