@@ -89,13 +89,15 @@ module Counters = struct
89
89
val unsafe_count_into : ctr -> Native .buffer -> int -> blocks :int -> unit
90
90
end
91
91
92
+ let _tmp = Domain_shims.DLS. new_key (Fun. const (Bytes. make 16 '\000' ))
93
+
92
94
module C64be = struct
93
95
type ctr = int64
94
96
let size = 8
95
97
let of_cstruct cs = BE. get_uint64 cs 0
96
98
let add = Int64. add
97
99
let unsafe_count_into t buf off ~blocks =
98
- let _tmp = Bytes. make 16 '\x00' in
100
+ let _tmp = Domain_shims.DLS. get _tmp in
99
101
Bytes. set_int64_be _tmp 0 t;
100
102
Native. count8be _tmp buf off ~blocks
101
103
end
@@ -109,7 +111,7 @@ module Counters = struct
109
111
let flip = if Int64. logxor w0 w0' < 0L then w0' > w0 else w0' < w0 in
110
112
((if flip then Int64. succ w1 else w1), w0')
111
113
let unsafe_count_into (w1 , w0 ) buf off ~blocks =
112
- let _tmp = Bytes. make 16 '\x00' in
114
+ let _tmp = Domain_shims.DLS. get _tmp in
113
115
Bytes. set_int64_be _tmp 0 w1; Bytes. set_int64_be _tmp 8 w0;
114
116
Native. count16be _tmp buf off ~blocks
115
117
end
@@ -120,7 +122,7 @@ module Counters = struct
120
122
let hi = 0xffffffff00000000L and lo = 0x00000000ffffffffL in
121
123
(w1, Int64. (logor (logand hi w0) (add n w0 |> logand lo)))
122
124
let unsafe_count_into (w1 , w0 ) buf off ~blocks =
123
- let _tmp = Bytes. make 16 '\x00' in
125
+ let _tmp = Domain_shims.DLS. get _tmp in
124
126
Bytes. set_int64_be _tmp 0 w1; Bytes. set_int64_be _tmp 8 w0;
125
127
Native. count16be4 _tmp buf off ~blocks
126
128
end
@@ -240,11 +242,12 @@ module Modes = struct
240
242
assert (cs.len > = tagsize);
241
243
let k = Bytes. create keysize in
242
244
Native.GHASH. keyinit cs.buffer cs.off k; k
245
+ let _cs = Domain_shims.DLS. new_key (Fun. const (create_unsafe tagsize))
243
246
let hash0 = Bytes. make tagsize '\x00'
244
247
let digesti ~key i = (* Clobbers `_cs`! *)
245
- let _cs = create_unsafe tagsize in
246
248
let res = Bytes. copy hash0 in
247
249
i (fun cs -> Native.GHASH. ghash key res cs.buffer cs.off cs.len);
250
+ let _cs = Domain_shims.DLS. get _cs in
248
251
blit_from_bytes res 0 _cs 0 tagsize; _cs
249
252
end
250
253
@@ -257,17 +260,19 @@ module Modes = struct
257
260
258
261
let tag_size = GHASH. tagsize
259
262
let key_sizes, block_size = C. (key, block)
263
+ let z128 = Domain_shims.DLS. new_key (Fun. const (create block_size))
264
+ let h = Domain_shims.DLS. new_key (Fun. const (create block_size))
260
265
261
266
let of_secret cs =
262
267
let key = C. e_of_secret cs in
263
- let z128 = create block_size in
264
- let h = create block_size in
268
+ let z128 = Domain_shims.DLS. get z128 in
269
+ let h = Domain_shims.DLS. get h in
265
270
C. encrypt ~key ~blocks: 1 z128.buffer z128.off h.buffer h.off;
266
271
{ key ; hkey = GHASH. derive h }
267
272
268
273
let bits64 cs = Int64. of_int (length cs * 8 )
269
- let pack64s = fun a b ->
270
- let _cs = create_unsafe 16 in
274
+ let _cs = Domain_shims.DLS. new_key ( Fun. const (create_unsafe 16 ))
275
+ let pack64s = let _cs = Domain_shims.DLS. get _cs in fun a b ->
271
276
BE. set_uint64 _cs 0 a; BE. set_uint64 _cs 8 b; _cs
272
277
273
278
let counter ~hkey nonce = match length nonce with
0 commit comments