add key device

This commit is contained in:
Swrup 2025-10-02 16:32:43 +02:00
parent 3b5a98a0d5
commit 062c34b8b7
3 changed files with 38 additions and 2 deletions

View file

@ -6,6 +6,7 @@
headers_lib headers_lib
syntax syntax
; ;
mirage-crypto
duration duration
vif vif
fmt fmt

View file

@ -2,7 +2,6 @@
https://docs.taler.net/taler-exchange-manual.html#offline-signing-setup-key-maintenance-and-tear-down https://docs.taler.net/taler-exchange-manual.html#offline-signing-setup-key-maintenance-and-tear-down
The exchange HTTP service must be running before you can complete the following offline signing procedure. Note that when an exchange is running without offline keys its not fully operational. To make the exchange HTTP service fully operational, the following steps involving the offline signing machine must be completed: The exchange HTTP service must be running before you can complete the following offline signing procedure. Note that when an exchange is running without offline keys its not fully operational. To make the exchange HTTP service fully operational, the following steps involving the offline signing machine must be completed:
1) The public keys of various online keys used by the exchange service are exported via a management HTTP API. 1) The public keys of various online keys used by the exchange service are exported via a management HTTP API.
@ -22,3 +21,32 @@
- implement `POST /management/keys` - implement `POST /management/keys`
- offline tool do: GET -> sign -> POST - offline tool do: GET -> sign -> POST
- now we should have a server with valid keys signed by the master offline key *) - now we should have a server with valid keys signed by the master offline key *)
(* implement secmod / crytpo stuff as a vif device *)
(* https://docs.taler.net/core/api-common.html#cryptographic-primitives
All elliptic curve operations are on Curve25519.
Public and private keys are thus 32 bytes, and signatures 64 bytes.
For hashing, including HKDFs, Taler uses 512-bit hash codes (64 bytes). *)
(* TODO big choice
do we re-implement crypto
or do we re-use secmodules with IPC on a Unix domain socket *)
type key =
| Eddsa of Mirage_crypto_ec.Ed25519.(priv * pub)
| Rsa of Mirage_crypto_pk.Rsa.(priv * pub)
let eddsa_online_key_device =
let finally _key = () in
Vif.Device.v ~name:"eddsa_online_key" ~finally [] @@ fun () ->
(* [Mirage_crypto_rng_miou_unix.(initialize (module Pfortuna))] is already done by [Vif.run] *)
Eddsa (Mirage_crypto_ec.Ed25519.generate ())
let rsa_denomination_key_device =
let finally _key = () in
Vif.Device.v ~name:"rsa_denomination_key" ~finally [] @@ fun () ->
let open Mirage_crypto_pk.Rsa in
let rsa_keysize = 2048 in
let priv = generate ~bits:rsa_keysize () in
Rsa (priv, pub_of_priv priv)

View file

@ -121,5 +121,12 @@ let () =
in in
Miou_unix.run @@ fun () -> Miou_unix.run @@ fun () ->
let env = () in let env = () in
let devices =
Vif.Devices.
[
Management.eddsa_online_key_device
; Management.rsa_denomination_key_device
]
in
let middlewares = Vif.Middlewares.[] in let middlewares = Vif.Middlewares.[] in
Vif.run ~cfg ~middlewares routes env Vif.run ~cfg ~devices ~middlewares routes env