blake3-rb 1.5.3 → 1.5.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Cargo.lock +193 -55
- data/Cargo.toml +1 -0
- data/ext/digest/blake3_ext/Cargo.toml +10 -2
- data/ext/digest/blake3_ext/build.rs +4 -0
- data/ext/digest/blake3_ext/src/lib.rs +138 -40
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79bfa02f801439d4336e9cc5d1c6f66b3fea5ee900fa327c98a76006289610cb
|
4
|
+
data.tar.gz: a84aff893fc9fb311103464071c2628fe398feb370f8afb2092c8a72663fd473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f55aad4696d2c13f956472e3193c68501fef7f1a698d86757bb251d533c6a44d2799d24842053e49ddab0f2ca01462d34583daf8fd9a61513a0341ac0bfde95c
|
7
|
+
data.tar.gz: 06ffcdbc95270b3ae7b3b7a9ff242cd5cb9388aef94d8e7fcfc669d24e357d2913b09f1566eb24785c55e39044fa971c342eb97dfee343f16bc8161e13434e06
|
data/Cargo.lock
CHANGED
@@ -4,9 +4,9 @@ version = 3
|
|
4
4
|
|
5
5
|
[[package]]
|
6
6
|
name = "aho-corasick"
|
7
|
-
version = "1.1.
|
7
|
+
version = "1.1.3"
|
8
8
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
9
|
-
checksum = "
|
9
|
+
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
10
10
|
dependencies = [
|
11
11
|
"memchr",
|
12
12
|
]
|
@@ -25,16 +25,16 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
|
|
25
25
|
|
26
26
|
[[package]]
|
27
27
|
name = "bindgen"
|
28
|
-
version = "0.
|
28
|
+
version = "0.69.4"
|
29
29
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
30
|
-
checksum = "
|
30
|
+
checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
|
31
31
|
dependencies = [
|
32
32
|
"bitflags",
|
33
33
|
"cexpr",
|
34
34
|
"clang-sys",
|
35
|
+
"itertools",
|
35
36
|
"lazy_static",
|
36
37
|
"lazycell",
|
37
|
-
"peeking_take_while",
|
38
38
|
"proc-macro2",
|
39
39
|
"quote",
|
40
40
|
"regex",
|
@@ -45,15 +45,15 @@ dependencies = [
|
|
45
45
|
|
46
46
|
[[package]]
|
47
47
|
name = "bitflags"
|
48
|
-
version = "2.
|
48
|
+
version = "2.5.0"
|
49
49
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
50
|
-
checksum = "
|
50
|
+
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
|
51
51
|
|
52
52
|
[[package]]
|
53
53
|
name = "blake3"
|
54
|
-
version = "1.5.
|
54
|
+
version = "1.5.1"
|
55
55
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
56
|
-
checksum = "
|
56
|
+
checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52"
|
57
57
|
dependencies = [
|
58
58
|
"arrayref",
|
59
59
|
"arrayvec",
|
@@ -67,17 +67,18 @@ name = "blake3_ext"
|
|
67
67
|
version = "0.1.0"
|
68
68
|
dependencies = [
|
69
69
|
"blake3",
|
70
|
+
"hex",
|
71
|
+
"rand",
|
70
72
|
"rb-sys",
|
73
|
+
"rb-sys-env",
|
74
|
+
"rb-sys-test-helpers",
|
71
75
|
]
|
72
76
|
|
73
77
|
[[package]]
|
74
78
|
name = "cc"
|
75
|
-
version = "1.0.
|
79
|
+
version = "1.0.97"
|
76
80
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
77
|
-
checksum = "
|
78
|
-
dependencies = [
|
79
|
-
"libc",
|
80
|
-
]
|
81
|
+
checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4"
|
81
82
|
|
82
83
|
[[package]]
|
83
84
|
name = "cexpr"
|
@@ -96,9 +97,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
96
97
|
|
97
98
|
[[package]]
|
98
99
|
name = "clang-sys"
|
99
|
-
version = "1.
|
100
|
+
version = "1.7.0"
|
100
101
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
101
|
-
checksum = "
|
102
|
+
checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1"
|
102
103
|
dependencies = [
|
103
104
|
"glob",
|
104
105
|
"libc",
|
@@ -111,12 +112,44 @@ version = "0.3.0"
|
|
111
112
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
112
113
|
checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
|
113
114
|
|
115
|
+
[[package]]
|
116
|
+
name = "either"
|
117
|
+
version = "1.11.0"
|
118
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
119
|
+
checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2"
|
120
|
+
|
121
|
+
[[package]]
|
122
|
+
name = "getrandom"
|
123
|
+
version = "0.2.15"
|
124
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
125
|
+
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
126
|
+
dependencies = [
|
127
|
+
"cfg-if",
|
128
|
+
"libc",
|
129
|
+
"wasi",
|
130
|
+
]
|
131
|
+
|
114
132
|
[[package]]
|
115
133
|
name = "glob"
|
116
134
|
version = "0.3.1"
|
117
135
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
118
136
|
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
119
137
|
|
138
|
+
[[package]]
|
139
|
+
name = "hex"
|
140
|
+
version = "0.4.3"
|
141
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
142
|
+
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
143
|
+
|
144
|
+
[[package]]
|
145
|
+
name = "itertools"
|
146
|
+
version = "0.12.1"
|
147
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
148
|
+
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
149
|
+
dependencies = [
|
150
|
+
"either",
|
151
|
+
]
|
152
|
+
|
120
153
|
[[package]]
|
121
154
|
name = "lazy_static"
|
122
155
|
version = "1.4.0"
|
@@ -131,25 +164,25 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|
131
164
|
|
132
165
|
[[package]]
|
133
166
|
name = "libc"
|
134
|
-
version = "0.2.
|
167
|
+
version = "0.2.154"
|
135
168
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
136
|
-
checksum = "
|
169
|
+
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
|
137
170
|
|
138
171
|
[[package]]
|
139
172
|
name = "libloading"
|
140
|
-
version = "0.
|
173
|
+
version = "0.8.3"
|
141
174
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
142
|
-
checksum = "
|
175
|
+
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
143
176
|
dependencies = [
|
144
177
|
"cfg-if",
|
145
|
-
"
|
178
|
+
"windows-targets",
|
146
179
|
]
|
147
180
|
|
148
181
|
[[package]]
|
149
182
|
name = "memchr"
|
150
|
-
version = "2.
|
183
|
+
version = "2.7.2"
|
151
184
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
152
|
-
checksum = "
|
185
|
+
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
153
186
|
|
154
187
|
[[package]]
|
155
188
|
name = "minimal-lexical"
|
@@ -168,43 +201,73 @@ dependencies = [
|
|
168
201
|
]
|
169
202
|
|
170
203
|
[[package]]
|
171
|
-
name = "
|
172
|
-
version = "0.
|
204
|
+
name = "ppv-lite86"
|
205
|
+
version = "0.2.17"
|
173
206
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
174
|
-
checksum = "
|
207
|
+
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
175
208
|
|
176
209
|
[[package]]
|
177
210
|
name = "proc-macro2"
|
178
|
-
version = "1.0.
|
211
|
+
version = "1.0.82"
|
179
212
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
180
|
-
checksum = "
|
213
|
+
checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b"
|
181
214
|
dependencies = [
|
182
215
|
"unicode-ident",
|
183
216
|
]
|
184
217
|
|
185
218
|
[[package]]
|
186
219
|
name = "quote"
|
187
|
-
version = "1.0.
|
220
|
+
version = "1.0.36"
|
188
221
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
189
|
-
checksum = "
|
222
|
+
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
190
223
|
dependencies = [
|
191
224
|
"proc-macro2",
|
192
225
|
]
|
193
226
|
|
227
|
+
[[package]]
|
228
|
+
name = "rand"
|
229
|
+
version = "0.8.5"
|
230
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
231
|
+
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
232
|
+
dependencies = [
|
233
|
+
"libc",
|
234
|
+
"rand_chacha",
|
235
|
+
"rand_core",
|
236
|
+
]
|
237
|
+
|
238
|
+
[[package]]
|
239
|
+
name = "rand_chacha"
|
240
|
+
version = "0.3.1"
|
241
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
242
|
+
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
243
|
+
dependencies = [
|
244
|
+
"ppv-lite86",
|
245
|
+
"rand_core",
|
246
|
+
]
|
247
|
+
|
248
|
+
[[package]]
|
249
|
+
name = "rand_core"
|
250
|
+
version = "0.6.4"
|
251
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
252
|
+
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
253
|
+
dependencies = [
|
254
|
+
"getrandom",
|
255
|
+
]
|
256
|
+
|
194
257
|
[[package]]
|
195
258
|
name = "rb-sys"
|
196
|
-
version = "0.9.
|
259
|
+
version = "0.9.97"
|
197
260
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
198
|
-
checksum = "
|
261
|
+
checksum = "47d30bcad206b51f2f66121190ca678dce1fdf3a2eae0ac5d838d1818b19bdf5"
|
199
262
|
dependencies = [
|
200
263
|
"rb-sys-build",
|
201
264
|
]
|
202
265
|
|
203
266
|
[[package]]
|
204
267
|
name = "rb-sys-build"
|
205
|
-
version = "0.9.
|
268
|
+
version = "0.9.97"
|
206
269
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
207
|
-
checksum = "
|
270
|
+
checksum = "3cbd92f281615f3c2dcb9dcb0f0576624752afbf9a7f99173b37c4b55b62dd8a"
|
208
271
|
dependencies = [
|
209
272
|
"bindgen",
|
210
273
|
"lazy_static",
|
@@ -215,11 +278,38 @@ dependencies = [
|
|
215
278
|
"syn",
|
216
279
|
]
|
217
280
|
|
281
|
+
[[package]]
|
282
|
+
name = "rb-sys-env"
|
283
|
+
version = "0.1.2"
|
284
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
285
|
+
checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
|
286
|
+
|
287
|
+
[[package]]
|
288
|
+
name = "rb-sys-test-helpers"
|
289
|
+
version = "0.2.0"
|
290
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
291
|
+
checksum = "bbd592029353df7955a76ca0b1bf0d9ccc57feab96615f80d1fe756462864949"
|
292
|
+
dependencies = [
|
293
|
+
"rb-sys",
|
294
|
+
"rb-sys-env",
|
295
|
+
"rb-sys-test-helpers-macros",
|
296
|
+
]
|
297
|
+
|
298
|
+
[[package]]
|
299
|
+
name = "rb-sys-test-helpers-macros"
|
300
|
+
version = "0.2.0"
|
301
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
302
|
+
checksum = "c21f156459adb755d58f73dbd783dc1de8b403635e637f7d1daec1c7a920c1f5"
|
303
|
+
dependencies = [
|
304
|
+
"quote",
|
305
|
+
"syn",
|
306
|
+
]
|
307
|
+
|
218
308
|
[[package]]
|
219
309
|
name = "regex"
|
220
|
-
version = "1.10.
|
310
|
+
version = "1.10.4"
|
221
311
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
222
|
-
checksum = "
|
312
|
+
checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c"
|
223
313
|
dependencies = [
|
224
314
|
"aho-corasick",
|
225
315
|
"memchr",
|
@@ -229,9 +319,9 @@ dependencies = [
|
|
229
319
|
|
230
320
|
[[package]]
|
231
321
|
name = "regex-automata"
|
232
|
-
version = "0.4.
|
322
|
+
version = "0.4.6"
|
233
323
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
234
|
-
checksum = "
|
324
|
+
checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
|
235
325
|
dependencies = [
|
236
326
|
"aho-corasick",
|
237
327
|
"memchr",
|
@@ -240,9 +330,9 @@ dependencies = [
|
|
240
330
|
|
241
331
|
[[package]]
|
242
332
|
name = "regex-syntax"
|
243
|
-
version = "0.8.
|
333
|
+
version = "0.8.3"
|
244
334
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
245
|
-
checksum = "
|
335
|
+
checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
|
246
336
|
|
247
337
|
[[package]]
|
248
338
|
name = "rustc-hash"
|
@@ -258,15 +348,15 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
|
|
258
348
|
|
259
349
|
[[package]]
|
260
350
|
name = "shlex"
|
261
|
-
version = "1.
|
351
|
+
version = "1.3.0"
|
262
352
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
263
|
-
checksum = "
|
353
|
+
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
264
354
|
|
265
355
|
[[package]]
|
266
356
|
name = "syn"
|
267
|
-
version = "2.0.
|
357
|
+
version = "2.0.64"
|
268
358
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
269
|
-
checksum = "
|
359
|
+
checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f"
|
270
360
|
dependencies = [
|
271
361
|
"proc-macro2",
|
272
362
|
"quote",
|
@@ -280,23 +370,71 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
280
370
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
281
371
|
|
282
372
|
[[package]]
|
283
|
-
name = "
|
284
|
-
version = "0.
|
373
|
+
name = "wasi"
|
374
|
+
version = "0.11.0+wasi-snapshot-preview1"
|
375
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
376
|
+
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
377
|
+
|
378
|
+
[[package]]
|
379
|
+
name = "windows-targets"
|
380
|
+
version = "0.52.5"
|
285
381
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
286
|
-
checksum = "
|
382
|
+
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
|
287
383
|
dependencies = [
|
288
|
-
"
|
289
|
-
"
|
384
|
+
"windows_aarch64_gnullvm",
|
385
|
+
"windows_aarch64_msvc",
|
386
|
+
"windows_i686_gnu",
|
387
|
+
"windows_i686_gnullvm",
|
388
|
+
"windows_i686_msvc",
|
389
|
+
"windows_x86_64_gnu",
|
390
|
+
"windows_x86_64_gnullvm",
|
391
|
+
"windows_x86_64_msvc",
|
290
392
|
]
|
291
393
|
|
292
394
|
[[package]]
|
293
|
-
name = "
|
294
|
-
version = "0.
|
395
|
+
name = "windows_aarch64_gnullvm"
|
396
|
+
version = "0.52.5"
|
397
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
398
|
+
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
|
399
|
+
|
400
|
+
[[package]]
|
401
|
+
name = "windows_aarch64_msvc"
|
402
|
+
version = "0.52.5"
|
403
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
404
|
+
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
|
405
|
+
|
406
|
+
[[package]]
|
407
|
+
name = "windows_i686_gnu"
|
408
|
+
version = "0.52.5"
|
409
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
410
|
+
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
|
411
|
+
|
412
|
+
[[package]]
|
413
|
+
name = "windows_i686_gnullvm"
|
414
|
+
version = "0.52.5"
|
415
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
416
|
+
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
|
417
|
+
|
418
|
+
[[package]]
|
419
|
+
name = "windows_i686_msvc"
|
420
|
+
version = "0.52.5"
|
421
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
422
|
+
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
|
423
|
+
|
424
|
+
[[package]]
|
425
|
+
name = "windows_x86_64_gnu"
|
426
|
+
version = "0.52.5"
|
427
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
428
|
+
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
|
429
|
+
|
430
|
+
[[package]]
|
431
|
+
name = "windows_x86_64_gnullvm"
|
432
|
+
version = "0.52.5"
|
295
433
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
296
|
-
checksum = "
|
434
|
+
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
|
297
435
|
|
298
436
|
[[package]]
|
299
|
-
name = "
|
300
|
-
version = "0.
|
437
|
+
name = "windows_x86_64_msvc"
|
438
|
+
version = "0.52.5"
|
301
439
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
302
|
-
checksum = "
|
440
|
+
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
data/Cargo.toml
CHANGED
@@ -10,5 +10,13 @@ publish = false
|
|
10
10
|
crate-type = ["cdylib"]
|
11
11
|
|
12
12
|
[dependencies]
|
13
|
-
rb-sys = { version = "0.9
|
14
|
-
blake3 = { version = "1.5
|
13
|
+
rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] }
|
14
|
+
blake3 = { version = "1.5" }
|
15
|
+
|
16
|
+
[dev-dependencies]
|
17
|
+
hex = "0.4.3"
|
18
|
+
rand = "0.8.5"
|
19
|
+
rb-sys-test-helpers = "0.2.0"
|
20
|
+
|
21
|
+
[build-dependencies]
|
22
|
+
rb-sys-env = "0.1.2"
|
@@ -5,57 +5,61 @@ use rb_sys::{
|
|
5
5
|
rb_cObject, rb_const_get, rb_define_class_under, rb_intern, rb_ivar_set, rb_require, size_t,
|
6
6
|
};
|
7
7
|
use std::ffi::{c_int, c_uchar, c_void};
|
8
|
+
use std::mem::MaybeUninit;
|
8
9
|
use std::os::raw::c_char;
|
9
10
|
|
10
11
|
use bindings::{rb_digest_make_metadata, RbDigestMetadataT, RUBY_DIGEST_API_VERSION};
|
11
12
|
|
12
|
-
const BLOCK_LEN: usize = 64;
|
13
|
-
const DIGEST_LEN: usize = 32;
|
14
|
-
|
15
13
|
#[repr(C)]
|
16
|
-
#[derive(Debug)]
|
17
|
-
struct
|
18
|
-
|
14
|
+
#[derive(Debug, Default)]
|
15
|
+
struct Blake3 {
|
16
|
+
hasher: Hasher,
|
19
17
|
}
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
block_len: BLOCK_LEN as _,
|
25
|
-
ctx_size: std::mem::size_of::<Blake3Ctx>() as _,
|
26
|
-
init_func: blake3_init,
|
27
|
-
update_func: blake3_update,
|
28
|
-
finish_func: blake3_finish,
|
29
|
-
};
|
19
|
+
impl Blake3 {
|
20
|
+
const BLOCK_LEN: usize = 64;
|
21
|
+
const DIGEST_LEN: usize = 32;
|
30
22
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
23
|
+
fn digest_metadata() -> &'static RbDigestMetadataT {
|
24
|
+
static DIGEST_METADATA: RbDigestMetadataT = RbDigestMetadataT {
|
25
|
+
api_version: RUBY_DIGEST_API_VERSION,
|
26
|
+
digest_len: Blake3::DIGEST_LEN as _,
|
27
|
+
block_len: Blake3::BLOCK_LEN as _,
|
28
|
+
ctx_size: std::mem::size_of::<Blake3>() as _,
|
29
|
+
init_func: Blake3::init_in_place,
|
30
|
+
update_func: Blake3::update,
|
31
|
+
finish_func: Blake3::finish,
|
32
|
+
};
|
33
|
+
&DIGEST_METADATA
|
34
|
+
}
|
38
35
|
|
39
|
-
//
|
40
|
-
extern "C" fn
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
// Initialize the context, which has already been allocated by Ruby.
|
37
|
+
extern "C" fn init_in_place(ctx: *mut c_void) -> c_int {
|
38
|
+
let ctx = ctx as *mut MaybeUninit<Blake3>;
|
39
|
+
let ctx = unsafe { &mut *ctx };
|
40
|
+
ctx.write(Blake3::default());
|
41
|
+
true as _
|
42
|
+
}
|
43
|
+
|
44
|
+
// Update the context with the given data.
|
45
|
+
extern "C" fn update(ctx: *mut c_void, data: *mut c_uchar, len: size_t) {
|
46
|
+
let ctx = ctx as *mut MaybeUninit<Blake3>;
|
47
|
+
let ctx = unsafe { &mut *ctx };
|
48
|
+
let ctx = unsafe { ctx.assume_init_mut() };
|
44
49
|
let slice = unsafe { std::slice::from_raw_parts(data, len as _) };
|
45
|
-
|
50
|
+
|
51
|
+
ctx.hasher.update(slice);
|
46
52
|
}
|
47
|
-
}
|
48
53
|
|
49
|
-
// Finalize the context and write the digest to the given pointer.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
let
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
0
|
54
|
+
// Finalize the context and write the digest to the given pointer. The
|
55
|
+
// memory for the digest is managed by Ruby, so we don't need to free it.
|
56
|
+
extern "C" fn finish(ctx: *mut c_void, digest: *mut c_uchar) -> c_int {
|
57
|
+
let ctx = ctx as *mut MaybeUninit<Blake3>;
|
58
|
+
let ctx = unsafe { &mut *ctx };
|
59
|
+
let ctx = unsafe { ctx.assume_init_mut() };
|
60
|
+
let outbuf = unsafe { std::slice::from_raw_parts_mut(digest, Self::DIGEST_LEN) };
|
61
|
+
ctx.hasher.finalize_xof().fill(outbuf);
|
62
|
+
true as _
|
59
63
|
}
|
60
64
|
}
|
61
65
|
|
@@ -71,7 +75,101 @@ pub unsafe extern "C" fn Init_blake3_ext() {
|
|
71
75
|
"Blake3\0".as_ptr() as *const c_char,
|
72
76
|
digest_base,
|
73
77
|
);
|
74
|
-
let meta = rb_digest_make_metadata(
|
78
|
+
let meta = rb_digest_make_metadata(Blake3::digest_metadata());
|
75
79
|
let metadata_id = rb_intern("metadata\0".as_ptr() as *const c_char);
|
76
80
|
rb_ivar_set(klass, metadata_id, meta);
|
77
81
|
}
|
82
|
+
|
83
|
+
#[cfg(test)]
|
84
|
+
mod tests {
|
85
|
+
use rb_sys::{
|
86
|
+
rb_cObject, rb_const_get, rb_enc_set_index, rb_funcallv_public, rb_intern, rb_str_new,
|
87
|
+
rb_utf8_encindex, RSTRING_LEN, RSTRING_PTR,
|
88
|
+
};
|
89
|
+
use rb_sys_test_helpers::{protect, ruby_test};
|
90
|
+
|
91
|
+
use crate::Init_blake3_ext;
|
92
|
+
|
93
|
+
#[ruby_test]
|
94
|
+
fn fuzz_parity_binary() {
|
95
|
+
setup();
|
96
|
+
|
97
|
+
for _ in 0..1024 {
|
98
|
+
let input_data = gen_random_bytes(4096);
|
99
|
+
let expected = compute_rust_digest(input_data.as_slice());
|
100
|
+
let actual = compute_ruby_digest(input_data.as_slice(), rb_utf8_encindex);
|
101
|
+
|
102
|
+
assert_eq!(expected, actual);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
#[ruby_test]
|
107
|
+
fn fuzz_parity_utf8() {
|
108
|
+
setup();
|
109
|
+
|
110
|
+
for _ in 0..1024 {
|
111
|
+
let input_data = gen_random_string(512);
|
112
|
+
let expected = compute_rust_digest(&input_data);
|
113
|
+
let actual = compute_ruby_digest(&input_data, rb_utf8_encindex);
|
114
|
+
|
115
|
+
assert_eq!(expected, actual);
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
fn setup() {
|
120
|
+
static INIT: std::sync::Once = std::sync::Once::new();
|
121
|
+
INIT.call_once(|| {
|
122
|
+
protect(|| unsafe { Init_blake3_ext() })
|
123
|
+
.expect("Failed to initialize Blake3 extension");
|
124
|
+
});
|
125
|
+
}
|
126
|
+
|
127
|
+
fn gen_random_bytes(max_len: usize) -> Vec<u8> {
|
128
|
+
let size = rand::random::<usize>() % max_len;
|
129
|
+
(0..size).map(|_| rand::random::<u8>()).collect()
|
130
|
+
}
|
131
|
+
|
132
|
+
fn gen_random_string(max_len: usize) -> String {
|
133
|
+
let size = rand::random::<usize>() % max_len;
|
134
|
+
(0..size)
|
135
|
+
.map(|_| rand::random::<char>())
|
136
|
+
.collect::<String>()
|
137
|
+
}
|
138
|
+
|
139
|
+
fn compute_rust_digest<T: AsRef<[u8]>>(input: T) -> String {
|
140
|
+
let mut hasher = blake3::Hasher::new();
|
141
|
+
hasher.update(input.as_ref());
|
142
|
+
let mut result = [0u8; 32];
|
143
|
+
hasher.finalize_xof().fill(&mut result);
|
144
|
+
hex::encode(result)
|
145
|
+
}
|
146
|
+
|
147
|
+
fn compute_ruby_digest<T: AsRef<[u8]>>(
|
148
|
+
input: T,
|
149
|
+
encoding: unsafe extern "C" fn() -> i32,
|
150
|
+
) -> String {
|
151
|
+
let input = input.as_ref();
|
152
|
+
let ruby_digest = protect(|| unsafe {
|
153
|
+
Init_blake3_ext();
|
154
|
+
let klass = rb_const_get(rb_cObject, rb_intern("Digest\0".as_ptr() as _));
|
155
|
+
let klass = rb_const_get(klass, rb_intern("Blake3\0".as_ptr() as _));
|
156
|
+
let string = rb_str_new(input.as_ptr() as _, input.len() as _);
|
157
|
+
rb_enc_set_index(string, encoding());
|
158
|
+
let mut args = [string];
|
159
|
+
rb_funcallv_public(
|
160
|
+
klass,
|
161
|
+
rb_intern("hexdigest\0".as_ptr() as _),
|
162
|
+
args.len() as _,
|
163
|
+
args.as_mut_ptr(),
|
164
|
+
)
|
165
|
+
})
|
166
|
+
.unwrap();
|
167
|
+
|
168
|
+
let rstring_ptr = unsafe { RSTRING_PTR(ruby_digest) };
|
169
|
+
let rstring_len = unsafe { RSTRING_LEN(ruby_digest) };
|
170
|
+
|
171
|
+
let bytes =
|
172
|
+
unsafe { std::slice::from_raw_parts(rstring_ptr as *const u8, rstring_len as _) };
|
173
|
+
std::str::from_utf8(bytes).unwrap().to_string()
|
174
|
+
}
|
175
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blake3-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Ker-Seymer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rb_sys
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- LICENSE.txt
|
37
37
|
- README.md
|
38
38
|
- ext/digest/blake3_ext/Cargo.toml
|
39
|
+
- ext/digest/blake3_ext/build.rs
|
39
40
|
- ext/digest/blake3_ext/extconf.rb
|
40
41
|
- ext/digest/blake3_ext/src/bindings.rs
|
41
42
|
- ext/digest/blake3_ext/src/lib.rs
|
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
64
|
- !ruby/object:Gem::Version
|
64
65
|
version: '0'
|
65
66
|
requirements: []
|
66
|
-
rubygems_version: 3.4.
|
67
|
+
rubygems_version: 3.4.19
|
67
68
|
signing_key:
|
68
69
|
specification_version: 4
|
69
70
|
summary: Blake3 hash function bindings for Ruby.
|