Package list golang-github-minio-sha256-simd / 05b4dd3
noasm should come along with ppc64le platforms (#44) Harshavardhana authored 2 years ago GitHub committed 2 years ago
3 changed file(s) with 149 addition(s) and 171 deletion(s). Raw diff Collapse all Expand all
273273
274274 return
275275 }
276
277 func block(dig *digest, p []byte) {
278 if blockfunc == blockfuncSha {
279 blockShaGo(dig, p)
280 } else if blockfunc == blockfuncAvx2 {
281 blockAvx2Go(dig, p)
282 } else if blockfunc == blockfuncAvx {
283 blockAvxGo(dig, p)
284 } else if blockfunc == blockfuncSsse {
285 blockSsseGo(dig, p)
286 } else if blockfunc == blockfuncArm {
287 blockArmGo(dig, p)
288 } else if blockfunc == blockfuncGeneric {
289 blockGeneric(dig, p)
290 }
291 }
292
293 func blockGeneric(dig *digest, p []byte) {
294 var w [64]uint32
295 h0, h1, h2, h3, h4, h5, h6, h7 := dig.h[0], dig.h[1], dig.h[2], dig.h[3], dig.h[4], dig.h[5], dig.h[6], dig.h[7]
296 for len(p) >= chunk {
297 // Can interlace the computation of w with the
298 // rounds below if needed for speed.
299 for i := 0; i < 16; i++ {
300 j := i * 4
301 w[i] = uint32(p[j])<<24 | uint32(p[j+1])<<16 | uint32(p[j+2])<<8 | uint32(p[j+3])
302 }
303 for i := 16; i < 64; i++ {
304 v1 := w[i-2]
305 t1 := (v1>>17 | v1<<(32-17)) ^ (v1>>19 | v1<<(32-19)) ^ (v1 >> 10)
306 v2 := w[i-15]
307 t2 := (v2>>7 | v2<<(32-7)) ^ (v2>>18 | v2<<(32-18)) ^ (v2 >> 3)
308 w[i] = t1 + w[i-7] + t2 + w[i-16]
309 }
310
311 a, b, c, d, e, f, g, h := h0, h1, h2, h3, h4, h5, h6, h7
312
313 for i := 0; i < 64; i++ {
314 t1 := h + ((e>>6 | e<<(32-6)) ^ (e>>11 | e<<(32-11)) ^ (e>>25 | e<<(32-25))) + ((e & f) ^ (^e & g)) + _K[i] + w[i]
315
316 t2 := ((a>>2 | a<<(32-2)) ^ (a>>13 | a<<(32-13)) ^ (a>>22 | a<<(32-22))) + ((a & b) ^ (a & c) ^ (b & c))
317
318 h = g
319 g = f
320 f = e
321 e = d + t1
322 d = c
323 c = b
324 b = a
325 a = t1 + t2
326 }
327
328 h0 += a
329 h1 += b
330 h2 += c
331 h3 += d
332 h4 += e
333 h5 += f
334 h6 += g
335 h7 += h
336
337 p = p[chunk:]
338 }
339
340 dig.h[0], dig.h[1], dig.h[2], dig.h[3], dig.h[4], dig.h[5], dig.h[6], dig.h[7] = h0, h1, h2, h3, h4, h5, h6, h7
341 }
342
343 var _K = []uint32{
344 0x428a2f98,
345 0x71374491,
346 0xb5c0fbcf,
347 0xe9b5dba5,
348 0x3956c25b,
349 0x59f111f1,
350 0x923f82a4,
351 0xab1c5ed5,
352 0xd807aa98,
353 0x12835b01,
354 0x243185be,
355 0x550c7dc3,
356 0x72be5d74,
357 0x80deb1fe,
358 0x9bdc06a7,
359 0xc19bf174,
360 0xe49b69c1,
361 0xefbe4786,
362 0x0fc19dc6,
363 0x240ca1cc,
364 0x2de92c6f,
365 0x4a7484aa,
366 0x5cb0a9dc,
367 0x76f988da,
368 0x983e5152,
369 0xa831c66d,
370 0xb00327c8,
371 0xbf597fc7,
372 0xc6e00bf3,
373 0xd5a79147,
374 0x06ca6351,
375 0x14292967,
376 0x27b70a85,
377 0x2e1b2138,
378 0x4d2c6dfc,
379 0x53380d13,
380 0x650a7354,
381 0x766a0abb,
382 0x81c2c92e,
383 0x92722c85,
384 0xa2bfe8a1,
385 0xa81a664b,
386 0xc24b8b70,
387 0xc76c51a3,
388 0xd192e819,
389 0xd6990624,
390 0xf40e3585,
391 0x106aa070,
392 0x19a4c116,
393 0x1e376c08,
394 0x2748774c,
395 0x34b0bcb5,
396 0x391c0cb3,
397 0x4ed8aa4a,
398 0x5b9cca4f,
399 0x682e6ff3,
400 0x748f82ee,
401 0x78a5636f,
402 0x84c87814,
403 0x8cc70208,
404 0x90befffa,
405 0xa4506ceb,
406 0xbef9a3f7,
407 0xc67178f2,
408 }
+0
-140
sha256block_noasm.go less more
0 //+build !arm64 !amd64 noasm appengine
1
2 /*
3 * Minio Cloud Storage, (C) 2016 Minio, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package sha256
19
20 func block(dig *digest, p []byte) {
21 blockGeneric(dig, p)
22 }
23
24 func blockGeneric(dig *digest, p []byte) {
25 var w [64]uint32
26 h0, h1, h2, h3, h4, h5, h6, h7 := dig.h[0], dig.h[1], dig.h[2], dig.h[3], dig.h[4], dig.h[5], dig.h[6], dig.h[7]
27 for len(p) >= chunk {
28 // Can interlace the computation of w with the
29 // rounds below if needed for speed.
30 for i := 0; i < 16; i++ {
31 j := i * 4
32 w[i] = uint32(p[j])<<24 | uint32(p[j+1])<<16 | uint32(p[j+2])<<8 | uint32(p[j+3])
33 }
34 for i := 16; i < 64; i++ {
35 v1 := w[i-2]
36 t1 := (v1>>17 | v1<<(32-17)) ^ (v1>>19 | v1<<(32-19)) ^ (v1 >> 10)
37 v2 := w[i-15]
38 t2 := (v2>>7 | v2<<(32-7)) ^ (v2>>18 | v2<<(32-18)) ^ (v2 >> 3)
39 w[i] = t1 + w[i-7] + t2 + w[i-16]
40 }
41
42 a, b, c, d, e, f, g, h := h0, h1, h2, h3, h4, h5, h6, h7
43
44 for i := 0; i < 64; i++ {
45 t1 := h + ((e>>6 | e<<(32-6)) ^ (e>>11 | e<<(32-11)) ^ (e>>25 | e<<(32-25))) + ((e & f) ^ (^e & g)) + _K[i] + w[i]
46
47 t2 := ((a>>2 | a<<(32-2)) ^ (a>>13 | a<<(32-13)) ^ (a>>22 | a<<(32-22))) + ((a & b) ^ (a & c) ^ (b & c))
48
49 h = g
50 g = f
51 f = e
52 e = d + t1
53 d = c
54 c = b
55 b = a
56 a = t1 + t2
57 }
58
59 h0 += a
60 h1 += b
61 h2 += c
62 h3 += d
63 h4 += e
64 h5 += f
65 h6 += g
66 h7 += h
67
68 p = p[chunk:]
69 }
70
71 dig.h[0], dig.h[1], dig.h[2], dig.h[3], dig.h[4], dig.h[5], dig.h[6], dig.h[7] = h0, h1, h2, h3, h4, h5, h6, h7
72 }
73
74 var _K = []uint32{
75 0x428a2f98,
76 0x71374491,
77 0xb5c0fbcf,
78 0xe9b5dba5,
79 0x3956c25b,
80 0x59f111f1,
81 0x923f82a4,
82 0xab1c5ed5,
83 0xd807aa98,
84 0x12835b01,
85 0x243185be,
86 0x550c7dc3,
87 0x72be5d74,
88 0x80deb1fe,
89 0x9bdc06a7,
90 0xc19bf174,
91 0xe49b69c1,
92 0xefbe4786,
93 0x0fc19dc6,
94 0x240ca1cc,
95 0x2de92c6f,
96 0x4a7484aa,
97 0x5cb0a9dc,
98 0x76f988da,
99 0x983e5152,
100 0xa831c66d,
101 0xb00327c8,
102 0xbf597fc7,
103 0xc6e00bf3,
104 0xd5a79147,
105 0x06ca6351,
106 0x14292967,
107 0x27b70a85,
108 0x2e1b2138,
109 0x4d2c6dfc,
110 0x53380d13,
111 0x650a7354,
112 0x766a0abb,
113 0x81c2c92e,
114 0x92722c85,
115 0xa2bfe8a1,
116 0xa81a664b,
117 0xc24b8b70,
118 0xc76c51a3,
119 0xd192e819,
120 0xd6990624,
121 0xf40e3585,
122 0x106aa070,
123 0x19a4c116,
124 0x1e376c08,
125 0x2748774c,
126 0x34b0bcb5,
127 0x391c0cb3,
128 0x4ed8aa4a,
129 0x5b9cca4f,
130 0x682e6ff3,
131 0x748f82ee,
132 0x78a5636f,
133 0x84c87814,
134 0x8cc70208,
135 0x90befffa,
136 0xa4506ceb,
137 0xbef9a3f7,
138 0xc67178f2,
139 }
0 // Minio Cloud Storage, (C) 2016 Minio, Inc.
1 //
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 //
0 //+build noasm appengine ppc64 ppc64le mips mipsle mips64 mips64le s390x wasm
141
15 // +build ppc64 ppc64le mips mipsle mips64 mips64le s390x wasm
2 /*
3 * Minio Cloud Storage, (C) 2019 Minio, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
1617
1718 package sha256
1819
2122 func blockSsseGo(dig *digest, p []byte) {}
2223 func blockShaGo(dig *digest, p []byte) {}
2324 func blockArmGo(dig *digest, p []byte) {}
24
25 func block(dig *digest, p []byte) {
26 if blockfunc == blockfuncSha {
27 blockShaGo(dig, p)
28 } else if blockfunc == blockfuncAvx2 {
29 blockAvx2Go(dig, p)
30 } else if blockfunc == blockfuncAvx {
31 blockAvxGo(dig, p)
32 } else if blockfunc == blockfuncSsse {
33 blockSsseGo(dig, p)
34 } else if blockfunc == blockfuncArm {
35 blockArmGo(dig, p)
36 } else if blockfunc == blockfuncGeneric {
37 blockGeneric(dig, p)
38 }
39 }