From 585d37a6df81f0d7fc8d6067159b90617b73ebc4 Mon Sep 17 00:00:00 2001 From: swrup Date: Sat, 7 Feb 2026 21:25:49 +0100 Subject: [PATCH] add http_information.ml --- data/auditor_private_key | 1 - src/{http_keys.ml => http_information.ml} | 20 ++++++++++++++++++- src/mte.ml | 24 +++-------------------- {data => test}/auditor_public_key | 0 test/offline_management.sh | 2 +- 5 files changed, 23 insertions(+), 24 deletions(-) delete mode 100644 data/auditor_private_key rename src/{http_keys.ml => http_information.ml} (92%) rename {data => test}/auditor_public_key (100%) diff --git a/data/auditor_private_key b/data/auditor_private_key deleted file mode 100644 index 82aad694..00000000 --- a/data/auditor_private_key +++ /dev/null @@ -1 +0,0 @@ -Iî÷q¸àwÇ´Y—›gbÙ'R+5µ™â°ƒˆyë> \ No newline at end of file diff --git a/src/http_keys.ml b/src/http_information.ml similarity index 92% rename from src/http_keys.ml rename to src/http_information.ml index 760e6cbe..79ac240e 100644 --- a/src/http_keys.ml +++ b/src/http_information.ml @@ -2,6 +2,24 @@ open Syntax open Api module String_map = Stdlib.Map.Make (Stdlib.String) +(* TODO mirage-crypto + is this ok? + maybe don't use the same RNG-initialization as the one used to generate keys *) +let seed req _server _env = + Logs.info (fun m -> m "GET /seed"); + (* RNG is initialized by Vif.run *) + let s = Mirage_crypto_rng.generate 64 in + let open Vif.Response in + let open Syntax in + let* () = add ~field:"content-type" "application/octet-stream" in + let* () = with_string req s in + respond `OK + +let config req _server _env = + Logs.info (fun m -> m "GET /config"); + let s = Api.(encode_exn ExchangeVersionResponse.jsont config) in + Respond_util.respond_with_ok_json s req + (* TODO for now we only have one item in each "denom group" change this once we have denom/signkey rotation *) @@ -239,7 +257,7 @@ let mk_keys ~db_conn (module Sm : Secmod.S) ~last_issue_date = let jsont = ExchangeKeysResponse.jsont -let f req server _env = +let keys req server _env = Logs.info (fun m -> m "GET /keys"); let db_conn = Vif.Server.device Devices.db_connection server in let sm = Vif.Server.device Devices.secmod server in diff --git a/src/mte.ml b/src/mte.ml index 159f688b..abfc68a8 100644 --- a/src/mte.ml +++ b/src/mte.ml @@ -13,24 +13,6 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . *) -(* TODO mirage-crypto - is this ok? - maybe don't use the same RNG-initialization as the one used to generate keys *) -let seed req _server _env = - Logs.info (fun m -> m "GET /seed"); - (* RNG is initialized by Vif.run *) - let s = Mirage_crypto_rng.generate 64 in - let open Vif.Response in - let open Syntax in - let* () = add ~field:"content-type" "application/octet-stream" in - let* () = with_string req s in - respond `OK - -let config req _server _env = - Logs.info (fun m -> m "GET /config"); - let s = Api.(encode_exn ExchangeVersionResponse.jsont config) in - Respond_util.respond_with_ok_json s req - let hello req _server _env = let open Vif.Response in let open Syntax in @@ -53,9 +35,9 @@ let routes = in let status_info = [ - get_ (rel / "seed") --> seed; - get_ (rel / "config") --> config; - get_ (rel / "keys") --> Http_keys.f; + get_ (rel / "seed") --> Http_information.seed; + get_ (rel / "config") --> Http_information.config; + get_ (rel / "keys") --> Http_information.keys; ] in let management = diff --git a/data/auditor_public_key b/test/auditor_public_key similarity index 100% rename from data/auditor_public_key rename to test/auditor_public_key diff --git a/test/offline_management.sh b/test/offline_management.sh index 83d46357..058093fd 100755 --- a/test/offline_management.sh +++ b/test/offline_management.sh @@ -5,7 +5,7 @@ set -e a="tmp_a.json" b="tmp_b.json" -auditor_pub=$(<"./data/auditor_public_key") +auditor_pub=$(<"./test/auditor_public_key") zero_euro="EUR:0.0" dune exec offline -- download --output $a