quickfix fpath in secmod
This commit is contained in:
parent
2361fa13e1
commit
e8d7b413ad
3 changed files with 29 additions and 7 deletions
|
|
@ -57,12 +57,14 @@ let key_fpath k =
|
|||
|
||||
let read_key fs fpath =
|
||||
Log.debug (fun m -> m "reading key file `%a`" Fpath.pp fpath);
|
||||
let fpath = Fpath.to_string fpath in
|
||||
let* data = Fat.read fs fpath |> unwrap_msg in
|
||||
EddsaPrivateKey.of_octets data
|
||||
|
||||
let write_eddsa fs fpath priv =
|
||||
Log.debug (fun m -> m "writing key file `%a`" Fpath.pp fpath);
|
||||
let data = EddsaPrivateKey.to_octets priv in
|
||||
let fpath = Fpath.to_string fpath in
|
||||
Fat.write fs fpath data |> unwrap_msg
|
||||
|
||||
let write_key fs k = write_eddsa fs (key_fpath k) k.priv
|
||||
|
|
@ -77,15 +79,20 @@ let delete_file fs fpath =
|
|||
Fpath.pp fpath
|
||||
in
|
||||
Log.debug (fun m -> m "delete key file `%a`" Fpath.pp fpath);
|
||||
let fpath = Fpath.to_string fpath in
|
||||
let+ () = Fat.remove fs fpath |> unwrap_msg in
|
||||
()
|
||||
|
||||
let get_key_dir_contents fs dir =
|
||||
let* dir = Fpath.of_string dir |> unwrap_msg in
|
||||
let* b = Fat.create fs dir |> unwrap_msg in
|
||||
if b then Log.info (fun m -> m "created directory `%a`" Fpath.pp dir);
|
||||
let dir = Fpath.to_string dir in
|
||||
let* () = Fat.mkdir fs dir |> unwrap_msg in
|
||||
Log.info (fun m -> m "created directory `%s`" dir);
|
||||
let+ l = Fat.ls fs dir |> unwrap_msg in
|
||||
List.map Fpath.normalize l
|
||||
(* List.map Fpath.normalize l *)
|
||||
let l = List.map (fun entry -> entry.Fat.name) l in
|
||||
let l = List.map Fpath.v l in
|
||||
l
|
||||
|
||||
(* -- *)
|
||||
|
||||
|
|
@ -164,7 +171,7 @@ let init fs =
|
|||
let sm_key_priv, sm_pub = EddsaPrivateKey.generate () in
|
||||
Log.debug (fun m ->
|
||||
m "generated secmod key: `%s`" (EddsaPublicKey.to_b32 sm_pub));
|
||||
let* () = write_eddsa sm_key_fpath sm_key_priv in
|
||||
let* () = write_eddsa fs sm_key_fpath sm_key_priv in
|
||||
let ht = Hashtbl.create 0xff in
|
||||
Ok { fs; sm_key_priv; sm_pub; ht }
|
||||
in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue