more cleanups
This commit is contained in:
parent
611d234e1a
commit
f3c67f626a
|
@ -88,17 +88,6 @@ let image =
|
||||||
|
|
||||||
type version = [ `AV0 | `AV1 | `AV2 ]
|
type version = [ `AV0 | `AV1 | `AV2 ]
|
||||||
|
|
||||||
let version_of_int = function
|
|
||||||
| 0 -> Ok `AV0
|
|
||||||
| 1 -> Ok `AV1
|
|
||||||
| 2 -> Ok `AV2
|
|
||||||
| _ -> Error (`Msg "couldn't parse version")
|
|
||||||
|
|
||||||
let version_to_int = function
|
|
||||||
| `AV0 -> 0
|
|
||||||
| `AV1 -> 1
|
|
||||||
| `AV2 -> 2
|
|
||||||
|
|
||||||
let pp_version ppf v =
|
let pp_version ppf v =
|
||||||
Fmt.int ppf
|
Fmt.int ppf
|
||||||
(match v with
|
(match v with
|
||||||
|
@ -418,10 +407,15 @@ let policy_cmd =
|
||||||
(explicit 2 null))
|
(explicit 2 null))
|
||||||
|
|
||||||
let version =
|
let version =
|
||||||
let f data = match version_of_int data with
|
let f data = match data with
|
||||||
| Ok v -> v
|
| 0 -> `AV0
|
||||||
| Error (`Msg m) -> Asn.S.error (`Parse m)
|
| 1 -> `AV1
|
||||||
and g = version_to_int
|
| 2 -> `AV2
|
||||||
|
| _ -> Asn.S.error (`Parse "unknown version number")
|
||||||
|
and g = function
|
||||||
|
| `AV0 -> 0
|
||||||
|
| `AV1 -> 1
|
||||||
|
| `AV2 -> 2
|
||||||
in
|
in
|
||||||
Asn.S.map f g Asn.S.int
|
Asn.S.map f g Asn.S.int
|
||||||
|
|
||||||
|
|
|
@ -29,21 +29,9 @@ end
|
||||||
|
|
||||||
module IS = Set.Make(I)
|
module IS = Set.Make(I)
|
||||||
module IM = Map.Make(I)
|
module IM = Map.Make(I)
|
||||||
module IM64 = Map.Make(Int64)
|
|
||||||
|
|
||||||
type vmtype = [ `Hvt_amd64 | `Hvt_arm64 | `Hvt_amd64_compressed ]
|
type vmtype = [ `Hvt_amd64 | `Hvt_arm64 | `Hvt_amd64_compressed ]
|
||||||
|
|
||||||
let vmtype_to_int = function
|
|
||||||
| `Hvt_amd64 -> 0
|
|
||||||
| `Hvt_arm64 -> 1
|
|
||||||
| `Hvt_amd64_compressed -> 2
|
|
||||||
|
|
||||||
let int_to_vmtype = function
|
|
||||||
| 0 -> Some `Hvt_amd64
|
|
||||||
| 1 -> Some `Hvt_arm64
|
|
||||||
| 2 -> Some `Hvt_amd64_compressed
|
|
||||||
| _ -> None
|
|
||||||
|
|
||||||
let pp_vmtype ppf = function
|
let pp_vmtype ppf = function
|
||||||
| `Hvt_amd64 -> Fmt.pf ppf "hvt-amd64"
|
| `Hvt_amd64 -> Fmt.pf ppf "hvt-amd64"
|
||||||
| `Hvt_amd64_compressed -> Fmt.pf ppf "hvt-amd64-compressed"
|
| `Hvt_amd64_compressed -> Fmt.pf ppf "hvt-amd64-compressed"
|
||||||
|
@ -188,14 +176,6 @@ let translate_tap vm tap =
|
||||||
| [ (_, b) ] -> Some b
|
| [ (_, b) ] -> Some b
|
||||||
| _ -> None
|
| _ -> None
|
||||||
|
|
||||||
let identifier serial =
|
|
||||||
match Hex.of_cstruct @@ Nocrypto.Hash.SHA256.digest @@
|
|
||||||
Nocrypto.Numeric.Z.to_cstruct_be @@ serial
|
|
||||||
with
|
|
||||||
| `Hex str -> str
|
|
||||||
|
|
||||||
let id cert = identifier (X509.serial cert)
|
|
||||||
|
|
||||||
let name cert = X509.common_name_to_string cert
|
let name cert = X509.common_name_to_string cert
|
||||||
|
|
||||||
(* this separates the leaf and top-level certificate from the chain,
|
(* this separates the leaf and top-level certificate from the chain,
|
||||||
|
|
|
@ -14,13 +14,7 @@ module IM : sig
|
||||||
include Map.S with type key = I.t
|
include Map.S with type key = I.t
|
||||||
end
|
end
|
||||||
|
|
||||||
module IM64 : sig
|
|
||||||
include Map.S with type key = Int64.t
|
|
||||||
end
|
|
||||||
|
|
||||||
type vmtype = [ `Hvt_amd64 | `Hvt_amd64_compressed | `Hvt_arm64 ]
|
type vmtype = [ `Hvt_amd64 | `Hvt_amd64_compressed | `Hvt_arm64 ]
|
||||||
val vmtype_to_int : vmtype -> int
|
|
||||||
val int_to_vmtype : int -> vmtype option
|
|
||||||
val pp_vmtype : vmtype Fmt.t
|
val pp_vmtype : vmtype Fmt.t
|
||||||
|
|
||||||
type id = string list
|
type id = string list
|
||||||
|
@ -81,8 +75,6 @@ type vm = {
|
||||||
val pp_vm : vm Fmt.t
|
val pp_vm : vm Fmt.t
|
||||||
val translate_tap : vm -> string -> string option
|
val translate_tap : vm -> string -> string option
|
||||||
|
|
||||||
val identifier : Nocrypto.Numeric.Z.t -> string
|
|
||||||
val id : X509.t -> string
|
|
||||||
val name : X509.t -> string
|
val name : X509.t -> string
|
||||||
|
|
||||||
val separate_chain : 'a list -> ('a * 'a list, [> `Msg of string ]) result
|
val separate_chain : 'a list -> ('a * 'a list, [> `Msg of string ]) result
|
||||||
|
|
Loading…
Reference in a new issue