init
This commit is contained in:
commit
099cd80670
48 changed files with 4951 additions and 0 deletions
78
tools/offline.ml
Normal file
78
tools/offline.ml
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
open Cmdliner
|
||||
open Cmdliner.Term.Syntax
|
||||
open Offline_impl
|
||||
|
||||
let default_master_offline_key_file = "data/master_offline_private_key"
|
||||
let default_response_file = "response.json"
|
||||
let default_request_file = "request.json"
|
||||
|
||||
(*let to_term_ret = function Error e -> `Error (false, e) | Ok () -> `Ok ()*)
|
||||
let to_term_ret = Fun.id
|
||||
|
||||
let setup_cmd =
|
||||
let doc = "Generate offline master keys" in
|
||||
let output =
|
||||
Arg.(
|
||||
value
|
||||
& opt filepath default_master_offline_key_file
|
||||
& info [ "o"; "output" ] ~doc)
|
||||
in
|
||||
Cmd.make (Cmd.info "setup" ~doc)
|
||||
@@
|
||||
let+ output = output in
|
||||
setup ~output |> to_term_ret
|
||||
|
||||
let download_cmd =
|
||||
let doc = "GET /management/keys/" in
|
||||
let man =
|
||||
[ `S Manpage.s_description; `P "$(cmd) download /management/keys." ]
|
||||
in
|
||||
let output =
|
||||
Arg.(
|
||||
value & opt filepath default_response_file & info [ "o"; "output" ] ~doc)
|
||||
in
|
||||
Cmd.make (Cmd.info "download" ~doc ~man)
|
||||
@@
|
||||
let+ output = output in
|
||||
download ~output |> to_term_ret
|
||||
|
||||
let upload_cmd =
|
||||
let doc = "POST /management/keys/" in
|
||||
let man =
|
||||
[ `S Manpage.s_description; `P "$(cmd) upload /management/keys." ]
|
||||
in
|
||||
let input =
|
||||
Arg.(value & opt file default_request_file & info [ "i"; "input" ] ~doc)
|
||||
in
|
||||
Cmd.make (Cmd.info "upload" ~doc ~man)
|
||||
@@
|
||||
let+ input = input in
|
||||
upload ~input |> to_term_ret
|
||||
|
||||
let sign_cmd =
|
||||
let doc = "Sign FutureKeysResponse." in
|
||||
let master_key =
|
||||
let doc = "Master offline Eddsa private key file." in
|
||||
Arg.(value & opt file default_master_offline_key_file & info [ "key" ] ~doc)
|
||||
in
|
||||
let input =
|
||||
Arg.(value & opt file default_response_file & info [ "i"; "input" ] ~doc)
|
||||
in
|
||||
let output =
|
||||
Arg.(
|
||||
value & opt filepath default_request_file & info [ "o"; "output" ] ~doc)
|
||||
in
|
||||
Cmd.make (Cmd.info "sign" ~doc)
|
||||
@@
|
||||
let+ input = input and+ output = output and+ master_key = master_key in
|
||||
sign ~input ~output ~master_key |> to_term_ret
|
||||
|
||||
let cli =
|
||||
let info =
|
||||
let doc = "MTE Offline CLI tool" in
|
||||
Cmd.info "mte-offline" ~doc
|
||||
in
|
||||
Cmd.group info [ setup_cmd; download_cmd; sign_cmd; upload_cmd ]
|
||||
|
||||
let main () = Cmd.eval_result cli
|
||||
let () = if !Sys.interactive then () else exit (main ())
|
||||
Loading…
Add table
Add a link
Reference in a new issue