package pkcs11-driver

  1. Overview
  2. Docs
Bindings to the PKCS#11 cryptographic API

Install

dune-project
 Dependency

Authors

Maintainers

Sources

pkcs11-v1.0.1.tbz
sha256=db6bed28e4a75cb3787d0b6feca954a91c9e52e678b8cc73c1058975b1846946
sha512=f764b356cac3dd7718003a158f2a4dad7b8caae981930ab9cfa674a08ebcf3583c531bfcca9ddbb593d0c8e5a64b52381f8c9c702c3a0d0d44000727b095c47a

doc/src/pkcs11-driver/pkcs11_mechanism_list.ml.html

Source file pkcs11_mechanism_list.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
open Ctypes

type _t

type t =
  { length : P11_ulong.t ptr
  ; mutable content : Pkcs11_CK_MECHANISM_TYPE.t ptr }

type u = P11_mechanism_type.t list

let get_length (t : t) : P11_ulong.t = !@(t.length)

let get_content (t : t) : Pkcs11_CK_MECHANISM_TYPE.t ptr = t.content

let get_length_addr (t : t) : P11_ulong.t ptr = t.length

let create () : t =
  { length = Ctypes.allocate ulong Unsigned.ULong.zero
  ; content = from_voidp Pkcs11_CK_MECHANISM_TYPE.typ null }

let allocate (t : t) : unit =
  let n = get_length t |> Unsigned.ULong.to_int in
  let data = allocate_n Pkcs11_CK_MECHANISM_TYPE.typ ~count:n in
  t.content <- data;
  ()

let of_raw content length = {length; content}

let view (t : t) : u =
  let length = get_length t |> Unsigned.ULong.to_int in
  let array = CArray.from_ptr (get_content t) length in
  List.map Pkcs11_CK_MECHANISM_TYPE.view @@ CArray.to_list array

let make (u : u) : t =
  let array =
    u
    |> List.map Pkcs11_CK_MECHANISM_TYPE.make
    |> CArray.of_list Pkcs11_CK_MECHANISM_TYPE.typ
  in
  { length = Ctypes.allocate ulong (Unsigned.ULong.of_int (List.length u))
  ; content = CArray.start array }