blake3-rb 1.5.6.rc1-aarch64-linux → 1.8.3.0-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/digest/blake3/3.2/blake3_ext.so +0 -0
- data/lib/digest/blake3/3.3/blake3_ext.so +0 -0
- data/lib/digest/blake3/3.4/blake3_ext.so +0 -0
- data/lib/digest/blake3/4.0/blake3_ext.so +0 -0
- data/lib/digest/blake3.rb +5 -1
- metadata +6 -27
- data/Cargo.lock +0 -473
- data/Cargo.toml +0 -13
- data/ext/digest/blake3_ext/Cargo.toml +0 -28
- data/ext/digest/blake3_ext/build.rs +0 -4
- data/ext/digest/blake3_ext/extconf.rb +0 -25
- data/ext/digest/blake3_ext/src/bindings.rs +0 -66
- data/ext/digest/blake3_ext/src/lib.rs +0 -176
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d80432aba3a61f5a8361730bfc6993fd1423690f50a6d280a1a93be8c544a04
|
|
4
|
+
data.tar.gz: f90bc7c30821d2b162f6fc3fa24465703a73aea310846f9f419664087c0bf3cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20c1e44ca551c9a06b3ea82fc41e463b10a1a34432147f45146a7c10bbcab0723a289b087712724c652a03a518fc0cc0aa459faada050b4794452646128d6ffa
|
|
7
|
+
data.tar.gz: a3e4b54192ab14bd2c364121c424ca0e99388d1b53ce46655ec48c1e29816f4c5b293028445c3c16114053cffe3e1918e940783bcbf863a4e6090afeac33fe96
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/digest/blake3.rb
CHANGED
|
@@ -12,5 +12,9 @@ begin
|
|
|
12
12
|
RUBY_VERSION =~ /(\d+\.\d+)/
|
|
13
13
|
require "digest/blake3/#{Regexp.last_match(1)}/blake3_ext"
|
|
14
14
|
rescue LoadError
|
|
15
|
-
|
|
15
|
+
begin
|
|
16
|
+
require_relative "blake3/blake3_ext"
|
|
17
|
+
rescue LoadError
|
|
18
|
+
require "digest/blake3/blake3_ext"
|
|
19
|
+
end
|
|
16
20
|
end
|
metadata
CHANGED
|
@@ -1,44 +1,23 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blake3-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.3.0
|
|
5
5
|
platform: aarch64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Ian Ker-Seymer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: rb_sys
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0.9'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0.9'
|
|
11
|
+
date: 2026-02-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
27
13
|
description: Provides native bindings to the Blake3 hash function for Ruby.
|
|
28
14
|
email:
|
|
29
15
|
executables: []
|
|
30
16
|
extensions: []
|
|
31
17
|
extra_rdoc_files: []
|
|
32
18
|
files:
|
|
33
|
-
- Cargo.lock
|
|
34
|
-
- Cargo.toml
|
|
35
19
|
- LICENSE.txt
|
|
36
20
|
- README.md
|
|
37
|
-
- ext/digest/blake3_ext/Cargo.toml
|
|
38
|
-
- ext/digest/blake3_ext/build.rs
|
|
39
|
-
- ext/digest/blake3_ext/extconf.rb
|
|
40
|
-
- ext/digest/blake3_ext/src/bindings.rs
|
|
41
|
-
- ext/digest/blake3_ext/src/lib.rs
|
|
42
21
|
- lib/blake3-rb.rb
|
|
43
22
|
- lib/digest/blake3.rb
|
|
44
23
|
- lib/digest/blake3/3.2/blake3_ext.so
|
|
@@ -66,11 +45,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
66
45
|
version: 4.1.dev
|
|
67
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
47
|
requirements:
|
|
69
|
-
- - "
|
|
48
|
+
- - ">="
|
|
70
49
|
- !ruby/object:Gem::Version
|
|
71
|
-
version:
|
|
50
|
+
version: '0'
|
|
72
51
|
requirements: []
|
|
73
|
-
rubygems_version: 3.
|
|
52
|
+
rubygems_version: 3.5.23
|
|
74
53
|
signing_key:
|
|
75
54
|
specification_version: 4
|
|
76
55
|
summary: Blake3 hash function bindings for Ruby.
|
data/Cargo.lock
DELETED
|
@@ -1,473 +0,0 @@
|
|
|
1
|
-
# This file is automatically @generated by Cargo.
|
|
2
|
-
# It is not intended for manual editing.
|
|
3
|
-
version = 4
|
|
4
|
-
|
|
5
|
-
[[package]]
|
|
6
|
-
name = "aho-corasick"
|
|
7
|
-
version = "1.1.3"
|
|
8
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
-
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
|
10
|
-
dependencies = [
|
|
11
|
-
"memchr",
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
[[package]]
|
|
15
|
-
name = "arrayref"
|
|
16
|
-
version = "0.3.9"
|
|
17
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
-
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
|
|
19
|
-
|
|
20
|
-
[[package]]
|
|
21
|
-
name = "arrayvec"
|
|
22
|
-
version = "0.7.6"
|
|
23
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
|
-
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
|
25
|
-
|
|
26
|
-
[[package]]
|
|
27
|
-
name = "bindgen"
|
|
28
|
-
version = "0.69.5"
|
|
29
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
30
|
-
checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
|
|
31
|
-
dependencies = [
|
|
32
|
-
"bitflags",
|
|
33
|
-
"cexpr",
|
|
34
|
-
"clang-sys",
|
|
35
|
-
"itertools",
|
|
36
|
-
"lazy_static",
|
|
37
|
-
"lazycell",
|
|
38
|
-
"proc-macro2",
|
|
39
|
-
"quote",
|
|
40
|
-
"regex",
|
|
41
|
-
"rustc-hash",
|
|
42
|
-
"shlex",
|
|
43
|
-
"syn",
|
|
44
|
-
]
|
|
45
|
-
|
|
46
|
-
[[package]]
|
|
47
|
-
name = "bitflags"
|
|
48
|
-
version = "2.7.0"
|
|
49
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
50
|
-
checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be"
|
|
51
|
-
|
|
52
|
-
[[package]]
|
|
53
|
-
name = "blake3"
|
|
54
|
-
version = "1.5.5"
|
|
55
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
56
|
-
checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e"
|
|
57
|
-
dependencies = [
|
|
58
|
-
"arrayref",
|
|
59
|
-
"arrayvec",
|
|
60
|
-
"cc",
|
|
61
|
-
"cfg-if",
|
|
62
|
-
"constant_time_eq",
|
|
63
|
-
]
|
|
64
|
-
|
|
65
|
-
[[package]]
|
|
66
|
-
name = "blake3_ext"
|
|
67
|
-
version = "0.1.0"
|
|
68
|
-
dependencies = [
|
|
69
|
-
"blake3",
|
|
70
|
-
"hex",
|
|
71
|
-
"rand",
|
|
72
|
-
"rb-sys",
|
|
73
|
-
"rb-sys-env",
|
|
74
|
-
"rb-sys-test-helpers",
|
|
75
|
-
]
|
|
76
|
-
|
|
77
|
-
[[package]]
|
|
78
|
-
name = "byteorder"
|
|
79
|
-
version = "1.5.0"
|
|
80
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
81
|
-
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|
82
|
-
|
|
83
|
-
[[package]]
|
|
84
|
-
name = "cc"
|
|
85
|
-
version = "1.2.8"
|
|
86
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
87
|
-
checksum = "ad0cf6e91fde44c773c6ee7ec6bba798504641a8bc2eb7e37a04ffbf4dfaa55a"
|
|
88
|
-
dependencies = [
|
|
89
|
-
"shlex",
|
|
90
|
-
]
|
|
91
|
-
|
|
92
|
-
[[package]]
|
|
93
|
-
name = "cexpr"
|
|
94
|
-
version = "0.6.0"
|
|
95
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
96
|
-
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
|
97
|
-
dependencies = [
|
|
98
|
-
"nom",
|
|
99
|
-
]
|
|
100
|
-
|
|
101
|
-
[[package]]
|
|
102
|
-
name = "cfg-if"
|
|
103
|
-
version = "1.0.0"
|
|
104
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
105
|
-
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
106
|
-
|
|
107
|
-
[[package]]
|
|
108
|
-
name = "clang-sys"
|
|
109
|
-
version = "1.8.1"
|
|
110
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
111
|
-
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
|
|
112
|
-
dependencies = [
|
|
113
|
-
"glob",
|
|
114
|
-
"libc",
|
|
115
|
-
"libloading",
|
|
116
|
-
]
|
|
117
|
-
|
|
118
|
-
[[package]]
|
|
119
|
-
name = "constant_time_eq"
|
|
120
|
-
version = "0.3.1"
|
|
121
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
122
|
-
checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
|
|
123
|
-
|
|
124
|
-
[[package]]
|
|
125
|
-
name = "either"
|
|
126
|
-
version = "1.13.0"
|
|
127
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
128
|
-
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
|
129
|
-
|
|
130
|
-
[[package]]
|
|
131
|
-
name = "getrandom"
|
|
132
|
-
version = "0.2.15"
|
|
133
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
134
|
-
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
|
135
|
-
dependencies = [
|
|
136
|
-
"cfg-if",
|
|
137
|
-
"libc",
|
|
138
|
-
"wasi",
|
|
139
|
-
]
|
|
140
|
-
|
|
141
|
-
[[package]]
|
|
142
|
-
name = "glob"
|
|
143
|
-
version = "0.3.2"
|
|
144
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
145
|
-
checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2"
|
|
146
|
-
|
|
147
|
-
[[package]]
|
|
148
|
-
name = "hex"
|
|
149
|
-
version = "0.4.3"
|
|
150
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
151
|
-
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
|
152
|
-
|
|
153
|
-
[[package]]
|
|
154
|
-
name = "itertools"
|
|
155
|
-
version = "0.12.1"
|
|
156
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
157
|
-
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
|
158
|
-
dependencies = [
|
|
159
|
-
"either",
|
|
160
|
-
]
|
|
161
|
-
|
|
162
|
-
[[package]]
|
|
163
|
-
name = "lazy_static"
|
|
164
|
-
version = "1.5.0"
|
|
165
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
166
|
-
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|
167
|
-
|
|
168
|
-
[[package]]
|
|
169
|
-
name = "lazycell"
|
|
170
|
-
version = "1.3.0"
|
|
171
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
172
|
-
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|
173
|
-
|
|
174
|
-
[[package]]
|
|
175
|
-
name = "libc"
|
|
176
|
-
version = "0.2.169"
|
|
177
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
178
|
-
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
|
179
|
-
|
|
180
|
-
[[package]]
|
|
181
|
-
name = "libloading"
|
|
182
|
-
version = "0.8.6"
|
|
183
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
184
|
-
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
|
185
|
-
dependencies = [
|
|
186
|
-
"cfg-if",
|
|
187
|
-
"windows-targets",
|
|
188
|
-
]
|
|
189
|
-
|
|
190
|
-
[[package]]
|
|
191
|
-
name = "memchr"
|
|
192
|
-
version = "2.7.4"
|
|
193
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
194
|
-
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
|
195
|
-
|
|
196
|
-
[[package]]
|
|
197
|
-
name = "minimal-lexical"
|
|
198
|
-
version = "0.2.1"
|
|
199
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
200
|
-
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|
201
|
-
|
|
202
|
-
[[package]]
|
|
203
|
-
name = "nom"
|
|
204
|
-
version = "7.1.3"
|
|
205
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
206
|
-
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
|
207
|
-
dependencies = [
|
|
208
|
-
"memchr",
|
|
209
|
-
"minimal-lexical",
|
|
210
|
-
]
|
|
211
|
-
|
|
212
|
-
[[package]]
|
|
213
|
-
name = "ppv-lite86"
|
|
214
|
-
version = "0.2.20"
|
|
215
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
216
|
-
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
|
|
217
|
-
dependencies = [
|
|
218
|
-
"zerocopy",
|
|
219
|
-
]
|
|
220
|
-
|
|
221
|
-
[[package]]
|
|
222
|
-
name = "proc-macro2"
|
|
223
|
-
version = "1.0.93"
|
|
224
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
225
|
-
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
|
|
226
|
-
dependencies = [
|
|
227
|
-
"unicode-ident",
|
|
228
|
-
]
|
|
229
|
-
|
|
230
|
-
[[package]]
|
|
231
|
-
name = "quote"
|
|
232
|
-
version = "1.0.38"
|
|
233
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
234
|
-
checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
|
|
235
|
-
dependencies = [
|
|
236
|
-
"proc-macro2",
|
|
237
|
-
]
|
|
238
|
-
|
|
239
|
-
[[package]]
|
|
240
|
-
name = "rand"
|
|
241
|
-
version = "0.8.5"
|
|
242
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
243
|
-
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
|
244
|
-
dependencies = [
|
|
245
|
-
"libc",
|
|
246
|
-
"rand_chacha",
|
|
247
|
-
"rand_core",
|
|
248
|
-
]
|
|
249
|
-
|
|
250
|
-
[[package]]
|
|
251
|
-
name = "rand_chacha"
|
|
252
|
-
version = "0.3.1"
|
|
253
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
254
|
-
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
|
255
|
-
dependencies = [
|
|
256
|
-
"ppv-lite86",
|
|
257
|
-
"rand_core",
|
|
258
|
-
]
|
|
259
|
-
|
|
260
|
-
[[package]]
|
|
261
|
-
name = "rand_core"
|
|
262
|
-
version = "0.6.4"
|
|
263
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
264
|
-
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
|
265
|
-
dependencies = [
|
|
266
|
-
"getrandom",
|
|
267
|
-
]
|
|
268
|
-
|
|
269
|
-
[[package]]
|
|
270
|
-
name = "rb-sys"
|
|
271
|
-
version = "0.9.124"
|
|
272
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
273
|
-
checksum = "c85c4188462601e2aa1469def389c17228566f82ea72f137ed096f21591bc489"
|
|
274
|
-
dependencies = [
|
|
275
|
-
"rb-sys-build",
|
|
276
|
-
]
|
|
277
|
-
|
|
278
|
-
[[package]]
|
|
279
|
-
name = "rb-sys-build"
|
|
280
|
-
version = "0.9.124"
|
|
281
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
282
|
-
checksum = "568068db4102230882e6d4ae8de6632e224ca75fe5970f6e026a04e91ed635d3"
|
|
283
|
-
dependencies = [
|
|
284
|
-
"bindgen",
|
|
285
|
-
"lazy_static",
|
|
286
|
-
"proc-macro2",
|
|
287
|
-
"quote",
|
|
288
|
-
"regex",
|
|
289
|
-
"shell-words",
|
|
290
|
-
"syn",
|
|
291
|
-
]
|
|
292
|
-
|
|
293
|
-
[[package]]
|
|
294
|
-
name = "rb-sys-env"
|
|
295
|
-
version = "0.2.3"
|
|
296
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
297
|
-
checksum = "cca7ad6a7e21e72151d56fe2495a259b5670e204c3adac41ee7ef676ea08117a"
|
|
298
|
-
|
|
299
|
-
[[package]]
|
|
300
|
-
name = "rb-sys-test-helpers"
|
|
301
|
-
version = "0.2.2"
|
|
302
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
303
|
-
checksum = "d6ccb543252549fc28f5d290322e041cd682bd199a8e1caaa813fb6e63dd221e"
|
|
304
|
-
dependencies = [
|
|
305
|
-
"rb-sys",
|
|
306
|
-
"rb-sys-env",
|
|
307
|
-
"rb-sys-test-helpers-macros",
|
|
308
|
-
]
|
|
309
|
-
|
|
310
|
-
[[package]]
|
|
311
|
-
name = "rb-sys-test-helpers-macros"
|
|
312
|
-
version = "0.2.2"
|
|
313
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
314
|
-
checksum = "1508caed999cb659ab1b3308e7b2985186b3b550ef5492dc18da71b560c55615"
|
|
315
|
-
dependencies = [
|
|
316
|
-
"quote",
|
|
317
|
-
"syn",
|
|
318
|
-
]
|
|
319
|
-
|
|
320
|
-
[[package]]
|
|
321
|
-
name = "regex"
|
|
322
|
-
version = "1.11.1"
|
|
323
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
324
|
-
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
|
|
325
|
-
dependencies = [
|
|
326
|
-
"aho-corasick",
|
|
327
|
-
"memchr",
|
|
328
|
-
"regex-automata",
|
|
329
|
-
"regex-syntax",
|
|
330
|
-
]
|
|
331
|
-
|
|
332
|
-
[[package]]
|
|
333
|
-
name = "regex-automata"
|
|
334
|
-
version = "0.4.9"
|
|
335
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
336
|
-
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
|
337
|
-
dependencies = [
|
|
338
|
-
"aho-corasick",
|
|
339
|
-
"memchr",
|
|
340
|
-
"regex-syntax",
|
|
341
|
-
]
|
|
342
|
-
|
|
343
|
-
[[package]]
|
|
344
|
-
name = "regex-syntax"
|
|
345
|
-
version = "0.8.5"
|
|
346
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
347
|
-
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
|
348
|
-
|
|
349
|
-
[[package]]
|
|
350
|
-
name = "rustc-hash"
|
|
351
|
-
version = "1.1.0"
|
|
352
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
353
|
-
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
|
354
|
-
|
|
355
|
-
[[package]]
|
|
356
|
-
name = "shell-words"
|
|
357
|
-
version = "1.1.0"
|
|
358
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
359
|
-
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
|
|
360
|
-
|
|
361
|
-
[[package]]
|
|
362
|
-
name = "shlex"
|
|
363
|
-
version = "1.3.0"
|
|
364
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
365
|
-
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
366
|
-
|
|
367
|
-
[[package]]
|
|
368
|
-
name = "syn"
|
|
369
|
-
version = "2.0.96"
|
|
370
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
371
|
-
checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80"
|
|
372
|
-
dependencies = [
|
|
373
|
-
"proc-macro2",
|
|
374
|
-
"quote",
|
|
375
|
-
"unicode-ident",
|
|
376
|
-
]
|
|
377
|
-
|
|
378
|
-
[[package]]
|
|
379
|
-
name = "unicode-ident"
|
|
380
|
-
version = "1.0.14"
|
|
381
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
382
|
-
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
|
383
|
-
|
|
384
|
-
[[package]]
|
|
385
|
-
name = "wasi"
|
|
386
|
-
version = "0.11.0+wasi-snapshot-preview1"
|
|
387
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
388
|
-
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|
389
|
-
|
|
390
|
-
[[package]]
|
|
391
|
-
name = "windows-targets"
|
|
392
|
-
version = "0.52.6"
|
|
393
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
394
|
-
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
|
395
|
-
dependencies = [
|
|
396
|
-
"windows_aarch64_gnullvm",
|
|
397
|
-
"windows_aarch64_msvc",
|
|
398
|
-
"windows_i686_gnu",
|
|
399
|
-
"windows_i686_gnullvm",
|
|
400
|
-
"windows_i686_msvc",
|
|
401
|
-
"windows_x86_64_gnu",
|
|
402
|
-
"windows_x86_64_gnullvm",
|
|
403
|
-
"windows_x86_64_msvc",
|
|
404
|
-
]
|
|
405
|
-
|
|
406
|
-
[[package]]
|
|
407
|
-
name = "windows_aarch64_gnullvm"
|
|
408
|
-
version = "0.52.6"
|
|
409
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
410
|
-
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
|
411
|
-
|
|
412
|
-
[[package]]
|
|
413
|
-
name = "windows_aarch64_msvc"
|
|
414
|
-
version = "0.52.6"
|
|
415
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
416
|
-
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
|
417
|
-
|
|
418
|
-
[[package]]
|
|
419
|
-
name = "windows_i686_gnu"
|
|
420
|
-
version = "0.52.6"
|
|
421
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
422
|
-
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
|
423
|
-
|
|
424
|
-
[[package]]
|
|
425
|
-
name = "windows_i686_gnullvm"
|
|
426
|
-
version = "0.52.6"
|
|
427
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
428
|
-
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
|
429
|
-
|
|
430
|
-
[[package]]
|
|
431
|
-
name = "windows_i686_msvc"
|
|
432
|
-
version = "0.52.6"
|
|
433
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
434
|
-
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
|
435
|
-
|
|
436
|
-
[[package]]
|
|
437
|
-
name = "windows_x86_64_gnu"
|
|
438
|
-
version = "0.52.6"
|
|
439
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
440
|
-
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
|
441
|
-
|
|
442
|
-
[[package]]
|
|
443
|
-
name = "windows_x86_64_gnullvm"
|
|
444
|
-
version = "0.52.6"
|
|
445
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
446
|
-
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
|
447
|
-
|
|
448
|
-
[[package]]
|
|
449
|
-
name = "windows_x86_64_msvc"
|
|
450
|
-
version = "0.52.6"
|
|
451
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
452
|
-
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
|
453
|
-
|
|
454
|
-
[[package]]
|
|
455
|
-
name = "zerocopy"
|
|
456
|
-
version = "0.7.35"
|
|
457
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
458
|
-
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
|
459
|
-
dependencies = [
|
|
460
|
-
"byteorder",
|
|
461
|
-
"zerocopy-derive",
|
|
462
|
-
]
|
|
463
|
-
|
|
464
|
-
[[package]]
|
|
465
|
-
name = "zerocopy-derive"
|
|
466
|
-
version = "0.7.35"
|
|
467
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
468
|
-
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
|
469
|
-
dependencies = [
|
|
470
|
-
"proc-macro2",
|
|
471
|
-
"quote",
|
|
472
|
-
"syn",
|
|
473
|
-
]
|
data/Cargo.toml
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# This Cargo.toml is here to let externals tools (IDEs, etc.) know that this is
|
|
2
|
-
# a Rust project. Your extensions dependencies should be added to the Cargo.toml
|
|
3
|
-
# in the ext/ directory.
|
|
4
|
-
|
|
5
|
-
[workspace]
|
|
6
|
-
members = ["./ext/digest/blake3_ext"]
|
|
7
|
-
resolver = "2"
|
|
8
|
-
|
|
9
|
-
[profile.release]
|
|
10
|
-
lto = true
|
|
11
|
-
opt-level = 3
|
|
12
|
-
codegen-units = 1
|
|
13
|
-
debug = true
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "blake3_ext"
|
|
3
|
-
version = "0.1.0"
|
|
4
|
-
edition = "2021"
|
|
5
|
-
authors = ["Ian Ker-Seymer <ian.kerseymer@shopify.com>"]
|
|
6
|
-
license = "MIT"
|
|
7
|
-
publish = false
|
|
8
|
-
|
|
9
|
-
[lib]
|
|
10
|
-
crate-type = ["cdylib"]
|
|
11
|
-
|
|
12
|
-
[dependencies]
|
|
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.2.1"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[lints.rust]
|
|
26
|
-
unexpected_cfgs = { level = "warn", check-cfg = [
|
|
27
|
-
'cfg(digest_use_rb_ext_resolve_symbol)',
|
|
28
|
-
] }
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "mkmf"
|
|
4
|
-
require "rb_sys/mkmf"
|
|
5
|
-
|
|
6
|
-
# Detect when DIGEST_USE_RB_EXT_RESOLVE_SYMBOL is defined truthy,
|
|
7
|
-
# which indicates rb_ext_resolve_symbol("digest.so", "rb_digest_wrap_metadata")
|
|
8
|
-
# will work with the version of Digest we're building against.
|
|
9
|
-
digest_use_rb_ext_resolve_symbol = try_compile(<<~C)
|
|
10
|
-
#include <ruby/digest.h>
|
|
11
|
-
|
|
12
|
-
#if !defined(DIGEST_USE_RB_EXT_RESOLVE_SYMBOL)
|
|
13
|
-
# error DIGEST_USE_RB_EXT_RESOLVE_SYMBOL not defined
|
|
14
|
-
#endif
|
|
15
|
-
#if !DIGEST_USE_RB_EXT_RESOLVE_SYMBOL
|
|
16
|
-
# error DIGEST_USE_RB_EXT_RESOLVE_SYMBOL is 0
|
|
17
|
-
#endif
|
|
18
|
-
C
|
|
19
|
-
puts("digest_use_rb_ext_resolve_symbol=#{digest_use_rb_ext_resolve_symbol}")
|
|
20
|
-
|
|
21
|
-
create_rust_makefile("digest/blake3/blake3_ext") do |r|
|
|
22
|
-
if digest_use_rb_ext_resolve_symbol
|
|
23
|
-
r.extra_rustflags = ["--cfg digest_use_rb_ext_resolve_symbol"]
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
use rb_sys::{size_t, VALUE};
|
|
2
|
-
use std::ffi::{c_int, c_uchar, c_void};
|
|
3
|
-
|
|
4
|
-
pub const RUBY_DIGEST_API_VERSION: c_int = 3;
|
|
5
|
-
|
|
6
|
-
pub type RbDigestHashInitFuncT = unsafe extern "C" fn(*mut c_void) -> c_int;
|
|
7
|
-
pub type RbDigestHashUpdateFuncT = unsafe extern "C" fn(*mut c_void, *mut c_uchar, size_t);
|
|
8
|
-
pub type RbDigestHashFinishFuncT = unsafe extern "C" fn(*mut c_void, *mut c_uchar) -> c_int;
|
|
9
|
-
|
|
10
|
-
#[derive(Debug)]
|
|
11
|
-
#[repr(C)]
|
|
12
|
-
pub struct RbDigestMetadataT {
|
|
13
|
-
pub api_version: c_int,
|
|
14
|
-
pub digest_len: size_t,
|
|
15
|
-
pub block_len: size_t,
|
|
16
|
-
pub ctx_size: size_t,
|
|
17
|
-
pub init_func: RbDigestHashInitFuncT,
|
|
18
|
-
pub update_func: RbDigestHashUpdateFuncT,
|
|
19
|
-
pub finish_func: RbDigestHashFinishFuncT,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
#[allow(dead_code)]
|
|
23
|
-
type WrapperType = unsafe extern "C" fn(&'static RbDigestMetadataT) -> VALUE;
|
|
24
|
-
|
|
25
|
-
#[cfg(any(digest_use_rb_ext_resolve_symbol, ruby_gte_3_4))]
|
|
26
|
-
pub unsafe fn rb_digest_make_metadata(meta: &'static RbDigestMetadataT) -> VALUE {
|
|
27
|
-
static mut WRAPPER: Option<WrapperType> = None;
|
|
28
|
-
|
|
29
|
-
unsafe fn load_wrapper() {
|
|
30
|
-
use rb_sys::rb_ext_resolve_symbol;
|
|
31
|
-
use std::ffi::c_char;
|
|
32
|
-
use std::sync::Once;
|
|
33
|
-
|
|
34
|
-
static INIT: Once = Once::new();
|
|
35
|
-
|
|
36
|
-
INIT.call_once(|| {
|
|
37
|
-
let lib_name = "digest.so\0".as_ptr() as *const c_char;
|
|
38
|
-
let symbol_name = "rb_digest_wrap_metadata\0".as_ptr() as *const c_char;
|
|
39
|
-
let symbol_ptr = rb_ext_resolve_symbol(lib_name, symbol_name);
|
|
40
|
-
|
|
41
|
-
if !symbol_ptr.is_null() {
|
|
42
|
-
WRAPPER = Some(std::mem::transmute::<*mut c_void, WrapperType>(symbol_ptr));
|
|
43
|
-
} else {
|
|
44
|
-
panic!("Failed to resolve rb_digest_wrap_metadata");
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
load_wrapper();
|
|
50
|
-
if let Some(wrapper) = WRAPPER {
|
|
51
|
-
return wrapper(meta);
|
|
52
|
-
}
|
|
53
|
-
panic!("Failed to resolve rb_digest_wrap_metadata");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
#[cfg(not(any(digest_use_rb_ext_resolve_symbol, ruby_gte_3_4)))]
|
|
57
|
-
pub unsafe fn rb_digest_make_metadata(meta: &'static RbDigestMetadataT) -> VALUE {
|
|
58
|
-
use rb_sys::{rb_data_object_wrap, rb_obj_freeze};
|
|
59
|
-
let data = rb_data_object_wrap(
|
|
60
|
-
0 as VALUE,
|
|
61
|
-
meta as *const RbDigestMetadataT as *mut c_void,
|
|
62
|
-
None,
|
|
63
|
-
None,
|
|
64
|
-
);
|
|
65
|
-
rb_obj_freeze(data)
|
|
66
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
#![allow(clippy::manual_c_str_literals)]
|
|
2
|
-
mod bindings;
|
|
3
|
-
|
|
4
|
-
use blake3::Hasher;
|
|
5
|
-
use rb_sys::{
|
|
6
|
-
rb_cObject, rb_const_get, rb_define_class_under, rb_intern, rb_ivar_set, rb_require, size_t,
|
|
7
|
-
};
|
|
8
|
-
use std::ffi::{c_int, c_uchar, c_void};
|
|
9
|
-
use std::mem::MaybeUninit;
|
|
10
|
-
use std::os::raw::c_char;
|
|
11
|
-
|
|
12
|
-
use bindings::{rb_digest_make_metadata, RbDigestMetadataT, RUBY_DIGEST_API_VERSION};
|
|
13
|
-
|
|
14
|
-
#[repr(C)]
|
|
15
|
-
#[derive(Debug, Default)]
|
|
16
|
-
struct Blake3 {
|
|
17
|
-
hasher: Hasher,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
impl Blake3 {
|
|
21
|
-
const BLOCK_LEN: usize = 64;
|
|
22
|
-
const DIGEST_LEN: usize = 32;
|
|
23
|
-
|
|
24
|
-
fn digest_metadata() -> &'static RbDigestMetadataT {
|
|
25
|
-
static DIGEST_METADATA: RbDigestMetadataT = RbDigestMetadataT {
|
|
26
|
-
api_version: RUBY_DIGEST_API_VERSION,
|
|
27
|
-
digest_len: Blake3::DIGEST_LEN as _,
|
|
28
|
-
block_len: Blake3::BLOCK_LEN as _,
|
|
29
|
-
ctx_size: std::mem::size_of::<Blake3>() as _,
|
|
30
|
-
init_func: Blake3::init_in_place,
|
|
31
|
-
update_func: Blake3::update,
|
|
32
|
-
finish_func: Blake3::finish,
|
|
33
|
-
};
|
|
34
|
-
&DIGEST_METADATA
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Initialize the context, which has already been allocated by Ruby.
|
|
38
|
-
extern "C" fn init_in_place(ctx: *mut c_void) -> c_int {
|
|
39
|
-
let ctx = ctx as *mut MaybeUninit<Blake3>;
|
|
40
|
-
let ctx = unsafe { &mut *ctx };
|
|
41
|
-
ctx.write(Blake3::default());
|
|
42
|
-
true as _
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Update the context with the given data.
|
|
46
|
-
extern "C" fn update(ctx: *mut c_void, data: *mut c_uchar, len: size_t) {
|
|
47
|
-
let ctx = ctx as *mut MaybeUninit<Blake3>;
|
|
48
|
-
let ctx = unsafe { &mut *ctx };
|
|
49
|
-
let ctx = unsafe { ctx.assume_init_mut() };
|
|
50
|
-
let slice = unsafe { std::slice::from_raw_parts(data, len as _) };
|
|
51
|
-
|
|
52
|
-
ctx.hasher.update(slice);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Finalize the context and write the digest to the given pointer. The
|
|
56
|
-
// memory for the digest is managed by Ruby, so we don't need to free it.
|
|
57
|
-
extern "C" fn finish(ctx: *mut c_void, digest: *mut c_uchar) -> c_int {
|
|
58
|
-
let ctx = ctx as *mut MaybeUninit<Blake3>;
|
|
59
|
-
let ctx = unsafe { &mut *ctx };
|
|
60
|
-
let ctx = unsafe { ctx.assume_init_mut() };
|
|
61
|
-
let outbuf = unsafe { std::slice::from_raw_parts_mut(digest, Self::DIGEST_LEN) };
|
|
62
|
-
ctx.hasher.finalize_xof().fill(outbuf);
|
|
63
|
-
true as _
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/// # Safety
|
|
68
|
-
/// This function is called by Ruby, so it must be safe.
|
|
69
|
-
#[no_mangle]
|
|
70
|
-
pub unsafe extern "C" fn Init_blake3_ext() {
|
|
71
|
-
rb_require("digest\0".as_ptr() as *const c_char);
|
|
72
|
-
let digest_module = rb_const_get(rb_cObject, rb_intern("Digest\0".as_ptr() as *const c_char));
|
|
73
|
-
let digest_base = rb_const_get(digest_module, rb_intern("Base\0".as_ptr() as *const c_char));
|
|
74
|
-
let klass = rb_define_class_under(
|
|
75
|
-
digest_module,
|
|
76
|
-
"Blake3\0".as_ptr() as *const c_char,
|
|
77
|
-
digest_base,
|
|
78
|
-
);
|
|
79
|
-
let meta = rb_digest_make_metadata(Blake3::digest_metadata());
|
|
80
|
-
let metadata_id = rb_intern("metadata\0".as_ptr() as *const c_char);
|
|
81
|
-
rb_ivar_set(klass, metadata_id, meta);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
#[cfg(test)]
|
|
85
|
-
mod tests {
|
|
86
|
-
use rb_sys::{
|
|
87
|
-
rb_cObject, rb_const_get, rb_enc_set_index, rb_funcallv_public, rb_intern, rb_str_new,
|
|
88
|
-
rb_utf8_encindex, RSTRING_LEN, RSTRING_PTR,
|
|
89
|
-
};
|
|
90
|
-
use rb_sys_test_helpers::{protect, ruby_test};
|
|
91
|
-
|
|
92
|
-
use crate::Init_blake3_ext;
|
|
93
|
-
|
|
94
|
-
#[ruby_test]
|
|
95
|
-
fn fuzz_parity_binary() {
|
|
96
|
-
setup();
|
|
97
|
-
|
|
98
|
-
for _ in 0..1024 {
|
|
99
|
-
let input_data = gen_random_bytes(4096);
|
|
100
|
-
let expected = compute_rust_digest(input_data.as_slice());
|
|
101
|
-
let actual = compute_ruby_digest(input_data.as_slice(), rb_utf8_encindex);
|
|
102
|
-
|
|
103
|
-
assert_eq!(expected, actual);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
#[ruby_test]
|
|
108
|
-
fn fuzz_parity_utf8() {
|
|
109
|
-
setup();
|
|
110
|
-
|
|
111
|
-
for _ in 0..1024 {
|
|
112
|
-
let input_data = gen_random_string(512);
|
|
113
|
-
let expected = compute_rust_digest(&input_data);
|
|
114
|
-
let actual = compute_ruby_digest(&input_data, rb_utf8_encindex);
|
|
115
|
-
|
|
116
|
-
assert_eq!(expected, actual);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
fn setup() {
|
|
121
|
-
static INIT: std::sync::Once = std::sync::Once::new();
|
|
122
|
-
INIT.call_once(|| {
|
|
123
|
-
protect(|| unsafe { Init_blake3_ext() })
|
|
124
|
-
.expect("Failed to initialize Blake3 extension");
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
fn gen_random_bytes(max_len: usize) -> Vec<u8> {
|
|
129
|
-
let size = rand::random::<usize>() % max_len;
|
|
130
|
-
(0..size).map(|_| rand::random::<u8>()).collect()
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
fn gen_random_string(max_len: usize) -> String {
|
|
134
|
-
let size = rand::random::<usize>() % max_len;
|
|
135
|
-
(0..size)
|
|
136
|
-
.map(|_| rand::random::<char>())
|
|
137
|
-
.collect::<String>()
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
fn compute_rust_digest<T: AsRef<[u8]>>(input: T) -> String {
|
|
141
|
-
let mut hasher = blake3::Hasher::new();
|
|
142
|
-
hasher.update(input.as_ref());
|
|
143
|
-
let mut result = [0u8; 32];
|
|
144
|
-
hasher.finalize_xof().fill(&mut result);
|
|
145
|
-
hex::encode(result)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
fn compute_ruby_digest<T: AsRef<[u8]>>(
|
|
149
|
-
input: T,
|
|
150
|
-
encoding: unsafe extern "C" fn() -> i32,
|
|
151
|
-
) -> String {
|
|
152
|
-
let input = input.as_ref();
|
|
153
|
-
let ruby_digest = protect(|| unsafe {
|
|
154
|
-
Init_blake3_ext();
|
|
155
|
-
let klass = rb_const_get(rb_cObject, rb_intern("Digest\0".as_ptr() as _));
|
|
156
|
-
let klass = rb_const_get(klass, rb_intern("Blake3\0".as_ptr() as _));
|
|
157
|
-
let string = rb_str_new(input.as_ptr() as _, input.len() as _);
|
|
158
|
-
rb_enc_set_index(string, encoding());
|
|
159
|
-
let mut args = [string];
|
|
160
|
-
rb_funcallv_public(
|
|
161
|
-
klass,
|
|
162
|
-
rb_intern("hexdigest\0".as_ptr() as _),
|
|
163
|
-
args.len() as _,
|
|
164
|
-
args.as_mut_ptr(),
|
|
165
|
-
)
|
|
166
|
-
})
|
|
167
|
-
.unwrap();
|
|
168
|
-
|
|
169
|
-
let rstring_ptr = unsafe { RSTRING_PTR(ruby_digest) };
|
|
170
|
-
let rstring_len = unsafe { RSTRING_LEN(ruby_digest) };
|
|
171
|
-
|
|
172
|
-
let bytes =
|
|
173
|
-
unsafe { std::slice::from_raw_parts(rstring_ptr as *const u8, rstring_len as _) };
|
|
174
|
-
std::str::from_utf8(bytes).unwrap().to_string()
|
|
175
|
-
}
|
|
176
|
-
}
|