secmod_rsa: use denom_hash
This commit is contained in:
parent
fa5d0ae75d
commit
4f473c003a
3 changed files with 45 additions and 50 deletions
26
src/keys.ml
26
src/keys.ml
|
|
@ -6,7 +6,7 @@ type 'a result = ('a, string) Result.t
|
|||
|
||||
module type S = sig
|
||||
val sign : eddsa_pub -> string -> eddsa_sig
|
||||
val sign_denom : rsa_pub -> string -> rsa_sig
|
||||
val sign_denom : denom_hash -> string -> rsa_sig
|
||||
val find_signkey : eddsa_pub -> Signkey.t option result
|
||||
val find_denomination : denom_hash -> Denomination.t option result
|
||||
val signkeys : unit -> Signkey.t list result
|
||||
|
|
@ -44,8 +44,8 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
| Error e -> Fmt.failwith "sign failure: %s." e
|
||||
| Ok v -> v
|
||||
|
||||
let sign_denom pub s =
|
||||
match Sm_rsa.sign pub s with
|
||||
let sign_denom h_pub s =
|
||||
match Sm_rsa.sign h_pub s with
|
||||
| Error e -> Fmt.failwith "sign_denom failure: %s." e
|
||||
| Ok v -> v
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
let+ l = Pg.get_denominations conn () |> unwrap_err_caqti in
|
||||
let missing_l, l =
|
||||
List.partition
|
||||
(fun dn -> Option.is_none @@ Sm_rsa.find_key dn.Denomination.pub)
|
||||
(fun dn -> Option.is_none @@ Sm_rsa.find_key dn.Denomination.h_pub)
|
||||
l
|
||||
in
|
||||
match missing_l with
|
||||
|
|
@ -181,8 +181,7 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
|
||||
let future_denominations () =
|
||||
Sm_rsa.keys ()
|
||||
|> list_filter_map (fun (pub, (section_name, t1)) ->
|
||||
let h_pub = Hash.DenominationHash.hash (RsaPublicKey.to_octets pub) in
|
||||
|> list_filter_map (fun (h_pub, (section_name, pub, t1)) ->
|
||||
let* opt = find_denomination h_pub in
|
||||
match opt with
|
||||
| None ->
|
||||
|
|
@ -281,15 +280,9 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
Ok ()
|
||||
|
||||
let certify_future_denomination h_pub master_sig =
|
||||
(* TODO Sm_rsa.find_key *)
|
||||
Sm_rsa.keys ()
|
||||
|> List.find_opt (fun (pub, (_section_name, _t1)) ->
|
||||
let h_pub' = Hash.DenominationHash.hash (RsaPublicKey.to_octets pub) in
|
||||
h_pub' = h_pub)
|
||||
|> function
|
||||
match Sm_rsa.find_key h_pub with
|
||||
| None -> Error "future denomination not found"
|
||||
| Some (pub, (section_name, t1)) ->
|
||||
let h_pub = Hash.DenominationHash.hash (RsaPublicKey.to_octets pub) in
|
||||
| Some (h_pub, (section_name, pub, t1)) ->
|
||||
let* () =
|
||||
let* opt = find_denomination h_pub in
|
||||
match opt with
|
||||
|
|
@ -323,10 +316,9 @@ module Make (Conn : Pg.CONN) : S = struct
|
|||
let revoke_denomination h_pub revoked_sig =
|
||||
let* opt = find_denomination h_pub in
|
||||
let* dn = Option.to_result ~none:"denomination not found" opt in
|
||||
let pub = dn.pub in
|
||||
let* () = Sm_rsa.revoke pub in
|
||||
let* () = Sm_rsa.revoke dn.h_pub in
|
||||
let+ () =
|
||||
Pg.insert_denomination_revocation conn h_pub revoked_sig
|
||||
Pg.insert_denomination_revocation conn dn.h_pub revoked_sig
|
||||
|> unwrap_err_caqti
|
||||
in
|
||||
()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue