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 fuser::Filesystem;
|
||||||
use rustcryptfs_lib::{config::CryptConf, filename::FilenameDecoder};
|
use rustcryptfs_lib::GocryptFs;
|
||||||
|
|
||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
|
|
||||||
pub struct EncryptedFs {
|
pub struct EncryptedFs {
|
||||||
master_key: Vec<u8>,
|
fs: GocryptFs,
|
||||||
filename_decoder: FilenameDecoder,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EncryptedFs {
|
impl EncryptedFs {
|
||||||
|
@ -15,22 +14,9 @@ impl EncryptedFs {
|
||||||
where
|
where
|
||||||
P: AsRef<Path>,
|
P: AsRef<Path>,
|
||||||
{
|
{
|
||||||
let path = path.as_ref();
|
let fs = GocryptFs::open(path, password)?;
|
||||||
|
|
||||||
let conf_path = path.join("gocryptfs.conf");
|
Ok(Self { fs })
|
||||||
|
|
||||||
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,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mount<P>(self, mountpoint: P)
|
pub fn mount<P>(self, mountpoint: P)
|
||||||
|
|
Loading…
Reference in New Issue