wip secmod
This commit is contained in:
parent
592ebee9a3
commit
b27ebea6ee
8 changed files with 153 additions and 109 deletions
83
src/types.ml
83
src/types.ml
|
|
@ -1,3 +1,33 @@
|
|||
module Config_types = struct
|
||||
module Currency = struct
|
||||
type t = {
|
||||
enabled: [ `YES | `NO ];
|
||||
code: string;
|
||||
name: string;
|
||||
fractional_input_digits: int;
|
||||
fractional_normal_digits: int;
|
||||
fractional_trailing_zero_digits: int;
|
||||
alt_unit_names: (int * string) list;
|
||||
}
|
||||
end
|
||||
|
||||
module Coin = struct
|
||||
type t = {
|
||||
value: Amount.t;
|
||||
duration_withdraw: int;
|
||||
duration_spend: int;
|
||||
duration_legal: int;
|
||||
fee_withdraw: Amount.t;
|
||||
fee_deposit: Amount.t;
|
||||
fee_refresh: Amount.t;
|
||||
fee_refund: Amount.t;
|
||||
cipher: [ (* `CS |*) `RSA ];
|
||||
rsa_keysize: int option (*only if `RSA *);
|
||||
age_restricted: [ (*`YES|*) `NO ];
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
(* https://docs.taler.net/core/api-common.html#tsref-type-ErrorDetail *)
|
||||
module ErrorDetail = struct
|
||||
(* TODO GANA error codes
|
||||
|
|
@ -41,7 +71,7 @@ module EddsaPublicKey = struct
|
|||
|
||||
let of_string s =
|
||||
let open Mirage_crypto_ec in
|
||||
match Base_32.decode s with
|
||||
match B32.decode s with
|
||||
| Error _ as err -> err
|
||||
| Ok octets -> (
|
||||
match Ed25519.pub_of_octets octets with
|
||||
|
|
@ -49,7 +79,7 @@ module EddsaPublicKey = struct
|
|||
| Ok pub -> Ok pub)
|
||||
|
||||
let to_string pub =
|
||||
pub |> Mirage_crypto_ec.Ed25519.pub_to_octets |> Base_32.encode
|
||||
pub |> Mirage_crypto_ec.Ed25519.pub_to_octets |> B32.encode
|
||||
end
|
||||
|
||||
module EddsaSignature = struct
|
||||
|
|
@ -69,22 +99,26 @@ end
|
|||
|
||||
module RsaPublicKey = struct
|
||||
(* RSA public key converted to Crockford Base32. *)
|
||||
type pub = Mirage_crypto_pk.Rsa.pub
|
||||
type t = Mirage_crypto_pk.Rsa.pub
|
||||
|
||||
let pub_of_string s =
|
||||
let of_string s =
|
||||
(* TODO bin
|
||||
- no [Bin.of_string] ?
|
||||
- what to do with the int ref? *)
|
||||
let off = ref 0 in
|
||||
let v = Bin.decode Binary_formats.RsaPublicKey.bin s off in
|
||||
let res = Mirage_crypto_pk.Rsa.pub ~n:v.n ~e:v.e in
|
||||
match res with Error (`Msg e) -> Error e | Ok pub -> Ok pub
|
||||
match B32.decode s with
|
||||
| Error _ as err -> err
|
||||
| Ok s -> (
|
||||
let off = ref 0 in
|
||||
let v = Bin.decode Binary_formats.RsaPublicKey.bin s off in
|
||||
let res = Mirage_crypto_pk.Rsa.pub ~n:v.n ~e:v.e in
|
||||
match res with Error (`Msg e) -> Error e | Ok pub -> Ok pub)
|
||||
|
||||
let pub_to_string ({ n; e } : Mirage_crypto_pk.Rsa.pub) =
|
||||
let to_string ({ 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
|
||||
end
|
||||
|
||||
|
|
@ -133,3 +167,34 @@ module FutureSignKey = struct
|
|||
signkey_secmod_sig: EddsaSignature.t;
|
||||
}
|
||||
end
|
||||
|
||||
module FutureDenom = struct
|
||||
type t = {
|
||||
section_name: string;
|
||||
value: Amount.t;
|
||||
stamp_start: Timestamp.t;
|
||||
stamp_expire_withdraw: Timestamp.t;
|
||||
stamp_expire_deposit: Timestamp.t;
|
||||
stamp_expire_legal: Timestamp.t;
|
||||
denom_pub: DenominationKey.t;
|
||||
fee_withdraw: Amount.t;
|
||||
fee_deposit: Amount.t;
|
||||
fee_refresh: Amount.t;
|
||||
fee_refund: Amount.t;
|
||||
(* Signature by the denomination security module
|
||||
over TALER_DenominationKeyAnnouncementPS
|
||||
for this denomination with purpose
|
||||
TALER_SIGNATURE_SM_DENOMINATION_KEY. *)
|
||||
denom_secmod_sig: EddsaSignature.t;
|
||||
}
|
||||
end
|
||||
|
||||
module FutureKeysResponse = struct
|
||||
type t = {
|
||||
future_denoms: FutureDenom.t list;
|
||||
future_signkeys: FutureSignKey.t list;
|
||||
master_pub: EddsaPublicKey.t;
|
||||
denom_secmod_public_key: EddsaPublicKey.t;
|
||||
signkey_secmod_public_key: EddsaPublicKey.t;
|
||||
}
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue