add binary_formats.ml
This commit is contained in:
parent
b7b28af6fe
commit
71d957e233
2 changed files with 17 additions and 5 deletions
1
src/dune
1
src/dune
|
|
@ -13,6 +13,7 @@
|
|||
;
|
||||
include
|
||||
;
|
||||
bin
|
||||
angstrom
|
||||
zarith ;
|
||||
mirage-crypto
|
||||
|
|
|
|||
|
|
@ -1,18 +1,29 @@
|
|||
(* https://docs.taler.net/core/api-common.html#id7 *)
|
||||
(* https://docs.taler.net/core/api-common.html#id7
|
||||
|
||||
- numeric values are in network byte order (big endian) *)
|
||||
|
||||
module Purpose = struct
|
||||
(* defined in gnunet_crypto_lib.h *)
|
||||
type t = {
|
||||
(* This field equals the number of bytes being signed,
|
||||
namely 'sizeof (struct Data)'. *)
|
||||
size: Int32.t; (* = uint32_t *)
|
||||
size: int32; (* = uint32_t *)
|
||||
(* This field is used to express the context in
|
||||
which the signature is made, ensuring that a
|
||||
signature cannot be lifted from one part of the protocol
|
||||
to another. See `src/include/taler/taler_signatures.h` within the
|
||||
exchange's codebase (git://taler.net/exchange). *)
|
||||
purpose: Int32.t; (* = uint32_t *)
|
||||
to another. *)
|
||||
purpose: int32; (* = uint32_t *)
|
||||
}
|
||||
|
||||
(* TODO endianess? *)
|
||||
let bin_t =
|
||||
let open Bin in
|
||||
record (fun size purpose -> { size; purpose })
|
||||
|+ field beint32 (fun t -> t.size)
|
||||
|+ field beint32 (fun t -> t.purpose)
|
||||
|> sealr
|
||||
|
||||
let to_string t = Bin.to_string bin_t t
|
||||
end
|
||||
|
||||
module Data = struct
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue