From bb876a689d5979696b757d04b0e34d988f10b51f Mon Sep 17 00:00:00 2001 From: swrup Date: Fri, 20 Feb 2026 12:59:53 +0100 Subject: [PATCH] --- src/config.ml | 16 ++++++++++++++++ src/secmod_rsa.ml | 10 +++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/config.ml b/src/config.ml index 468648c5..b4aebab2 100644 --- a/src/config.ml +++ b/src/config.ml @@ -191,6 +191,22 @@ module Exchange_secmod_rsa = struct let duration = get "duration" |> duration let key_dir = get "key_dir" let sm_priv_key = get "sm_priv_key" + + (* only support one rsa_keysize *) + let rsa_keysize = + Coin.all_coins + |> List.map (fun coin -> coin.Coin.rsa_keysize) + |> List.sort_uniq Int.compare + |> function + | [] -> fail "no coin section found" + | a :: b :: _ -> + fail + "coins with different rsa_keysize are not supported, found \ + rsa_keysize = %d and %d" + a b + | n :: [] -> n + + let sections = Coin.all_coins |> List.map (fun coin -> coin.Coin.section_name) end module Exchange_secmod_eddsa = struct diff --git a/src/secmod_rsa.ml b/src/secmod_rsa.ml index 7c981b50..95d072de 100644 --- a/src/secmod_rsa.ml +++ b/src/secmod_rsa.ml @@ -114,8 +114,7 @@ let gen_additional_keys_until_lookahead ~now ~section_name l = let new_keys = List.map (fun (t1, t2) -> - (* TODO ~bits is in coin's config *) - let priv, pub = RsaPrivateKey.generate ~bits:2048 () in + let priv, pub = RsaPrivateKey.generate ~bits:Cfg.rsa_keysize () in { section_name; priv; pub; t1; t2 }) periodes in @@ -147,11 +146,8 @@ let load_section section_name = let keys = List.filter_map Fun.id l in Ok keys -(* TODO read from config *) -let sections = [] - let load () = - let* keys_l = list_map load_section sections in + let* keys_l = list_map load_section Cfg.sections in let keys = List.concat keys_l in match keys with | [] -> Ok None @@ -182,7 +178,7 @@ let init () = List.filter (fun k -> k.section_name = section_name) all_keys in gen_additional_keys_until_lookahead ~now ~section_name keys) - sections + Cfg.sections in let new_keys = List.concat new_keys_l in let () = List.iter (fun k -> Hashtbl.replace t.ht k.pub k) new_keys in