This commit is contained in:
parent
78b08dcb4e
commit
19a470371e
3 changed files with 24 additions and 21 deletions
|
|
@ -20,7 +20,12 @@
|
|||
- test them
|
||||
- some purpose (`TALER_SIGNATURE_XXX`) are missing
|
||||
exchange and gana master branch are not in sync
|
||||
and we should use a specific git tag instead *)
|
||||
and we should use a specific git tag instead
|
||||
|
||||
- clean up functor mess
|
||||
don't have not hash thing be HashCode like
|
||||
- have a make function for wrapped HashCode structs
|
||||
make it take the relevant type *)
|
||||
|
||||
module Taler_signatures = Include.Taler_signatures
|
||||
|
||||
|
|
|
|||
|
|
@ -76,17 +76,7 @@ let mk_future_denom denom_secmod_sign_f
|
|||
let mk_future_sign_key signkey_secmod_sign_f
|
||||
({ pub; sign= _; stamp_start; stamp_expire; stamp_end } : Secmod_keys.t) =
|
||||
let exchange_pub =
|
||||
(* TODO
|
||||
- I don't think its in crockford base 32 here
|
||||
maybe SHA-512?
|
||||
or maybe SHA-512 in crockford base 32
|
||||
-> no, its not a hash here
|
||||
need to change ugly binary_formats functor
|
||||
to not mixup hashed values with others
|
||||
- have a make function for wrapped HashCode structs
|
||||
make it take the relevant type *)
|
||||
let v = EddsaPublicKey.to_b32 pub in
|
||||
Binary_formats.ExchangePublicKeyP.{ v= { v } }
|
||||
Binary_formats.ExchangePublicKeyP.{ v= { v= EddsaPublicKey.to_octets pub } }
|
||||
in
|
||||
let signkey_secmod_sig =
|
||||
let open Binary_formats in
|
||||
|
|
|
|||
26
src/types.ml
26
src/types.ml
|
|
@ -82,6 +82,8 @@ module EddsaPublicKey = struct
|
|||
converted to Crockford Base32. *)
|
||||
type t = Mirage_crypto_ec.Ed25519.pub
|
||||
|
||||
let to_octets t = Mirage_crypto_ec.Ed25519.pub_to_octets t
|
||||
|
||||
let of_b32 s =
|
||||
let open Syntax in
|
||||
let open Mirage_crypto_ec in
|
||||
|
|
@ -90,13 +92,14 @@ module EddsaPublicKey = struct
|
|||
| Error e -> Fmt.error "%a" pp_error e
|
||||
| Ok pub -> Ok pub
|
||||
|
||||
let to_b32 pub = pub |> Mirage_crypto_ec.Ed25519.pub_to_octets |> B32.encode
|
||||
let to_b32 t = B32.encode (to_octets t)
|
||||
let jsont = Jsont.of_of_string ~kind:"EddsaPublicKey" of_b32 ~enc:to_b32
|
||||
end
|
||||
|
||||
module EddsaSignature : sig
|
||||
type t
|
||||
|
||||
val to_octets : t -> string
|
||||
val sign : key:Mirage_crypto_ec.Ed25519.priv -> string -> t
|
||||
val of_b32 : string -> (t, string) result
|
||||
val to_b32 : t -> string
|
||||
|
|
@ -108,6 +111,8 @@ end = struct
|
|||
They are signature over a c-struct like `TALER_xxxPS` + with a purpose *)
|
||||
type t = string
|
||||
|
||||
let to_octets t = t
|
||||
|
||||
(* TODO key format
|
||||
is it exactly like in GNU_CRYPTO?
|
||||
endianess issue? *)
|
||||
|
|
@ -128,6 +133,13 @@ end
|
|||
module RsaPublicKey = struct
|
||||
type t = Mirage_crypto_pk.Rsa.pub
|
||||
|
||||
let to_octets ({ n; e } : Mirage_crypto_pk.Rsa.pub) =
|
||||
let open Binary_formats.RsaPublicKey in
|
||||
let header = { n_len= Z.size n; e_len= Z.size e } in
|
||||
let v = { header; n; e } in
|
||||
let s = Bin.to_string bin v in
|
||||
s
|
||||
|
||||
let of_b32 s =
|
||||
let open Syntax in
|
||||
let* s = B32.decode s in
|
||||
|
|
@ -135,20 +147,14 @@ module RsaPublicKey = struct
|
|||
let+ v = Mirage_crypto_pk.Rsa.pub ~n:v.n ~e:v.e |> unwrap_err_msg in
|
||||
v
|
||||
|
||||
let to_b32 ({ n; e } : Mirage_crypto_pk.Rsa.pub) =
|
||||
let open Binary_formats.RsaPublicKey in
|
||||
let header = { n_len= Z.size n; e_len= Z.size e } in
|
||||
let v = { header; n; e } in
|
||||
let s = Bin.to_string bin v in
|
||||
let s = B32.encode s in
|
||||
s
|
||||
|
||||
let to_b32 t = B32.encode (to_octets t)
|
||||
let jsont = Jsont.of_of_string ~kind:"RsaPublicKey" of_b32 ~enc:to_b32
|
||||
end
|
||||
|
||||
module RsaSignature : sig
|
||||
type t
|
||||
|
||||
val to_octets : t -> string
|
||||
val sign : key:Mirage_crypto_pk.Rsa.priv -> string -> t
|
||||
val of_b32 : string -> (t, string) result
|
||||
val to_b32 : t -> string
|
||||
|
|
@ -156,6 +162,8 @@ module RsaSignature : sig
|
|||
end = struct
|
||||
type t = string
|
||||
|
||||
let to_octets t = t
|
||||
|
||||
(* no Rsa.sign(?):
|
||||
decrypt is equivalent to sign *)
|
||||
let sign ~key s =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue