add timestamps; use Ptime

This commit is contained in:
swrup 2025-10-17 15:09:47 +02:00
parent 112ece6d9a
commit a27af0ecf1
8 changed files with 163 additions and 77 deletions

View file

@ -7,6 +7,9 @@ type t = {
+ b32 *)
string ->
string;
stamp_start: Ptime.t;
stamp_expire: Ptime.t;
stamp_end: Ptime.t;
}
let make ~name =
@ -16,8 +19,24 @@ let make ~name =
- look if it exists
- if not, create it (TOFU initialization scheme)
- write it *)
(* TODO time
correctly set those: *)
let stamp_start = Ptime_clock.now () in
let stamp_expire =
match Ptime.add_span stamp_start Config.Exchange.signkey_legal_duration with
| None ->
Fmt.failwith "Ptime.add_span: result is not in the range [min;max]"
| Some v -> v
in
let stamp_end = stamp_expire in
let priv, pub = Mirage_crypto_ec.Ed25519.generate () in
{ pub; sign= Mirage_crypto_ec.Ed25519.sign ~key:priv }
{
pub;
sign= Mirage_crypto_ec.Ed25519.sign ~key:priv;
stamp_start;
stamp_expire;
stamp_end;
}
let signkey_device = make ~name:"signkey"