Skip to content

Commit

Permalink
+
Browse files Browse the repository at this point in the history
  • Loading branch information
oluceps committed Nov 23, 2024
1 parent be5caa2 commit cbf75e8
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/util/secmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
iter,
path::{Path, PathBuf},
str::FromStr,
sync::Arc,
};

use crate::{
Expand Down Expand Up @@ -244,22 +245,21 @@ impl<'a> RencInst<'a, InStore> {
.into()
}
/// read secret file
pub fn bake_decrypted(self, ident: &dyn Identity) -> Result<HashMap<&'a Secret, Vec<u8>>> {
self.inner()
.pin()
.into_iter()
.map(|(k, v)| {
v.read_buffer().map(|b| {
(
k.0,
SecBuf::<HostEnc>::from(b)
.decrypt(ident)
.expect("must")
.inner(),
)
})
})
.try_collect::<HashMap<&'a Secret, Vec<u8>>>()
pub fn bake_decrypted(self, ident: &dyn Identity) -> Result<Arc<HashMap<&'a Secret, Vec<u8>>>> {
let self_arc = Arc::new(self.inner());
let self_arc_ref = self_arc.pin();
let ret: Arc<HashMap<&Secret, Vec<u8>>> = Arc::new(HashMap::new());

for ((k, _), v) in self_arc_ref.into_iter() {
ret.pin().insert(
k,
v.read_buffer()
.and_then(|i| SecBuf::<HostEnc>::from(i).decrypt(ident))
.expect("decrypt must sussess")
.inner(),
);
}
Ok(ret)
}
}

Expand Down

0 comments on commit cbf75e8

Please sign in to comment.