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
let cstruct_of_array arr =
let r = Cstruct.create (Array.length arr) in
Array.iteri (fun idx v -> Cstruct.set_uint8 r idx v) arr;
r
let id_sha1 = [|
0x30; 0x21;
0x30; 0x09;
0x06; 0x05;
0x2b; 0x0e; 0x03; 0x02; 0x1a;
0x05; 0x00;
0x04; 0x14
|] |> cstruct_of_array
let id_sha256 = [|
0x30; 0x31;
0x30; 0x0d;
0x06; 0x09;
0x60; 0x86; 0x48; 0x01; 0x65; 0x03; 0x04; 0x02; 0x01;
0x05; 0x00;
0x04; 0x20
|] |> cstruct_of_array
let id_sha512 = [|
0x30; 0x51;
0x30; 0x0d;
0x06; 0x09;
0x60; 0x86; 0x48; 0x01; 0x65; 0x03; 0x04; 0x02; 0x03;
0x05; 0x00;
0x04; 0x40
|] |> cstruct_of_array
let cstruct_is_prefix prefix other =
Cstruct.equal prefix (Cstruct.sub other 0 (Cstruct.len prefix))