@amritk/nish-x86_64-linux 0.26.0 → 0.28.0
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.
- package/INSTALL.md +13 -8
- package/bin/nish +0 -0
- package/docs/AI.md +27 -5
- package/package.json +1 -1
- package/runtime/core.d.ts +47 -0
- package/runtime/core.mjs +67 -0
- package/runtime/nish.d.ts +54 -5
- package/runtime/nish.h +67 -8
- package/runtime/nish.mjs +6 -0
- package/runtime/runtime-checksum.c +270 -0
- package/runtime/runtime-os.c +9 -4
- package/runtime/runtime-parallel.c +21 -0
- package/runtime/runtime-sandbox.c +470 -0
- package/runtime/runtime-sha256.c +239 -0
- package/runtime/runtime-simd.c +63 -2
- package/runtime/runtime-wasm.c +18 -0
- package/scripts/build.sh +60 -24
- package/std/README.md +16 -10
- package/std/compress/checksum.ts +88 -75
- package/std/compress/deflate.ts +224 -0
- package/std/compress/gzip.ts +52 -0
- package/std/crypto/bcrypt.ts +816 -280
- package/std/crypto/sha256.ts +335 -188
- package/std/json-equal.ts +335 -0
- package/std/json-format.ts +1070 -0
- package/std/json-number.ts +428 -0
- package/std/json-pointer.ts +245 -0
- package/std/json-value.ts +510 -17
- package/std/net/http-client.ts +1645 -0
- package/std/net/http-compress.ts +259 -16
- package/std/net/http1-client.ts +104 -19
- package/std/net/http1-server.ts +61 -12
- package/std/net/postgres.ts +576 -8
- package/std/net/websocket.ts +295 -14
- package/std/regex.ts +613 -52
- package/std/term-io.ts +35 -8
- package/std/yaml-json.ts +841 -0
package/std/crypto/sha256.ts
CHANGED
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
* Nothing here branches or indexes on the message: the only branches are on
|
|
28
28
|
* lengths and loop counters, which a hash does not keep secret.
|
|
29
29
|
*
|
|
30
|
+
* Every read is checked: nothing here imports `nish:unsafe`, so hashing never
|
|
31
|
+
* makes a caller reach `unsafe`, which `--deny unsafe` refuses (the SCRAM in
|
|
32
|
+
* `std/net/postgres.ts` is one such caller). `sha256Compress` instead orders
|
|
33
|
+
* its reads so that the optimiser can fold a block's bounds checks into one.
|
|
34
|
+
*
|
|
30
35
|
* Written from the specification, not ported from another implementation.
|
|
31
36
|
*/
|
|
32
37
|
|
|
@@ -36,160 +41,50 @@ export const SHA256_SIZE: i32 = 32
|
|
|
36
41
|
/** The length of a message block in bytes (FIPS 180-4 §1, "Block Size"). */
|
|
37
42
|
export const SHA256_BLOCK: i32 = 64
|
|
38
43
|
|
|
44
|
+
/** ROTR^n(x) of FIPS 180-4 §3.2: a right rotation of a 32-bit word, `0 < n < 32`. */
|
|
45
|
+
const sha256Rotr = (x: u32, n: u32): u32 => (x >>> n) | (x << (32 - n))
|
|
46
|
+
|
|
47
|
+
/** Σ0 of FIPS 180-4 §4.1.2, (4.4). */
|
|
48
|
+
const sha256BigSigma0 = (x: u32): u32 => sha256Rotr(x, 2) ^ sha256Rotr(x, 13) ^ sha256Rotr(x, 22)
|
|
49
|
+
|
|
50
|
+
/** Σ1 of FIPS 180-4 §4.1.2, (4.5). */
|
|
51
|
+
const sha256BigSigma1 = (x: u32): u32 => sha256Rotr(x, 6) ^ sha256Rotr(x, 11) ^ sha256Rotr(x, 25)
|
|
52
|
+
|
|
53
|
+
/** σ0 of FIPS 180-4 §4.1.2, (4.6). */
|
|
54
|
+
const sha256SmallSigma0 = (x: u32): u32 => sha256Rotr(x, 7) ^ sha256Rotr(x, 18) ^ (x >>> 3)
|
|
55
|
+
|
|
56
|
+
/** σ1 of FIPS 180-4 §4.1.2, (4.7). */
|
|
57
|
+
const sha256SmallSigma1 = (x: u32): u32 => sha256Rotr(x, 17) ^ sha256Rotr(x, 19) ^ (x >>> 10)
|
|
58
|
+
|
|
39
59
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* A function over a `switch` rather than a table, because a module constant
|
|
44
|
-
* cannot be an array ([LANGUAGE.md](../../docs/LANGUAGE.md#module-constants))
|
|
45
|
-
* and building one per hasher would be sixty-four stores for every `new`. LLVM's
|
|
46
|
-
* code generator turns a `switch` whose every arm returns a constant into a
|
|
47
|
-
* read-only lookup table, so in the binary this is one load. `t` is the round
|
|
48
|
-
* number, never message data.
|
|
60
|
+
* Ch of FIPS 180-4 §4.1.2, (4.2). `(x & y) ^ (~x & z)` picks each bit of `y`
|
|
61
|
+
* where `x` has a one and of `z` where it has a zero, which is what
|
|
62
|
+
* `z ^ (x & (y ^ z))` computes in three operations instead of four.
|
|
49
63
|
*/
|
|
50
|
-
const
|
|
51
|
-
switch (t) {
|
|
52
|
-
case 0:
|
|
53
|
-
return 0x428a2f98
|
|
54
|
-
case 1:
|
|
55
|
-
return 0x71374491
|
|
56
|
-
case 2:
|
|
57
|
-
return 0xb5c0fbcf
|
|
58
|
-
case 3:
|
|
59
|
-
return 0xe9b5dba5
|
|
60
|
-
case 4:
|
|
61
|
-
return 0x3956c25b
|
|
62
|
-
case 5:
|
|
63
|
-
return 0x59f111f1
|
|
64
|
-
case 6:
|
|
65
|
-
return 0x923f82a4
|
|
66
|
-
case 7:
|
|
67
|
-
return 0xab1c5ed5
|
|
68
|
-
case 8:
|
|
69
|
-
return 0xd807aa98
|
|
70
|
-
case 9:
|
|
71
|
-
return 0x12835b01
|
|
72
|
-
case 10:
|
|
73
|
-
return 0x243185be
|
|
74
|
-
case 11:
|
|
75
|
-
return 0x550c7dc3
|
|
76
|
-
case 12:
|
|
77
|
-
return 0x72be5d74
|
|
78
|
-
case 13:
|
|
79
|
-
return 0x80deb1fe
|
|
80
|
-
case 14:
|
|
81
|
-
return 0x9bdc06a7
|
|
82
|
-
case 15:
|
|
83
|
-
return 0xc19bf174
|
|
84
|
-
case 16:
|
|
85
|
-
return 0xe49b69c1
|
|
86
|
-
case 17:
|
|
87
|
-
return 0xefbe4786
|
|
88
|
-
case 18:
|
|
89
|
-
return 0x0fc19dc6
|
|
90
|
-
case 19:
|
|
91
|
-
return 0x240ca1cc
|
|
92
|
-
case 20:
|
|
93
|
-
return 0x2de92c6f
|
|
94
|
-
case 21:
|
|
95
|
-
return 0x4a7484aa
|
|
96
|
-
case 22:
|
|
97
|
-
return 0x5cb0a9dc
|
|
98
|
-
case 23:
|
|
99
|
-
return 0x76f988da
|
|
100
|
-
case 24:
|
|
101
|
-
return 0x983e5152
|
|
102
|
-
case 25:
|
|
103
|
-
return 0xa831c66d
|
|
104
|
-
case 26:
|
|
105
|
-
return 0xb00327c8
|
|
106
|
-
case 27:
|
|
107
|
-
return 0xbf597fc7
|
|
108
|
-
case 28:
|
|
109
|
-
return 0xc6e00bf3
|
|
110
|
-
case 29:
|
|
111
|
-
return 0xd5a79147
|
|
112
|
-
case 30:
|
|
113
|
-
return 0x06ca6351
|
|
114
|
-
case 31:
|
|
115
|
-
return 0x14292967
|
|
116
|
-
case 32:
|
|
117
|
-
return 0x27b70a85
|
|
118
|
-
case 33:
|
|
119
|
-
return 0x2e1b2138
|
|
120
|
-
case 34:
|
|
121
|
-
return 0x4d2c6dfc
|
|
122
|
-
case 35:
|
|
123
|
-
return 0x53380d13
|
|
124
|
-
case 36:
|
|
125
|
-
return 0x650a7354
|
|
126
|
-
case 37:
|
|
127
|
-
return 0x766a0abb
|
|
128
|
-
case 38:
|
|
129
|
-
return 0x81c2c92e
|
|
130
|
-
case 39:
|
|
131
|
-
return 0x92722c85
|
|
132
|
-
case 40:
|
|
133
|
-
return 0xa2bfe8a1
|
|
134
|
-
case 41:
|
|
135
|
-
return 0xa81a664b
|
|
136
|
-
case 42:
|
|
137
|
-
return 0xc24b8b70
|
|
138
|
-
case 43:
|
|
139
|
-
return 0xc76c51a3
|
|
140
|
-
case 44:
|
|
141
|
-
return 0xd192e819
|
|
142
|
-
case 45:
|
|
143
|
-
return 0xd6990624
|
|
144
|
-
case 46:
|
|
145
|
-
return 0xf40e3585
|
|
146
|
-
case 47:
|
|
147
|
-
return 0x106aa070
|
|
148
|
-
case 48:
|
|
149
|
-
return 0x19a4c116
|
|
150
|
-
case 49:
|
|
151
|
-
return 0x1e376c08
|
|
152
|
-
case 50:
|
|
153
|
-
return 0x2748774c
|
|
154
|
-
case 51:
|
|
155
|
-
return 0x34b0bcb5
|
|
156
|
-
case 52:
|
|
157
|
-
return 0x391c0cb3
|
|
158
|
-
case 53:
|
|
159
|
-
return 0x4ed8aa4a
|
|
160
|
-
case 54:
|
|
161
|
-
return 0x5b9cca4f
|
|
162
|
-
case 55:
|
|
163
|
-
return 0x682e6ff3
|
|
164
|
-
case 56:
|
|
165
|
-
return 0x748f82ee
|
|
166
|
-
case 57:
|
|
167
|
-
return 0x78a5636f
|
|
168
|
-
case 58:
|
|
169
|
-
return 0x84c87814
|
|
170
|
-
case 59:
|
|
171
|
-
return 0x8cc70208
|
|
172
|
-
case 60:
|
|
173
|
-
return 0x90befffa
|
|
174
|
-
case 61:
|
|
175
|
-
return 0xa4506ceb
|
|
176
|
-
case 62:
|
|
177
|
-
return 0xbef9a3f7
|
|
178
|
-
case 63:
|
|
179
|
-
return 0xc67178f2
|
|
180
|
-
// Unreachable: `t` is a round number, 0 to 63. A `default` of its own
|
|
181
|
-
// keeps K_63 inside the table, so the lookup needs no range test first.
|
|
182
|
-
default:
|
|
183
|
-
return 0
|
|
184
|
-
}
|
|
185
|
-
}
|
|
64
|
+
const sha256Choose = (x: u32, y: u32, z: u32): u32 => z ^ (x & (y ^ z))
|
|
186
65
|
|
|
187
|
-
/**
|
|
188
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Maj of FIPS 180-4 §4.1.2, (4.3). `(x & y) ^ (x & z) ^ (y & z)` is each
|
|
68
|
+
* bit's majority vote, which is `x & y` unless `x` and `y` differ, and then
|
|
69
|
+
* `z`'s bit: `(x & y) ^ (z & (x ^ y))`.
|
|
70
|
+
*/
|
|
71
|
+
const sha256Majority = (x: u32, y: u32, z: u32): u32 => (x & y) ^ (z & (x ^ y))
|
|
189
72
|
|
|
190
|
-
/**
|
|
191
|
-
|
|
192
|
-
|
|
73
|
+
/**
|
|
74
|
+
* The big-endian word at `buf[p .. p + 4)`, as FIPS 180-4 §3.1 orders bytes in
|
|
75
|
+
* a word. `p`'s range makes each `p + k` an `add nsw`, with no overflow test.
|
|
76
|
+
* The low byte, `buf[p + 3]`, is read first, so its bounds check also covers
|
|
77
|
+
* the three reads after it and LLVM drops theirs; once a check further on in
|
|
78
|
+
* the buffer covers that one too, nothing lies between the four reads and
|
|
79
|
+
* LLVM joins them into one 32-bit load and a byte swap.
|
|
80
|
+
*
|
|
81
|
+
* The low byte is also the innermost `|` because σ1 shifts a word right by 10,
|
|
82
|
+
* and when the low byte is the outermost operand LLVM's instcombine answers
|
|
83
|
+
* that shift from the inner three bytes alone, which gives the half-built word
|
|
84
|
+
* a second use and leaves words 14 and 15 as four byte loads each.
|
|
85
|
+
*/
|
|
86
|
+
const sha256LoadWord = (buf: u8[], p: integer<0, 2147483643>): u32 =>
|
|
87
|
+
toU32(buf[p + 3]) | (toU32(buf[p + 2]) << 8) | (toU32(buf[p + 1]) << 16) | (toU32(buf[p]) << 24)
|
|
193
88
|
|
|
194
89
|
/**
|
|
195
90
|
* Copies `from[fromAt .. fromAt + n)` to `to[toAt .. toAt + n)`. Every caller
|
|
@@ -208,28 +103,39 @@ const sha256CopyBytes = (from: u8[], fromAt: i32, to: u8[], toAt: i32, n: i32):
|
|
|
208
103
|
* 64-word message schedule, passed in so that it is allocated once per hasher.
|
|
209
104
|
*
|
|
210
105
|
* A function over the arrays rather than a method, so that each array is a
|
|
211
|
-
* plain local whose length the guard below proves once for every
|
|
106
|
+
* plain local whose length the guard below proves once for every access.
|
|
107
|
+
*
|
|
108
|
+
* The sixty-four rounds are written out rather than looped. Unrolled, each
|
|
109
|
+
* round constant K_t of §4.2.2 (the first 32 bits of the fractional parts of
|
|
110
|
+
* the cube roots of the first sixty-four primes) is an immediate operand, and
|
|
111
|
+
* the eight working variables never move: instead of `h = g`, `g = f` and so
|
|
112
|
+
* on, each round renames them, so round t + 1 reads as its `a` the variable
|
|
113
|
+
* round t wrote as its `h`, and after eight rounds the names are back where
|
|
114
|
+
* they started. Only `d` and `h` of a round are written: `d + T1` is the next
|
|
115
|
+
* `e`, and `T1 + T2` the next `a`. The message schedule of step 1 is computed
|
|
116
|
+
* one word ahead of the round that reads it, rather than all at once first.
|
|
212
117
|
*/
|
|
213
118
|
const sha256Compress = (h: u32[], w: u32[], src: u8[], at: i32): void => {
|
|
214
|
-
// The test is written as the condition the body runs under, not as an
|
|
215
|
-
//
|
|
216
|
-
//
|
|
217
|
-
// the
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
119
|
+
// The test is written as the condition the body runs under, not as an early
|
|
120
|
+
// exit, because that is the shape that proves the constant `w[t]` and `h[i]`
|
|
121
|
+
// indices in range and drops their bounds checks. Its last clause, which
|
|
122
|
+
// the one before implies for any array an `i32` can index, is what puts
|
|
123
|
+
// `at` in `base`'s range with no check.
|
|
124
|
+
if (
|
|
125
|
+
toI32(h.length) >= 8 &&
|
|
126
|
+
toI32(w.length) >= 64 &&
|
|
127
|
+
at >= 0 &&
|
|
128
|
+
at <= toI32(src.length) - SHA256_BLOCK &&
|
|
129
|
+
at <= 2147483583
|
|
130
|
+
) {
|
|
131
|
+
const base: integer<0, 2147483583> = at
|
|
132
|
+
// Word 15 is loaded first. Its first read, the block's last byte, is the
|
|
133
|
+
// one bounds check of the block: the checker cannot prove `base + k` in
|
|
134
|
+
// range from the guard, but LLVM sees that every other read of the block
|
|
135
|
+
// lies below it and drops their checks, so words 0 to 14 are each one
|
|
136
|
+
// load and a byte swap. Word 15 stays four byte loads, because its last
|
|
137
|
+
// byte's index is the check's.
|
|
138
|
+
w[15] = sha256LoadWord(src, base + 60)
|
|
233
139
|
// Step 2: the working variables start from the previous hash value.
|
|
234
140
|
let a: u32 = h[0]
|
|
235
141
|
let b: u32 = h[1]
|
|
@@ -239,24 +145,265 @@ const sha256Compress = (h: u32[], w: u32[], src: u8[], at: i32): void => {
|
|
|
239
145
|
let f: u32 = h[5]
|
|
240
146
|
let g: u32 = h[6]
|
|
241
147
|
let hh: u32 = h[7]
|
|
242
|
-
//
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
148
|
+
// T1 of step 3; T2 is added where it is computed.
|
|
149
|
+
let t1: u32 = 0
|
|
150
|
+
// Steps 1 and 3: rounds 0 to 15 read the block's sixteen words.
|
|
151
|
+
w[0] = sha256LoadWord(src, base)
|
|
152
|
+
t1 = hh + sha256BigSigma1(e) + sha256Choose(e, f, g) + 0x428a2f98 + w[0]
|
|
153
|
+
d += t1
|
|
154
|
+
hh = t1 + sha256BigSigma0(a) + sha256Majority(a, b, c)
|
|
155
|
+
w[1] = sha256LoadWord(src, base + 4)
|
|
156
|
+
t1 = g + sha256BigSigma1(d) + sha256Choose(d, e, f) + 0x71374491 + w[1]
|
|
157
|
+
c += t1
|
|
158
|
+
g = t1 + sha256BigSigma0(hh) + sha256Majority(hh, a, b)
|
|
159
|
+
w[2] = sha256LoadWord(src, base + 8)
|
|
160
|
+
t1 = f + sha256BigSigma1(c) + sha256Choose(c, d, e) + 0xb5c0fbcf + w[2]
|
|
161
|
+
b += t1
|
|
162
|
+
f = t1 + sha256BigSigma0(g) + sha256Majority(g, hh, a)
|
|
163
|
+
w[3] = sha256LoadWord(src, base + 12)
|
|
164
|
+
t1 = e + sha256BigSigma1(b) + sha256Choose(b, c, d) + 0xe9b5dba5 + w[3]
|
|
165
|
+
a += t1
|
|
166
|
+
e = t1 + sha256BigSigma0(f) + sha256Majority(f, g, hh)
|
|
167
|
+
w[4] = sha256LoadWord(src, base + 16)
|
|
168
|
+
t1 = d + sha256BigSigma1(a) + sha256Choose(a, b, c) + 0x3956c25b + w[4]
|
|
169
|
+
hh += t1
|
|
170
|
+
d = t1 + sha256BigSigma0(e) + sha256Majority(e, f, g)
|
|
171
|
+
w[5] = sha256LoadWord(src, base + 20)
|
|
172
|
+
t1 = c + sha256BigSigma1(hh) + sha256Choose(hh, a, b) + 0x59f111f1 + w[5]
|
|
173
|
+
g += t1
|
|
174
|
+
c = t1 + sha256BigSigma0(d) + sha256Majority(d, e, f)
|
|
175
|
+
w[6] = sha256LoadWord(src, base + 24)
|
|
176
|
+
t1 = b + sha256BigSigma1(g) + sha256Choose(g, hh, a) + 0x923f82a4 + w[6]
|
|
177
|
+
f += t1
|
|
178
|
+
b = t1 + sha256BigSigma0(c) + sha256Majority(c, d, e)
|
|
179
|
+
w[7] = sha256LoadWord(src, base + 28)
|
|
180
|
+
t1 = a + sha256BigSigma1(f) + sha256Choose(f, g, hh) + 0xab1c5ed5 + w[7]
|
|
181
|
+
e += t1
|
|
182
|
+
a = t1 + sha256BigSigma0(b) + sha256Majority(b, c, d)
|
|
183
|
+
w[8] = sha256LoadWord(src, base + 32)
|
|
184
|
+
t1 = hh + sha256BigSigma1(e) + sha256Choose(e, f, g) + 0xd807aa98 + w[8]
|
|
185
|
+
d += t1
|
|
186
|
+
hh = t1 + sha256BigSigma0(a) + sha256Majority(a, b, c)
|
|
187
|
+
w[9] = sha256LoadWord(src, base + 36)
|
|
188
|
+
t1 = g + sha256BigSigma1(d) + sha256Choose(d, e, f) + 0x12835b01 + w[9]
|
|
189
|
+
c += t1
|
|
190
|
+
g = t1 + sha256BigSigma0(hh) + sha256Majority(hh, a, b)
|
|
191
|
+
w[10] = sha256LoadWord(src, base + 40)
|
|
192
|
+
t1 = f + sha256BigSigma1(c) + sha256Choose(c, d, e) + 0x243185be + w[10]
|
|
193
|
+
b += t1
|
|
194
|
+
f = t1 + sha256BigSigma0(g) + sha256Majority(g, hh, a)
|
|
195
|
+
w[11] = sha256LoadWord(src, base + 44)
|
|
196
|
+
t1 = e + sha256BigSigma1(b) + sha256Choose(b, c, d) + 0x550c7dc3 + w[11]
|
|
197
|
+
a += t1
|
|
198
|
+
e = t1 + sha256BigSigma0(f) + sha256Majority(f, g, hh)
|
|
199
|
+
w[12] = sha256LoadWord(src, base + 48)
|
|
200
|
+
t1 = d + sha256BigSigma1(a) + sha256Choose(a, b, c) + 0x72be5d74 + w[12]
|
|
201
|
+
hh += t1
|
|
202
|
+
d = t1 + sha256BigSigma0(e) + sha256Majority(e, f, g)
|
|
203
|
+
w[13] = sha256LoadWord(src, base + 52)
|
|
204
|
+
t1 = c + sha256BigSigma1(hh) + sha256Choose(hh, a, b) + 0x80deb1fe + w[13]
|
|
205
|
+
g += t1
|
|
206
|
+
c = t1 + sha256BigSigma0(d) + sha256Majority(d, e, f)
|
|
207
|
+
w[14] = sha256LoadWord(src, base + 56)
|
|
208
|
+
t1 = b + sha256BigSigma1(g) + sha256Choose(g, hh, a) + 0x9bdc06a7 + w[14]
|
|
209
|
+
f += t1
|
|
210
|
+
b = t1 + sha256BigSigma0(c) + sha256Majority(c, d, e)
|
|
211
|
+
t1 = a + sha256BigSigma1(f) + sha256Choose(f, g, hh) + 0xc19bf174 + w[15]
|
|
212
|
+
e += t1
|
|
213
|
+
a = t1 + sha256BigSigma0(b) + sha256Majority(b, c, d)
|
|
214
|
+
// Rounds 16 to 63 extend the schedule one word ahead of the round that reads it.
|
|
215
|
+
w[16] = sha256SmallSigma1(w[14]) + w[9] + sha256SmallSigma0(w[1]) + w[0]
|
|
216
|
+
t1 = hh + sha256BigSigma1(e) + sha256Choose(e, f, g) + 0xe49b69c1 + w[16]
|
|
217
|
+
d += t1
|
|
218
|
+
hh = t1 + sha256BigSigma0(a) + sha256Majority(a, b, c)
|
|
219
|
+
w[17] = sha256SmallSigma1(w[15]) + w[10] + sha256SmallSigma0(w[2]) + w[1]
|
|
220
|
+
t1 = g + sha256BigSigma1(d) + sha256Choose(d, e, f) + 0xefbe4786 + w[17]
|
|
221
|
+
c += t1
|
|
222
|
+
g = t1 + sha256BigSigma0(hh) + sha256Majority(hh, a, b)
|
|
223
|
+
w[18] = sha256SmallSigma1(w[16]) + w[11] + sha256SmallSigma0(w[3]) + w[2]
|
|
224
|
+
t1 = f + sha256BigSigma1(c) + sha256Choose(c, d, e) + 0x0fc19dc6 + w[18]
|
|
225
|
+
b += t1
|
|
226
|
+
f = t1 + sha256BigSigma0(g) + sha256Majority(g, hh, a)
|
|
227
|
+
w[19] = sha256SmallSigma1(w[17]) + w[12] + sha256SmallSigma0(w[4]) + w[3]
|
|
228
|
+
t1 = e + sha256BigSigma1(b) + sha256Choose(b, c, d) + 0x240ca1cc + w[19]
|
|
229
|
+
a += t1
|
|
230
|
+
e = t1 + sha256BigSigma0(f) + sha256Majority(f, g, hh)
|
|
231
|
+
w[20] = sha256SmallSigma1(w[18]) + w[13] + sha256SmallSigma0(w[5]) + w[4]
|
|
232
|
+
t1 = d + sha256BigSigma1(a) + sha256Choose(a, b, c) + 0x2de92c6f + w[20]
|
|
233
|
+
hh += t1
|
|
234
|
+
d = t1 + sha256BigSigma0(e) + sha256Majority(e, f, g)
|
|
235
|
+
w[21] = sha256SmallSigma1(w[19]) + w[14] + sha256SmallSigma0(w[6]) + w[5]
|
|
236
|
+
t1 = c + sha256BigSigma1(hh) + sha256Choose(hh, a, b) + 0x4a7484aa + w[21]
|
|
237
|
+
g += t1
|
|
238
|
+
c = t1 + sha256BigSigma0(d) + sha256Majority(d, e, f)
|
|
239
|
+
w[22] = sha256SmallSigma1(w[20]) + w[15] + sha256SmallSigma0(w[7]) + w[6]
|
|
240
|
+
t1 = b + sha256BigSigma1(g) + sha256Choose(g, hh, a) + 0x5cb0a9dc + w[22]
|
|
241
|
+
f += t1
|
|
242
|
+
b = t1 + sha256BigSigma0(c) + sha256Majority(c, d, e)
|
|
243
|
+
w[23] = sha256SmallSigma1(w[21]) + w[16] + sha256SmallSigma0(w[8]) + w[7]
|
|
244
|
+
t1 = a + sha256BigSigma1(f) + sha256Choose(f, g, hh) + 0x76f988da + w[23]
|
|
245
|
+
e += t1
|
|
246
|
+
a = t1 + sha256BigSigma0(b) + sha256Majority(b, c, d)
|
|
247
|
+
w[24] = sha256SmallSigma1(w[22]) + w[17] + sha256SmallSigma0(w[9]) + w[8]
|
|
248
|
+
t1 = hh + sha256BigSigma1(e) + sha256Choose(e, f, g) + 0x983e5152 + w[24]
|
|
249
|
+
d += t1
|
|
250
|
+
hh = t1 + sha256BigSigma0(a) + sha256Majority(a, b, c)
|
|
251
|
+
w[25] = sha256SmallSigma1(w[23]) + w[18] + sha256SmallSigma0(w[10]) + w[9]
|
|
252
|
+
t1 = g + sha256BigSigma1(d) + sha256Choose(d, e, f) + 0xa831c66d + w[25]
|
|
253
|
+
c += t1
|
|
254
|
+
g = t1 + sha256BigSigma0(hh) + sha256Majority(hh, a, b)
|
|
255
|
+
w[26] = sha256SmallSigma1(w[24]) + w[19] + sha256SmallSigma0(w[11]) + w[10]
|
|
256
|
+
t1 = f + sha256BigSigma1(c) + sha256Choose(c, d, e) + 0xb00327c8 + w[26]
|
|
257
|
+
b += t1
|
|
258
|
+
f = t1 + sha256BigSigma0(g) + sha256Majority(g, hh, a)
|
|
259
|
+
w[27] = sha256SmallSigma1(w[25]) + w[20] + sha256SmallSigma0(w[12]) + w[11]
|
|
260
|
+
t1 = e + sha256BigSigma1(b) + sha256Choose(b, c, d) + 0xbf597fc7 + w[27]
|
|
261
|
+
a += t1
|
|
262
|
+
e = t1 + sha256BigSigma0(f) + sha256Majority(f, g, hh)
|
|
263
|
+
w[28] = sha256SmallSigma1(w[26]) + w[21] + sha256SmallSigma0(w[13]) + w[12]
|
|
264
|
+
t1 = d + sha256BigSigma1(a) + sha256Choose(a, b, c) + 0xc6e00bf3 + w[28]
|
|
265
|
+
hh += t1
|
|
266
|
+
d = t1 + sha256BigSigma0(e) + sha256Majority(e, f, g)
|
|
267
|
+
w[29] = sha256SmallSigma1(w[27]) + w[22] + sha256SmallSigma0(w[14]) + w[13]
|
|
268
|
+
t1 = c + sha256BigSigma1(hh) + sha256Choose(hh, a, b) + 0xd5a79147 + w[29]
|
|
269
|
+
g += t1
|
|
270
|
+
c = t1 + sha256BigSigma0(d) + sha256Majority(d, e, f)
|
|
271
|
+
w[30] = sha256SmallSigma1(w[28]) + w[23] + sha256SmallSigma0(w[15]) + w[14]
|
|
272
|
+
t1 = b + sha256BigSigma1(g) + sha256Choose(g, hh, a) + 0x06ca6351 + w[30]
|
|
273
|
+
f += t1
|
|
274
|
+
b = t1 + sha256BigSigma0(c) + sha256Majority(c, d, e)
|
|
275
|
+
w[31] = sha256SmallSigma1(w[29]) + w[24] + sha256SmallSigma0(w[16]) + w[15]
|
|
276
|
+
t1 = a + sha256BigSigma1(f) + sha256Choose(f, g, hh) + 0x14292967 + w[31]
|
|
277
|
+
e += t1
|
|
278
|
+
a = t1 + sha256BigSigma0(b) + sha256Majority(b, c, d)
|
|
279
|
+
w[32] = sha256SmallSigma1(w[30]) + w[25] + sha256SmallSigma0(w[17]) + w[16]
|
|
280
|
+
t1 = hh + sha256BigSigma1(e) + sha256Choose(e, f, g) + 0x27b70a85 + w[32]
|
|
281
|
+
d += t1
|
|
282
|
+
hh = t1 + sha256BigSigma0(a) + sha256Majority(a, b, c)
|
|
283
|
+
w[33] = sha256SmallSigma1(w[31]) + w[26] + sha256SmallSigma0(w[18]) + w[17]
|
|
284
|
+
t1 = g + sha256BigSigma1(d) + sha256Choose(d, e, f) + 0x2e1b2138 + w[33]
|
|
285
|
+
c += t1
|
|
286
|
+
g = t1 + sha256BigSigma0(hh) + sha256Majority(hh, a, b)
|
|
287
|
+
w[34] = sha256SmallSigma1(w[32]) + w[27] + sha256SmallSigma0(w[19]) + w[18]
|
|
288
|
+
t1 = f + sha256BigSigma1(c) + sha256Choose(c, d, e) + 0x4d2c6dfc + w[34]
|
|
289
|
+
b += t1
|
|
290
|
+
f = t1 + sha256BigSigma0(g) + sha256Majority(g, hh, a)
|
|
291
|
+
w[35] = sha256SmallSigma1(w[33]) + w[28] + sha256SmallSigma0(w[20]) + w[19]
|
|
292
|
+
t1 = e + sha256BigSigma1(b) + sha256Choose(b, c, d) + 0x53380d13 + w[35]
|
|
293
|
+
a += t1
|
|
294
|
+
e = t1 + sha256BigSigma0(f) + sha256Majority(f, g, hh)
|
|
295
|
+
w[36] = sha256SmallSigma1(w[34]) + w[29] + sha256SmallSigma0(w[21]) + w[20]
|
|
296
|
+
t1 = d + sha256BigSigma1(a) + sha256Choose(a, b, c) + 0x650a7354 + w[36]
|
|
297
|
+
hh += t1
|
|
298
|
+
d = t1 + sha256BigSigma0(e) + sha256Majority(e, f, g)
|
|
299
|
+
w[37] = sha256SmallSigma1(w[35]) + w[30] + sha256SmallSigma0(w[22]) + w[21]
|
|
300
|
+
t1 = c + sha256BigSigma1(hh) + sha256Choose(hh, a, b) + 0x766a0abb + w[37]
|
|
301
|
+
g += t1
|
|
302
|
+
c = t1 + sha256BigSigma0(d) + sha256Majority(d, e, f)
|
|
303
|
+
w[38] = sha256SmallSigma1(w[36]) + w[31] + sha256SmallSigma0(w[23]) + w[22]
|
|
304
|
+
t1 = b + sha256BigSigma1(g) + sha256Choose(g, hh, a) + 0x81c2c92e + w[38]
|
|
305
|
+
f += t1
|
|
306
|
+
b = t1 + sha256BigSigma0(c) + sha256Majority(c, d, e)
|
|
307
|
+
w[39] = sha256SmallSigma1(w[37]) + w[32] + sha256SmallSigma0(w[24]) + w[23]
|
|
308
|
+
t1 = a + sha256BigSigma1(f) + sha256Choose(f, g, hh) + 0x92722c85 + w[39]
|
|
309
|
+
e += t1
|
|
310
|
+
a = t1 + sha256BigSigma0(b) + sha256Majority(b, c, d)
|
|
311
|
+
w[40] = sha256SmallSigma1(w[38]) + w[33] + sha256SmallSigma0(w[25]) + w[24]
|
|
312
|
+
t1 = hh + sha256BigSigma1(e) + sha256Choose(e, f, g) + 0xa2bfe8a1 + w[40]
|
|
313
|
+
d += t1
|
|
314
|
+
hh = t1 + sha256BigSigma0(a) + sha256Majority(a, b, c)
|
|
315
|
+
w[41] = sha256SmallSigma1(w[39]) + w[34] + sha256SmallSigma0(w[26]) + w[25]
|
|
316
|
+
t1 = g + sha256BigSigma1(d) + sha256Choose(d, e, f) + 0xa81a664b + w[41]
|
|
317
|
+
c += t1
|
|
318
|
+
g = t1 + sha256BigSigma0(hh) + sha256Majority(hh, a, b)
|
|
319
|
+
w[42] = sha256SmallSigma1(w[40]) + w[35] + sha256SmallSigma0(w[27]) + w[26]
|
|
320
|
+
t1 = f + sha256BigSigma1(c) + sha256Choose(c, d, e) + 0xc24b8b70 + w[42]
|
|
321
|
+
b += t1
|
|
322
|
+
f = t1 + sha256BigSigma0(g) + sha256Majority(g, hh, a)
|
|
323
|
+
w[43] = sha256SmallSigma1(w[41]) + w[36] + sha256SmallSigma0(w[28]) + w[27]
|
|
324
|
+
t1 = e + sha256BigSigma1(b) + sha256Choose(b, c, d) + 0xc76c51a3 + w[43]
|
|
325
|
+
a += t1
|
|
326
|
+
e = t1 + sha256BigSigma0(f) + sha256Majority(f, g, hh)
|
|
327
|
+
w[44] = sha256SmallSigma1(w[42]) + w[37] + sha256SmallSigma0(w[29]) + w[28]
|
|
328
|
+
t1 = d + sha256BigSigma1(a) + sha256Choose(a, b, c) + 0xd192e819 + w[44]
|
|
329
|
+
hh += t1
|
|
330
|
+
d = t1 + sha256BigSigma0(e) + sha256Majority(e, f, g)
|
|
331
|
+
w[45] = sha256SmallSigma1(w[43]) + w[38] + sha256SmallSigma0(w[30]) + w[29]
|
|
332
|
+
t1 = c + sha256BigSigma1(hh) + sha256Choose(hh, a, b) + 0xd6990624 + w[45]
|
|
333
|
+
g += t1
|
|
334
|
+
c = t1 + sha256BigSigma0(d) + sha256Majority(d, e, f)
|
|
335
|
+
w[46] = sha256SmallSigma1(w[44]) + w[39] + sha256SmallSigma0(w[31]) + w[30]
|
|
336
|
+
t1 = b + sha256BigSigma1(g) + sha256Choose(g, hh, a) + 0xf40e3585 + w[46]
|
|
337
|
+
f += t1
|
|
338
|
+
b = t1 + sha256BigSigma0(c) + sha256Majority(c, d, e)
|
|
339
|
+
w[47] = sha256SmallSigma1(w[45]) + w[40] + sha256SmallSigma0(w[32]) + w[31]
|
|
340
|
+
t1 = a + sha256BigSigma1(f) + sha256Choose(f, g, hh) + 0x106aa070 + w[47]
|
|
341
|
+
e += t1
|
|
342
|
+
a = t1 + sha256BigSigma0(b) + sha256Majority(b, c, d)
|
|
343
|
+
w[48] = sha256SmallSigma1(w[46]) + w[41] + sha256SmallSigma0(w[33]) + w[32]
|
|
344
|
+
t1 = hh + sha256BigSigma1(e) + sha256Choose(e, f, g) + 0x19a4c116 + w[48]
|
|
345
|
+
d += t1
|
|
346
|
+
hh = t1 + sha256BigSigma0(a) + sha256Majority(a, b, c)
|
|
347
|
+
w[49] = sha256SmallSigma1(w[47]) + w[42] + sha256SmallSigma0(w[34]) + w[33]
|
|
348
|
+
t1 = g + sha256BigSigma1(d) + sha256Choose(d, e, f) + 0x1e376c08 + w[49]
|
|
349
|
+
c += t1
|
|
350
|
+
g = t1 + sha256BigSigma0(hh) + sha256Majority(hh, a, b)
|
|
351
|
+
w[50] = sha256SmallSigma1(w[48]) + w[43] + sha256SmallSigma0(w[35]) + w[34]
|
|
352
|
+
t1 = f + sha256BigSigma1(c) + sha256Choose(c, d, e) + 0x2748774c + w[50]
|
|
353
|
+
b += t1
|
|
354
|
+
f = t1 + sha256BigSigma0(g) + sha256Majority(g, hh, a)
|
|
355
|
+
w[51] = sha256SmallSigma1(w[49]) + w[44] + sha256SmallSigma0(w[36]) + w[35]
|
|
356
|
+
t1 = e + sha256BigSigma1(b) + sha256Choose(b, c, d) + 0x34b0bcb5 + w[51]
|
|
357
|
+
a += t1
|
|
358
|
+
e = t1 + sha256BigSigma0(f) + sha256Majority(f, g, hh)
|
|
359
|
+
w[52] = sha256SmallSigma1(w[50]) + w[45] + sha256SmallSigma0(w[37]) + w[36]
|
|
360
|
+
t1 = d + sha256BigSigma1(a) + sha256Choose(a, b, c) + 0x391c0cb3 + w[52]
|
|
361
|
+
hh += t1
|
|
362
|
+
d = t1 + sha256BigSigma0(e) + sha256Majority(e, f, g)
|
|
363
|
+
w[53] = sha256SmallSigma1(w[51]) + w[46] + sha256SmallSigma0(w[38]) + w[37]
|
|
364
|
+
t1 = c + sha256BigSigma1(hh) + sha256Choose(hh, a, b) + 0x4ed8aa4a + w[53]
|
|
365
|
+
g += t1
|
|
366
|
+
c = t1 + sha256BigSigma0(d) + sha256Majority(d, e, f)
|
|
367
|
+
w[54] = sha256SmallSigma1(w[52]) + w[47] + sha256SmallSigma0(w[39]) + w[38]
|
|
368
|
+
t1 = b + sha256BigSigma1(g) + sha256Choose(g, hh, a) + 0x5b9cca4f + w[54]
|
|
369
|
+
f += t1
|
|
370
|
+
b = t1 + sha256BigSigma0(c) + sha256Majority(c, d, e)
|
|
371
|
+
w[55] = sha256SmallSigma1(w[53]) + w[48] + sha256SmallSigma0(w[40]) + w[39]
|
|
372
|
+
t1 = a + sha256BigSigma1(f) + sha256Choose(f, g, hh) + 0x682e6ff3 + w[55]
|
|
373
|
+
e += t1
|
|
374
|
+
a = t1 + sha256BigSigma0(b) + sha256Majority(b, c, d)
|
|
375
|
+
w[56] = sha256SmallSigma1(w[54]) + w[49] + sha256SmallSigma0(w[41]) + w[40]
|
|
376
|
+
t1 = hh + sha256BigSigma1(e) + sha256Choose(e, f, g) + 0x748f82ee + w[56]
|
|
377
|
+
d += t1
|
|
378
|
+
hh = t1 + sha256BigSigma0(a) + sha256Majority(a, b, c)
|
|
379
|
+
w[57] = sha256SmallSigma1(w[55]) + w[50] + sha256SmallSigma0(w[42]) + w[41]
|
|
380
|
+
t1 = g + sha256BigSigma1(d) + sha256Choose(d, e, f) + 0x78a5636f + w[57]
|
|
381
|
+
c += t1
|
|
382
|
+
g = t1 + sha256BigSigma0(hh) + sha256Majority(hh, a, b)
|
|
383
|
+
w[58] = sha256SmallSigma1(w[56]) + w[51] + sha256SmallSigma0(w[43]) + w[42]
|
|
384
|
+
t1 = f + sha256BigSigma1(c) + sha256Choose(c, d, e) + 0x84c87814 + w[58]
|
|
385
|
+
b += t1
|
|
386
|
+
f = t1 + sha256BigSigma0(g) + sha256Majority(g, hh, a)
|
|
387
|
+
w[59] = sha256SmallSigma1(w[57]) + w[52] + sha256SmallSigma0(w[44]) + w[43]
|
|
388
|
+
t1 = e + sha256BigSigma1(b) + sha256Choose(b, c, d) + 0x8cc70208 + w[59]
|
|
389
|
+
a += t1
|
|
390
|
+
e = t1 + sha256BigSigma0(f) + sha256Majority(f, g, hh)
|
|
391
|
+
w[60] = sha256SmallSigma1(w[58]) + w[53] + sha256SmallSigma0(w[45]) + w[44]
|
|
392
|
+
t1 = d + sha256BigSigma1(a) + sha256Choose(a, b, c) + 0x90befffa + w[60]
|
|
393
|
+
hh += t1
|
|
394
|
+
d = t1 + sha256BigSigma0(e) + sha256Majority(e, f, g)
|
|
395
|
+
w[61] = sha256SmallSigma1(w[59]) + w[54] + sha256SmallSigma0(w[46]) + w[45]
|
|
396
|
+
t1 = c + sha256BigSigma1(hh) + sha256Choose(hh, a, b) + 0xa4506ceb + w[61]
|
|
397
|
+
g += t1
|
|
398
|
+
c = t1 + sha256BigSigma0(d) + sha256Majority(d, e, f)
|
|
399
|
+
w[62] = sha256SmallSigma1(w[60]) + w[55] + sha256SmallSigma0(w[47]) + w[46]
|
|
400
|
+
t1 = b + sha256BigSigma1(g) + sha256Choose(g, hh, a) + 0xbef9a3f7 + w[62]
|
|
401
|
+
f += t1
|
|
402
|
+
b = t1 + sha256BigSigma0(c) + sha256Majority(c, d, e)
|
|
403
|
+
w[63] = sha256SmallSigma1(w[61]) + w[56] + sha256SmallSigma0(w[48]) + w[47]
|
|
404
|
+
t1 = a + sha256BigSigma1(f) + sha256Choose(f, g, hh) + 0xc67178f2 + w[63]
|
|
405
|
+
e += t1
|
|
406
|
+
a = t1 + sha256BigSigma0(b) + sha256Majority(b, c, d)
|
|
260
407
|
// Step 4: the next intermediate hash value.
|
|
261
408
|
h[0] += a
|
|
262
409
|
h[1] += b
|