dh-auth-library 1.0.0 → 1.2.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/README.md +23 -12
- package/dist/auth/api/apiTokenHelper.d.ts +2 -2
- package/dist/auth/api/index.d.ts +0 -1
- package/dist/auth/api/sessionHandlerResolvers.d.ts +3 -6
- package/dist/auth/pages/digidLoginPage.d.ts +1 -1
- package/dist/auth/pages/eHerkenningLoginPage.d.ts +6 -7
- package/dist/auth/sessionHandler.d.ts +1 -1
- package/dist/auth/utils/sessionFileHelper.d.ts +9 -8
- package/dist/constants/accountTypes.d.ts +7 -29
- package/dist/constants/authTypes.d.ts +3 -0
- package/dist/constants/index.d.ts +1 -4
- package/dist/index.cjs.js +35 -333
- package/dist/index.es.js +34 -317
- package/package.json +55 -54
- package/dist/auth/api/apiAuthentication.d.ts +0 -10
- package/dist/constants/accounts.d.ts +0 -12
- package/dist/constants/testAccounts.d.ts +0 -38
- package/dist/constants/testProfiles.d.ts +0 -27
- package/dist/sha-B5xpXfPW.mjs +0 -911
- package/dist/sha-Eh0BcCJ_.js +0 -911
package/dist/sha-B5xpXfPW.mjs
DELETED
|
@@ -1,911 +0,0 @@
|
|
|
1
|
-
//#region node_modules/.pnpm/jssha@3.3.2/node_modules/jssha/dist/sha.mjs
|
|
2
|
-
/**
|
|
3
|
-
* A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,
|
|
4
|
-
* and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.
|
|
5
|
-
*
|
|
6
|
-
* Copyright 2008-2026 Brian Turek, 1998-2009 Paul Johnston & Contributors
|
|
7
|
-
* Distributed under the BSD License
|
|
8
|
-
* See http://caligatio.github.com/jsSHA/ for more information
|
|
9
|
-
*/
|
|
10
|
-
var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
11
|
-
function r(t, n, e, r) {
|
|
12
|
-
let i, s, o;
|
|
13
|
-
const h = n || [0], u = (e = e || 0) >>> 3, w = -1 === r ? 3 : 0;
|
|
14
|
-
for (i = 0; i < t.length; i += 1) o = i + u, s = o >>> 2, h.length <= s && h.push(0), h[s] |= t[i] << 8 * (w + r * (o % 4));
|
|
15
|
-
return {
|
|
16
|
-
value: h,
|
|
17
|
-
binLen: 8 * t.length + e
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function i(i, s, o) {
|
|
21
|
-
switch (s) {
|
|
22
|
-
case "UTF8":
|
|
23
|
-
case "UTF16BE":
|
|
24
|
-
case "UTF16LE": break;
|
|
25
|
-
default: throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE");
|
|
26
|
-
}
|
|
27
|
-
switch (i) {
|
|
28
|
-
case "HEX": return function(t, n, e) {
|
|
29
|
-
return function(t, n, e, r) {
|
|
30
|
-
let i, s, o, h;
|
|
31
|
-
if (0 != t.length % 2) throw new Error("String of HEX type must be in byte increments");
|
|
32
|
-
const u = n || [0], w = (e = e || 0) >>> 3, c = -1 === r ? 3 : 0;
|
|
33
|
-
for (i = 0; i < t.length; i += 2) {
|
|
34
|
-
if (s = parseInt(t.substr(i, 2), 16), isNaN(s)) throw new Error("String of HEX type contains invalid characters");
|
|
35
|
-
for (h = (i >>> 1) + w, o = h >>> 2; u.length <= o;) u.push(0);
|
|
36
|
-
u[o] |= s << 8 * (c + r * (h % 4));
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
value: u,
|
|
40
|
-
binLen: 4 * t.length + e
|
|
41
|
-
};
|
|
42
|
-
}(t, n, e, o);
|
|
43
|
-
};
|
|
44
|
-
case "TEXT": return function(t, n, e) {
|
|
45
|
-
return function(t, n, e, r, i) {
|
|
46
|
-
let s, o, h, u, w, c, f, a, l = 0;
|
|
47
|
-
const A = e || [0], E = (r = r || 0) >>> 3;
|
|
48
|
-
if ("UTF8" === n) for (f = -1 === i ? 3 : 0, h = 0; h < t.length; h += 1) for (s = t.charCodeAt(h), o = [], 128 > s ? o.push(s) : 2048 > s ? (o.push(192 | s >>> 6), o.push(128 | 63 & s)) : 55296 > s || 57344 <= s ? o.push(224 | s >>> 12, 128 | s >>> 6 & 63, 128 | 63 & s) : (h += 1, s = 65536 + ((1023 & s) << 10 | 1023 & t.charCodeAt(h)), o.push(240 | s >>> 18, 128 | s >>> 12 & 63, 128 | s >>> 6 & 63, 128 | 63 & s)), u = 0; u < o.length; u += 1) {
|
|
49
|
-
for (c = l + E, w = c >>> 2; A.length <= w;) A.push(0);
|
|
50
|
-
A[w] |= o[u] << 8 * (f + i * (c % 4)), l += 1;
|
|
51
|
-
}
|
|
52
|
-
else for (f = -1 === i ? 2 : 0, a = "UTF16LE" === n && 1 !== i || "UTF16LE" !== n && 1 === i, h = 0; h < t.length; h += 1) {
|
|
53
|
-
for (s = t.charCodeAt(h), !0 === a && (u = 255 & s, s = u << 8 | s >>> 8), c = l + E, w = c >>> 2; A.length <= w;) A.push(0);
|
|
54
|
-
A[w] |= s << 8 * (f + i * (c % 4)), l += 2;
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
value: A,
|
|
58
|
-
binLen: 8 * l + r
|
|
59
|
-
};
|
|
60
|
-
}(t, s, n, e, o);
|
|
61
|
-
};
|
|
62
|
-
case "B64": return function(n, e, r) {
|
|
63
|
-
return function(n, e, r, i) {
|
|
64
|
-
let s, o, h, u, w, c, f, a = 0;
|
|
65
|
-
const l = e || [0], A = (r = r || 0) >>> 3, E = -1 === i ? 3 : 0, H = n.indexOf("=");
|
|
66
|
-
if (-1 === n.search(/^[a-zA-Z0-9=+/]+$/)) throw new Error("Invalid character in base-64 string");
|
|
67
|
-
if (n = n.replace(/=/g, ""), -1 !== H && H < n.length) throw new Error("Invalid '=' found in base-64 string");
|
|
68
|
-
for (o = 0; o < n.length; o += 4) {
|
|
69
|
-
for (w = n.substr(o, 4), u = 0, h = 0; h < w.length; h += 1) s = t.indexOf(w.charAt(h)), u |= s << 18 - 6 * h;
|
|
70
|
-
for (h = 0; h < w.length - 1; h += 1) {
|
|
71
|
-
for (f = a + A, c = f >>> 2; l.length <= c;) l.push(0);
|
|
72
|
-
l[c] |= (u >>> 16 - 8 * h & 255) << 8 * (E + i * (f % 4)), a += 1;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
value: l,
|
|
77
|
-
binLen: 8 * a + r
|
|
78
|
-
};
|
|
79
|
-
}(n, e, r, o);
|
|
80
|
-
};
|
|
81
|
-
case "BYTES": return function(t, n, e) {
|
|
82
|
-
return function(t, n, e, r) {
|
|
83
|
-
let i, s, o, h;
|
|
84
|
-
const u = n || [0], w = (e = e || 0) >>> 3, c = -1 === r ? 3 : 0;
|
|
85
|
-
for (s = 0; s < t.length; s += 1) i = t.charCodeAt(s), h = s + w, o = h >>> 2, u.length <= o && u.push(0), u[o] |= i << 8 * (c + r * (h % 4));
|
|
86
|
-
return {
|
|
87
|
-
value: u,
|
|
88
|
-
binLen: 8 * t.length + e
|
|
89
|
-
};
|
|
90
|
-
}(t, n, e, o);
|
|
91
|
-
};
|
|
92
|
-
case "ARRAYBUFFER": return function(t, n, e) {
|
|
93
|
-
return function(t, n, e, i) {
|
|
94
|
-
return r(new Uint8Array(t), n, e, i);
|
|
95
|
-
}(t, n, e, o);
|
|
96
|
-
};
|
|
97
|
-
case "UINT8ARRAY": return function(t, n, e) {
|
|
98
|
-
return r(t, n, e, o);
|
|
99
|
-
};
|
|
100
|
-
default: throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY");
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function s(r, i, s, o) {
|
|
104
|
-
switch (r) {
|
|
105
|
-
case "HEX": return function(t) {
|
|
106
|
-
return function(t, n, e, r) {
|
|
107
|
-
const i = "0123456789abcdef";
|
|
108
|
-
let s, o, h = "";
|
|
109
|
-
const u = n / 8, w = -1 === e ? 3 : 0;
|
|
110
|
-
for (s = 0; s < u; s += 1) o = t[s >>> 2] >>> 8 * (w + e * (s % 4)), h += i.charAt(o >>> 4 & 15) + i.charAt(15 & o);
|
|
111
|
-
return r.outputUpper ? h.toUpperCase() : h;
|
|
112
|
-
}(t, i, s, o);
|
|
113
|
-
};
|
|
114
|
-
case "B64": return function(n) {
|
|
115
|
-
return function(n, e, r, i) {
|
|
116
|
-
let s, o, h, u, w, c = "";
|
|
117
|
-
const f = e / 8, a = -1 === r ? 3 : 0;
|
|
118
|
-
for (s = 0; s < f; s += 3) for (u = s + 1 < f ? n[s + 1 >>> 2] : 0, w = s + 2 < f ? n[s + 2 >>> 2] : 0, h = (n[s >>> 2] >>> 8 * (a + r * (s % 4)) & 255) << 16 | (u >>> 8 * (a + r * ((s + 1) % 4)) & 255) << 8 | w >>> 8 * (a + r * ((s + 2) % 4)) & 255, o = 0; o < 4; o += 1) c += 8 * s + 6 * o <= e ? t.charAt(h >>> 6 * (3 - o) & 63) : i.b64Pad;
|
|
119
|
-
return c;
|
|
120
|
-
}(n, i, s, o);
|
|
121
|
-
};
|
|
122
|
-
case "BYTES": return function(t) {
|
|
123
|
-
return function(t, n, e) {
|
|
124
|
-
let r, i, s = "";
|
|
125
|
-
const o = n / 8, h = -1 === e ? 3 : 0;
|
|
126
|
-
for (r = 0; r < o; r += 1) i = t[r >>> 2] >>> 8 * (h + e * (r % 4)) & 255, s += String.fromCharCode(i);
|
|
127
|
-
return s;
|
|
128
|
-
}(t, i, s);
|
|
129
|
-
};
|
|
130
|
-
case "ARRAYBUFFER": return function(t) {
|
|
131
|
-
return function(t, n, e) {
|
|
132
|
-
let r;
|
|
133
|
-
const i = n / 8, s = new ArrayBuffer(i), o = new Uint8Array(s), h = -1 === e ? 3 : 0;
|
|
134
|
-
for (r = 0; r < i; r += 1) o[r] = t[r >>> 2] >>> 8 * (h + e * (r % 4)) & 255;
|
|
135
|
-
return s;
|
|
136
|
-
}(t, i, s);
|
|
137
|
-
};
|
|
138
|
-
case "UINT8ARRAY": return function(t) {
|
|
139
|
-
return function(t, n, e) {
|
|
140
|
-
let r;
|
|
141
|
-
const i = n / 8, s = -1 === e ? 3 : 0, o = new Uint8Array(i);
|
|
142
|
-
for (r = 0; r < i; r += 1) o[r] = t[r >>> 2] >>> 8 * (s + e * (r % 4)) & 255;
|
|
143
|
-
return o;
|
|
144
|
-
}(t, i, s);
|
|
145
|
-
};
|
|
146
|
-
default: throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY");
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
var o = 4294967296, h = [
|
|
150
|
-
1116352408,
|
|
151
|
-
1899447441,
|
|
152
|
-
3049323471,
|
|
153
|
-
3921009573,
|
|
154
|
-
961987163,
|
|
155
|
-
1508970993,
|
|
156
|
-
2453635748,
|
|
157
|
-
2870763221,
|
|
158
|
-
3624381080,
|
|
159
|
-
310598401,
|
|
160
|
-
607225278,
|
|
161
|
-
1426881987,
|
|
162
|
-
1925078388,
|
|
163
|
-
2162078206,
|
|
164
|
-
2614888103,
|
|
165
|
-
3248222580,
|
|
166
|
-
3835390401,
|
|
167
|
-
4022224774,
|
|
168
|
-
264347078,
|
|
169
|
-
604807628,
|
|
170
|
-
770255983,
|
|
171
|
-
1249150122,
|
|
172
|
-
1555081692,
|
|
173
|
-
1996064986,
|
|
174
|
-
2554220882,
|
|
175
|
-
2821834349,
|
|
176
|
-
2952996808,
|
|
177
|
-
3210313671,
|
|
178
|
-
3336571891,
|
|
179
|
-
3584528711,
|
|
180
|
-
113926993,
|
|
181
|
-
338241895,
|
|
182
|
-
666307205,
|
|
183
|
-
773529912,
|
|
184
|
-
1294757372,
|
|
185
|
-
1396182291,
|
|
186
|
-
1695183700,
|
|
187
|
-
1986661051,
|
|
188
|
-
2177026350,
|
|
189
|
-
2456956037,
|
|
190
|
-
2730485921,
|
|
191
|
-
2820302411,
|
|
192
|
-
3259730800,
|
|
193
|
-
3345764771,
|
|
194
|
-
3516065817,
|
|
195
|
-
3600352804,
|
|
196
|
-
4094571909,
|
|
197
|
-
275423344,
|
|
198
|
-
430227734,
|
|
199
|
-
506948616,
|
|
200
|
-
659060556,
|
|
201
|
-
883997877,
|
|
202
|
-
958139571,
|
|
203
|
-
1322822218,
|
|
204
|
-
1537002063,
|
|
205
|
-
1747873779,
|
|
206
|
-
1955562222,
|
|
207
|
-
2024104815,
|
|
208
|
-
2227730452,
|
|
209
|
-
2361852424,
|
|
210
|
-
2428436474,
|
|
211
|
-
2756734187,
|
|
212
|
-
3204031479,
|
|
213
|
-
3329325298
|
|
214
|
-
], u = [
|
|
215
|
-
3238371032,
|
|
216
|
-
914150663,
|
|
217
|
-
812702999,
|
|
218
|
-
4144912697,
|
|
219
|
-
4290775857,
|
|
220
|
-
1750603025,
|
|
221
|
-
1694076839,
|
|
222
|
-
3204075428
|
|
223
|
-
], w = [
|
|
224
|
-
1779033703,
|
|
225
|
-
3144134277,
|
|
226
|
-
1013904242,
|
|
227
|
-
2773480762,
|
|
228
|
-
1359893119,
|
|
229
|
-
2600822924,
|
|
230
|
-
528734635,
|
|
231
|
-
1541459225
|
|
232
|
-
], c = "Chosen SHA variant is not supported", f = "Cannot set numRounds with MAC";
|
|
233
|
-
function a(t, n) {
|
|
234
|
-
let e, r;
|
|
235
|
-
const i = t.binLen >>> 3, s = n.binLen >>> 3, o = i << 3, h = 4 - i << 3;
|
|
236
|
-
if (i % 4 != 0) {
|
|
237
|
-
for (e = 0; e < s; e += 4) r = i + e >>> 2, t.value[r] |= n.value[e >>> 2] << o, t.value.push(0), t.value[r + 1] |= n.value[e >>> 2] >>> h;
|
|
238
|
-
return (t.value.length << 2) - 4 >= s + i && t.value.pop(), {
|
|
239
|
-
value: t.value,
|
|
240
|
-
binLen: t.binLen + n.binLen
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
return {
|
|
244
|
-
value: t.value.concat(n.value),
|
|
245
|
-
binLen: t.binLen + n.binLen
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
function l(t) {
|
|
249
|
-
const n = {
|
|
250
|
-
outputUpper: !1,
|
|
251
|
-
b64Pad: "=",
|
|
252
|
-
outputLen: -1
|
|
253
|
-
}, e = t || {}, r = "Output length must be a multiple of 8";
|
|
254
|
-
if (n.outputUpper = e.outputUpper || !1, e.b64Pad && (n.b64Pad = e.b64Pad), e.outputLen) {
|
|
255
|
-
if (e.outputLen % 8 != 0) throw new Error(r);
|
|
256
|
-
n.outputLen = e.outputLen;
|
|
257
|
-
} else if (e.shakeLen) {
|
|
258
|
-
if (e.shakeLen % 8 != 0) throw new Error(r);
|
|
259
|
-
n.outputLen = e.shakeLen;
|
|
260
|
-
}
|
|
261
|
-
if ("boolean" != typeof n.outputUpper) throw new Error("Invalid outputUpper formatting option");
|
|
262
|
-
if ("string" != typeof n.b64Pad) throw new Error("Invalid b64Pad formatting option");
|
|
263
|
-
return n;
|
|
264
|
-
}
|
|
265
|
-
function A(t, n, e, r) {
|
|
266
|
-
const s = t + " must include a value and format";
|
|
267
|
-
if (!n) {
|
|
268
|
-
if (!r) throw new Error(s);
|
|
269
|
-
return r;
|
|
270
|
-
}
|
|
271
|
-
if (void 0 === n.value || !n.format) throw new Error(s);
|
|
272
|
-
return i(n.format, n.encoding || "UTF8", e)(n.value);
|
|
273
|
-
}
|
|
274
|
-
var E = class {
|
|
275
|
-
constructor(t, n, e) {
|
|
276
|
-
const r = e || {};
|
|
277
|
-
if (this.t = n, this.i = r.encoding || "UTF8", this.numRounds = r.numRounds || 1, isNaN(this.numRounds) || this.numRounds !== parseInt(this.numRounds, 10) || 1 > this.numRounds) throw new Error("numRounds must a integer >= 1");
|
|
278
|
-
this.o = t, this.h = [], this.u = 0, this.l = !1, this.A = 0, this.H = !1, this.S = [], this.p = [];
|
|
279
|
-
}
|
|
280
|
-
update(t) {
|
|
281
|
-
let n, e = 0;
|
|
282
|
-
const r = this.m >>> 5, i = this.C(t, this.h, this.u), s = i.binLen, o = i.value, h = s >>> 5;
|
|
283
|
-
for (n = 0; n < h; n += r) e + this.m <= s && (this.U = this.R(o.slice(n, n + r), this.U), e += this.m);
|
|
284
|
-
return this.A += e, this.h = o.slice(e >>> 5), this.u = s % this.m, this.l = !0, this;
|
|
285
|
-
}
|
|
286
|
-
getHash(t, n) {
|
|
287
|
-
let e, r, i = this.K;
|
|
288
|
-
const o = l(n);
|
|
289
|
-
if (this.v) {
|
|
290
|
-
if (-1 === o.outputLen) throw new Error("Output length must be specified in options");
|
|
291
|
-
i = o.outputLen;
|
|
292
|
-
}
|
|
293
|
-
const h = s(t, i, this.T, o);
|
|
294
|
-
if (this.H && this.F) return h(this.F(o));
|
|
295
|
-
for (r = this.L(this.h.slice(), this.u, this.A, this.B(this.U), i), e = 1; e < this.numRounds; e += 1) this.v && i % 32 != 0 && (r[r.length - 1] &= 16777215 >>> 24 - i % 32), r = this.L(r, i, 0, this.M(this.o), i);
|
|
296
|
-
return h(r);
|
|
297
|
-
}
|
|
298
|
-
setHMACKey(t, n, e) {
|
|
299
|
-
if (!this.k) throw new Error("Variant does not support HMAC");
|
|
300
|
-
if (this.l) throw new Error("Cannot set MAC key after calling update");
|
|
301
|
-
const r = i(n, (e || {}).encoding || "UTF8", this.T);
|
|
302
|
-
this.Y(r(t));
|
|
303
|
-
}
|
|
304
|
-
Y(t) {
|
|
305
|
-
const n = this.m >>> 3, e = n / 4 - 1;
|
|
306
|
-
let r;
|
|
307
|
-
if (1 !== this.numRounds) throw new Error(f);
|
|
308
|
-
if (this.H) throw new Error("MAC key already set");
|
|
309
|
-
for (n < t.binLen / 8 && (t.value = this.L(t.value, t.binLen, 0, this.M(this.o), this.K)); t.value.length <= e;) t.value.push(0);
|
|
310
|
-
for (r = 0; r <= e; r += 1) this.S[r] = 909522486 ^ t.value[r], this.p[r] = 1549556828 ^ t.value[r];
|
|
311
|
-
this.U = this.R(this.S, this.U), this.A = this.m, this.H = !0;
|
|
312
|
-
}
|
|
313
|
-
getHMAC(t, n) {
|
|
314
|
-
const e = l(n);
|
|
315
|
-
return s(t, this.K, this.T, e)(this.N());
|
|
316
|
-
}
|
|
317
|
-
N() {
|
|
318
|
-
let t;
|
|
319
|
-
if (!this.H) throw new Error("Cannot call getHMAC without first setting MAC key");
|
|
320
|
-
const n = this.L(this.h.slice(), this.u, this.A, this.B(this.U), this.K);
|
|
321
|
-
return t = this.R(this.p, this.M(this.o)), t = this.L(n, this.K, this.m, t, this.K), t;
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
function H(t, n) {
|
|
325
|
-
return t << n | t >>> 32 - n;
|
|
326
|
-
}
|
|
327
|
-
function S(t, n) {
|
|
328
|
-
return t >>> n | t << 32 - n;
|
|
329
|
-
}
|
|
330
|
-
function b(t, n) {
|
|
331
|
-
return t >>> n;
|
|
332
|
-
}
|
|
333
|
-
function p(t, n, e) {
|
|
334
|
-
return t ^ n ^ e;
|
|
335
|
-
}
|
|
336
|
-
function d(t, n, e) {
|
|
337
|
-
return t & n ^ ~t & e;
|
|
338
|
-
}
|
|
339
|
-
function m(t, n, e) {
|
|
340
|
-
return t & n ^ t & e ^ n & e;
|
|
341
|
-
}
|
|
342
|
-
function C(t) {
|
|
343
|
-
return S(t, 2) ^ S(t, 13) ^ S(t, 22);
|
|
344
|
-
}
|
|
345
|
-
function y(t, n) {
|
|
346
|
-
const e = (65535 & t) + (65535 & n);
|
|
347
|
-
return (65535 & (t >>> 16) + (n >>> 16) + (e >>> 16)) << 16 | 65535 & e;
|
|
348
|
-
}
|
|
349
|
-
function U(t, n, e, r) {
|
|
350
|
-
const i = (65535 & t) + (65535 & n) + (65535 & e) + (65535 & r);
|
|
351
|
-
return (65535 & (t >>> 16) + (n >>> 16) + (e >>> 16) + (r >>> 16) + (i >>> 16)) << 16 | 65535 & i;
|
|
352
|
-
}
|
|
353
|
-
function R(t, n, e, r, i) {
|
|
354
|
-
const s = (65535 & t) + (65535 & n) + (65535 & e) + (65535 & r) + (65535 & i);
|
|
355
|
-
return (65535 & (t >>> 16) + (n >>> 16) + (e >>> 16) + (r >>> 16) + (i >>> 16) + (s >>> 16)) << 16 | 65535 & s;
|
|
356
|
-
}
|
|
357
|
-
function K(t) {
|
|
358
|
-
return S(t, 17) ^ S(t, 19) ^ b(t, 10);
|
|
359
|
-
}
|
|
360
|
-
function v(t) {
|
|
361
|
-
return S(t, 7) ^ S(t, 18) ^ b(t, 3);
|
|
362
|
-
}
|
|
363
|
-
function T(t) {
|
|
364
|
-
return S(t, 6) ^ S(t, 11) ^ S(t, 25);
|
|
365
|
-
}
|
|
366
|
-
function g(t) {
|
|
367
|
-
return [
|
|
368
|
-
1732584193,
|
|
369
|
-
4023233417,
|
|
370
|
-
2562383102,
|
|
371
|
-
271733878,
|
|
372
|
-
3285377520
|
|
373
|
-
];
|
|
374
|
-
}
|
|
375
|
-
function F(t, n) {
|
|
376
|
-
let e, r, i, s, o, h, u;
|
|
377
|
-
const w = [];
|
|
378
|
-
for (e = n[0], r = n[1], i = n[2], s = n[3], o = n[4], u = 0; u < 80; u += 1) w[u] = u < 16 ? t[u] : H(w[u - 3] ^ w[u - 8] ^ w[u - 14] ^ w[u - 16], 1), h = u < 20 ? R(H(e, 5), d(r, i, s), o, 1518500249, w[u]) : u < 40 ? R(H(e, 5), p(r, i, s), o, 1859775393, w[u]) : u < 60 ? R(H(e, 5), m(r, i, s), o, 2400959708, w[u]) : R(H(e, 5), p(r, i, s), o, 3395469782, w[u]), o = s, s = i, i = H(r, 30), r = e, e = h;
|
|
379
|
-
return n[0] = y(e, n[0]), n[1] = y(r, n[1]), n[2] = y(i, n[2]), n[3] = y(s, n[3]), n[4] = y(o, n[4]), n;
|
|
380
|
-
}
|
|
381
|
-
function L(t, n, e, r) {
|
|
382
|
-
let i;
|
|
383
|
-
const s = 15 + (n + 65 >>> 9 << 4), h = n + e;
|
|
384
|
-
for (; t.length <= s;) t.push(0);
|
|
385
|
-
for (t[n >>> 5] |= 128 << 24 - n % 32, t[s] = 4294967295 & h, t[s - 1] = h / o | 0, i = 0; i < t.length; i += 16) r = F(t.slice(i, i + 16), r);
|
|
386
|
-
return r;
|
|
387
|
-
}
|
|
388
|
-
var B = class extends E {
|
|
389
|
-
constructor(t, n, e) {
|
|
390
|
-
if ("SHA-1" !== t) throw new Error(c);
|
|
391
|
-
super(t, n, e);
|
|
392
|
-
const r = e || {};
|
|
393
|
-
this.k = !0, this.F = this.N, this.T = -1, this.C = i(this.t, this.i, this.T), this.R = F, this.B = function(t) {
|
|
394
|
-
return t.slice();
|
|
395
|
-
}, this.M = g, this.L = L, this.U = [
|
|
396
|
-
1732584193,
|
|
397
|
-
4023233417,
|
|
398
|
-
2562383102,
|
|
399
|
-
271733878,
|
|
400
|
-
3285377520
|
|
401
|
-
], this.m = 512, this.K = 160, this.v = !1, r.hmacKey && this.Y(A("hmacKey", r.hmacKey, this.T));
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
function M(t) {
|
|
405
|
-
let n;
|
|
406
|
-
return n = "SHA-224" == t ? u.slice() : w.slice(), n;
|
|
407
|
-
}
|
|
408
|
-
function k(t, n) {
|
|
409
|
-
let e, r, i, s, o, u, w, c, f, a, l;
|
|
410
|
-
const A = [];
|
|
411
|
-
for (e = n[0], r = n[1], i = n[2], s = n[3], o = n[4], u = n[5], w = n[6], c = n[7], l = 0; l < 64; l += 1) A[l] = l < 16 ? t[l] : U(K(A[l - 2]), A[l - 7], v(A[l - 15]), A[l - 16]), f = R(c, T(o), d(o, u, w), h[l], A[l]), a = y(C(e), m(e, r, i)), c = w, w = u, u = o, o = y(s, f), s = i, i = r, r = e, e = y(f, a);
|
|
412
|
-
return n[0] = y(e, n[0]), n[1] = y(r, n[1]), n[2] = y(i, n[2]), n[3] = y(s, n[3]), n[4] = y(o, n[4]), n[5] = y(u, n[5]), n[6] = y(w, n[6]), n[7] = y(c, n[7]), n;
|
|
413
|
-
}
|
|
414
|
-
var Y = class extends E {
|
|
415
|
-
constructor(t, n, e) {
|
|
416
|
-
if ("SHA-224" !== t && "SHA-256" !== t) throw new Error(c);
|
|
417
|
-
super(t, n, e);
|
|
418
|
-
const r = e || {};
|
|
419
|
-
this.F = this.N, this.k = !0, this.T = -1, this.C = i(this.t, this.i, this.T), this.R = k, this.B = function(t) {
|
|
420
|
-
return t.slice();
|
|
421
|
-
}, this.M = M, this.L = function(n, e, r, i) {
|
|
422
|
-
return function(t, n, e, r, i) {
|
|
423
|
-
let s, h;
|
|
424
|
-
const u = 15 + (n + 65 >>> 9 << 4), w = n + e;
|
|
425
|
-
for (; t.length <= u;) t.push(0);
|
|
426
|
-
for (t[n >>> 5] |= 128 << 24 - n % 32, t[u] = 4294967295 & w, t[u - 1] = w / o | 0, s = 0; s < t.length; s += 16) r = k(t.slice(s, s + 16), r);
|
|
427
|
-
return h = "SHA-224" === i ? [
|
|
428
|
-
r[0],
|
|
429
|
-
r[1],
|
|
430
|
-
r[2],
|
|
431
|
-
r[3],
|
|
432
|
-
r[4],
|
|
433
|
-
r[5],
|
|
434
|
-
r[6]
|
|
435
|
-
] : r, h;
|
|
436
|
-
}(n, e, r, i, t);
|
|
437
|
-
}, this.U = M(t), this.m = 512, this.K = "SHA-224" === t ? 224 : 256, this.v = !1, r.hmacKey && this.Y(A("hmacKey", r.hmacKey, this.T));
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
var N = class {
|
|
441
|
-
constructor(t, n) {
|
|
442
|
-
this.I = t, this.X = n;
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
function I(t, n) {
|
|
446
|
-
let e;
|
|
447
|
-
return n > 32 ? (e = 64 - n, new N(t.X << n | t.I >>> e, t.I << n | t.X >>> e)) : 0 !== n ? (e = 32 - n, new N(t.I << n | t.X >>> e, t.X << n | t.I >>> e)) : t;
|
|
448
|
-
}
|
|
449
|
-
function X(t, n) {
|
|
450
|
-
let e;
|
|
451
|
-
return n < 32 ? (e = 32 - n, new N(t.I >>> n | t.X << e, t.X >>> n | t.I << e)) : (e = 64 - n, new N(t.X >>> n | t.I << e, t.I >>> n | t.X << e));
|
|
452
|
-
}
|
|
453
|
-
function z(t, n) {
|
|
454
|
-
return new N(t.I >>> n, t.X >>> n | t.I << 32 - n);
|
|
455
|
-
}
|
|
456
|
-
function x(t, n, e) {
|
|
457
|
-
return new N(t.I & n.I ^ ~t.I & e.I, t.X & n.X ^ ~t.X & e.X);
|
|
458
|
-
}
|
|
459
|
-
function _(t, n, e) {
|
|
460
|
-
return new N(t.I & n.I ^ t.I & e.I ^ n.I & e.I, t.X & n.X ^ t.X & e.X ^ n.X & e.X);
|
|
461
|
-
}
|
|
462
|
-
function O(t) {
|
|
463
|
-
const n = X(t, 28), e = X(t, 34), r = X(t, 39);
|
|
464
|
-
return new N(n.I ^ e.I ^ r.I, n.X ^ e.X ^ r.X);
|
|
465
|
-
}
|
|
466
|
-
function P(t, n) {
|
|
467
|
-
let e, r;
|
|
468
|
-
e = (65535 & t.X) + (65535 & n.X), r = (t.X >>> 16) + (n.X >>> 16) + (e >>> 16);
|
|
469
|
-
const i = (65535 & r) << 16 | 65535 & e;
|
|
470
|
-
e = (65535 & t.I) + (65535 & n.I) + (r >>> 16), r = (t.I >>> 16) + (n.I >>> 16) + (e >>> 16);
|
|
471
|
-
return new N((65535 & r) << 16 | 65535 & e, i);
|
|
472
|
-
}
|
|
473
|
-
function V(t, n, e, r) {
|
|
474
|
-
let i, s;
|
|
475
|
-
i = (65535 & t.X) + (65535 & n.X) + (65535 & e.X) + (65535 & r.X), s = (t.X >>> 16) + (n.X >>> 16) + (e.X >>> 16) + (r.X >>> 16) + (i >>> 16);
|
|
476
|
-
const o = (65535 & s) << 16 | 65535 & i;
|
|
477
|
-
i = (65535 & t.I) + (65535 & n.I) + (65535 & e.I) + (65535 & r.I) + (s >>> 16), s = (t.I >>> 16) + (n.I >>> 16) + (e.I >>> 16) + (r.I >>> 16) + (i >>> 16);
|
|
478
|
-
return new N((65535 & s) << 16 | 65535 & i, o);
|
|
479
|
-
}
|
|
480
|
-
function Z(t, n, e, r, i) {
|
|
481
|
-
let s, o;
|
|
482
|
-
s = (65535 & t.X) + (65535 & n.X) + (65535 & e.X) + (65535 & r.X) + (65535 & i.X), o = (t.X >>> 16) + (n.X >>> 16) + (e.X >>> 16) + (r.X >>> 16) + (i.X >>> 16) + (s >>> 16);
|
|
483
|
-
const h = (65535 & o) << 16 | 65535 & s;
|
|
484
|
-
s = (65535 & t.I) + (65535 & n.I) + (65535 & e.I) + (65535 & r.I) + (65535 & i.I) + (o >>> 16), o = (t.I >>> 16) + (n.I >>> 16) + (e.I >>> 16) + (r.I >>> 16) + (i.I >>> 16) + (s >>> 16);
|
|
485
|
-
return new N((65535 & o) << 16 | 65535 & s, h);
|
|
486
|
-
}
|
|
487
|
-
function j(t, n) {
|
|
488
|
-
return new N(t.I ^ n.I, t.X ^ n.X);
|
|
489
|
-
}
|
|
490
|
-
function q(t, n, e, r, i) {
|
|
491
|
-
return new N(t.I ^ n.I ^ e.I ^ r.I ^ i.I, t.X ^ n.X ^ e.X ^ r.X ^ i.X);
|
|
492
|
-
}
|
|
493
|
-
function D(t) {
|
|
494
|
-
const n = X(t, 19), e = X(t, 61), r = z(t, 6);
|
|
495
|
-
return new N(n.I ^ e.I ^ r.I, n.X ^ e.X ^ r.X);
|
|
496
|
-
}
|
|
497
|
-
function G(t) {
|
|
498
|
-
const n = X(t, 1), e = X(t, 8), r = z(t, 7);
|
|
499
|
-
return new N(n.I ^ e.I ^ r.I, n.X ^ e.X ^ r.X);
|
|
500
|
-
}
|
|
501
|
-
function J(t) {
|
|
502
|
-
const n = X(t, 14), e = X(t, 18), r = X(t, 41);
|
|
503
|
-
return new N(n.I ^ e.I ^ r.I, n.X ^ e.X ^ r.X);
|
|
504
|
-
}
|
|
505
|
-
var Q = [
|
|
506
|
-
new N(h[0], 3609767458),
|
|
507
|
-
new N(h[1], 602891725),
|
|
508
|
-
new N(h[2], 3964484399),
|
|
509
|
-
new N(h[3], 2173295548),
|
|
510
|
-
new N(h[4], 4081628472),
|
|
511
|
-
new N(h[5], 3053834265),
|
|
512
|
-
new N(h[6], 2937671579),
|
|
513
|
-
new N(h[7], 3664609560),
|
|
514
|
-
new N(h[8], 2734883394),
|
|
515
|
-
new N(h[9], 1164996542),
|
|
516
|
-
new N(h[10], 1323610764),
|
|
517
|
-
new N(h[11], 3590304994),
|
|
518
|
-
new N(h[12], 4068182383),
|
|
519
|
-
new N(h[13], 991336113),
|
|
520
|
-
new N(h[14], 633803317),
|
|
521
|
-
new N(h[15], 3479774868),
|
|
522
|
-
new N(h[16], 2666613458),
|
|
523
|
-
new N(h[17], 944711139),
|
|
524
|
-
new N(h[18], 2341262773),
|
|
525
|
-
new N(h[19], 2007800933),
|
|
526
|
-
new N(h[20], 1495990901),
|
|
527
|
-
new N(h[21], 1856431235),
|
|
528
|
-
new N(h[22], 3175218132),
|
|
529
|
-
new N(h[23], 2198950837),
|
|
530
|
-
new N(h[24], 3999719339),
|
|
531
|
-
new N(h[25], 766784016),
|
|
532
|
-
new N(h[26], 2566594879),
|
|
533
|
-
new N(h[27], 3203337956),
|
|
534
|
-
new N(h[28], 1034457026),
|
|
535
|
-
new N(h[29], 2466948901),
|
|
536
|
-
new N(h[30], 3758326383),
|
|
537
|
-
new N(h[31], 168717936),
|
|
538
|
-
new N(h[32], 1188179964),
|
|
539
|
-
new N(h[33], 1546045734),
|
|
540
|
-
new N(h[34], 1522805485),
|
|
541
|
-
new N(h[35], 2643833823),
|
|
542
|
-
new N(h[36], 2343527390),
|
|
543
|
-
new N(h[37], 1014477480),
|
|
544
|
-
new N(h[38], 1206759142),
|
|
545
|
-
new N(h[39], 344077627),
|
|
546
|
-
new N(h[40], 1290863460),
|
|
547
|
-
new N(h[41], 3158454273),
|
|
548
|
-
new N(h[42], 3505952657),
|
|
549
|
-
new N(h[43], 106217008),
|
|
550
|
-
new N(h[44], 3606008344),
|
|
551
|
-
new N(h[45], 1432725776),
|
|
552
|
-
new N(h[46], 1467031594),
|
|
553
|
-
new N(h[47], 851169720),
|
|
554
|
-
new N(h[48], 3100823752),
|
|
555
|
-
new N(h[49], 1363258195),
|
|
556
|
-
new N(h[50], 3750685593),
|
|
557
|
-
new N(h[51], 3785050280),
|
|
558
|
-
new N(h[52], 3318307427),
|
|
559
|
-
new N(h[53], 3812723403),
|
|
560
|
-
new N(h[54], 2003034995),
|
|
561
|
-
new N(h[55], 3602036899),
|
|
562
|
-
new N(h[56], 1575990012),
|
|
563
|
-
new N(h[57], 1125592928),
|
|
564
|
-
new N(h[58], 2716904306),
|
|
565
|
-
new N(h[59], 442776044),
|
|
566
|
-
new N(h[60], 593698344),
|
|
567
|
-
new N(h[61], 3733110249),
|
|
568
|
-
new N(h[62], 2999351573),
|
|
569
|
-
new N(h[63], 3815920427),
|
|
570
|
-
new N(3391569614, 3928383900),
|
|
571
|
-
new N(3515267271, 566280711),
|
|
572
|
-
new N(3940187606, 3454069534),
|
|
573
|
-
new N(4118630271, 4000239992),
|
|
574
|
-
new N(116418474, 1914138554),
|
|
575
|
-
new N(174292421, 2731055270),
|
|
576
|
-
new N(289380356, 3203993006),
|
|
577
|
-
new N(460393269, 320620315),
|
|
578
|
-
new N(685471733, 587496836),
|
|
579
|
-
new N(852142971, 1086792851),
|
|
580
|
-
new N(1017036298, 365543100),
|
|
581
|
-
new N(1126000580, 2618297676),
|
|
582
|
-
new N(1288033470, 3409855158),
|
|
583
|
-
new N(1501505948, 4234509866),
|
|
584
|
-
new N(1607167915, 987167468),
|
|
585
|
-
new N(1816402316, 1246189591)
|
|
586
|
-
];
|
|
587
|
-
function W(t) {
|
|
588
|
-
return "SHA-384" === t ? [
|
|
589
|
-
new N(3418070365, u[0]),
|
|
590
|
-
new N(1654270250, u[1]),
|
|
591
|
-
new N(2438529370, u[2]),
|
|
592
|
-
new N(355462360, u[3]),
|
|
593
|
-
new N(1731405415, u[4]),
|
|
594
|
-
new N(41048885895, u[5]),
|
|
595
|
-
new N(3675008525, u[6]),
|
|
596
|
-
new N(1203062813, u[7])
|
|
597
|
-
] : [
|
|
598
|
-
new N(w[0], 4089235720),
|
|
599
|
-
new N(w[1], 2227873595),
|
|
600
|
-
new N(w[2], 4271175723),
|
|
601
|
-
new N(w[3], 1595750129),
|
|
602
|
-
new N(w[4], 2917565137),
|
|
603
|
-
new N(w[5], 725511199),
|
|
604
|
-
new N(w[6], 4215389547),
|
|
605
|
-
new N(w[7], 327033209)
|
|
606
|
-
];
|
|
607
|
-
}
|
|
608
|
-
function $(t, n) {
|
|
609
|
-
let e, r, i, s, o, h, u, w, c, f, a, l;
|
|
610
|
-
const A = [];
|
|
611
|
-
for (e = n[0], r = n[1], i = n[2], s = n[3], o = n[4], h = n[5], u = n[6], w = n[7], a = 0; a < 80; a += 1) a < 16 ? (l = 2 * a, A[a] = new N(t[l], t[l + 1])) : A[a] = V(D(A[a - 2]), A[a - 7], G(A[a - 15]), A[a - 16]), c = Z(w, J(o), x(o, h, u), Q[a], A[a]), f = P(O(e), _(e, r, i)), w = u, u = h, h = o, o = P(s, c), s = i, i = r, r = e, e = P(c, f);
|
|
612
|
-
return n[0] = P(e, n[0]), n[1] = P(r, n[1]), n[2] = P(i, n[2]), n[3] = P(s, n[3]), n[4] = P(o, n[4]), n[5] = P(h, n[5]), n[6] = P(u, n[6]), n[7] = P(w, n[7]), n;
|
|
613
|
-
}
|
|
614
|
-
var tt = class extends E {
|
|
615
|
-
constructor(t, n, e) {
|
|
616
|
-
if ("SHA-384" !== t && "SHA-512" !== t) throw new Error(c);
|
|
617
|
-
super(t, n, e);
|
|
618
|
-
const r = e || {};
|
|
619
|
-
this.F = this.N, this.k = !0, this.T = -1, this.C = i(this.t, this.i, this.T), this.R = $, this.B = function(t) {
|
|
620
|
-
return t.slice();
|
|
621
|
-
}, this.M = W, this.L = function(n, e, r, i) {
|
|
622
|
-
return function(t, n, e, r, i) {
|
|
623
|
-
let s, h;
|
|
624
|
-
const u = 31 + (n + 129 >>> 10 << 5), w = n + e;
|
|
625
|
-
for (; t.length <= u;) t.push(0);
|
|
626
|
-
for (t[n >>> 5] |= 128 << 24 - n % 32, t[u] = 4294967295 & w, t[u - 1] = w / o | 0, s = 0; s < t.length; s += 32) r = $(t.slice(s, s + 32), r);
|
|
627
|
-
return h = "SHA-384" === i ? [
|
|
628
|
-
r[0].I,
|
|
629
|
-
r[0].X,
|
|
630
|
-
r[1].I,
|
|
631
|
-
r[1].X,
|
|
632
|
-
r[2].I,
|
|
633
|
-
r[2].X,
|
|
634
|
-
r[3].I,
|
|
635
|
-
r[3].X,
|
|
636
|
-
r[4].I,
|
|
637
|
-
r[4].X,
|
|
638
|
-
r[5].I,
|
|
639
|
-
r[5].X
|
|
640
|
-
] : [
|
|
641
|
-
r[0].I,
|
|
642
|
-
r[0].X,
|
|
643
|
-
r[1].I,
|
|
644
|
-
r[1].X,
|
|
645
|
-
r[2].I,
|
|
646
|
-
r[2].X,
|
|
647
|
-
r[3].I,
|
|
648
|
-
r[3].X,
|
|
649
|
-
r[4].I,
|
|
650
|
-
r[4].X,
|
|
651
|
-
r[5].I,
|
|
652
|
-
r[5].X,
|
|
653
|
-
r[6].I,
|
|
654
|
-
r[6].X,
|
|
655
|
-
r[7].I,
|
|
656
|
-
r[7].X
|
|
657
|
-
], h;
|
|
658
|
-
}(n, e, r, i, t);
|
|
659
|
-
}, this.U = W(t), this.m = 1024, this.K = "SHA-384" === t ? 384 : 512, this.v = !1, r.hmacKey && this.Y(A("hmacKey", r.hmacKey, this.T));
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
var nt = [
|
|
663
|
-
new N(0, 1),
|
|
664
|
-
new N(0, 32898),
|
|
665
|
-
new N(2147483648, 32906),
|
|
666
|
-
new N(2147483648, 2147516416),
|
|
667
|
-
new N(0, 32907),
|
|
668
|
-
new N(0, 2147483649),
|
|
669
|
-
new N(2147483648, 2147516545),
|
|
670
|
-
new N(2147483648, 32777),
|
|
671
|
-
new N(0, 138),
|
|
672
|
-
new N(0, 136),
|
|
673
|
-
new N(0, 2147516425),
|
|
674
|
-
new N(0, 2147483658),
|
|
675
|
-
new N(0, 2147516555),
|
|
676
|
-
new N(2147483648, 139),
|
|
677
|
-
new N(2147483648, 32905),
|
|
678
|
-
new N(2147483648, 32771),
|
|
679
|
-
new N(2147483648, 32770),
|
|
680
|
-
new N(2147483648, 128),
|
|
681
|
-
new N(0, 32778),
|
|
682
|
-
new N(2147483648, 2147483658),
|
|
683
|
-
new N(2147483648, 2147516545),
|
|
684
|
-
new N(2147483648, 32896),
|
|
685
|
-
new N(0, 2147483649),
|
|
686
|
-
new N(2147483648, 2147516424)
|
|
687
|
-
], et = [
|
|
688
|
-
[
|
|
689
|
-
0,
|
|
690
|
-
36,
|
|
691
|
-
3,
|
|
692
|
-
41,
|
|
693
|
-
18
|
|
694
|
-
],
|
|
695
|
-
[
|
|
696
|
-
1,
|
|
697
|
-
44,
|
|
698
|
-
10,
|
|
699
|
-
45,
|
|
700
|
-
2
|
|
701
|
-
],
|
|
702
|
-
[
|
|
703
|
-
62,
|
|
704
|
-
6,
|
|
705
|
-
43,
|
|
706
|
-
15,
|
|
707
|
-
61
|
|
708
|
-
],
|
|
709
|
-
[
|
|
710
|
-
28,
|
|
711
|
-
55,
|
|
712
|
-
25,
|
|
713
|
-
21,
|
|
714
|
-
56
|
|
715
|
-
],
|
|
716
|
-
[
|
|
717
|
-
27,
|
|
718
|
-
20,
|
|
719
|
-
39,
|
|
720
|
-
8,
|
|
721
|
-
14
|
|
722
|
-
]
|
|
723
|
-
];
|
|
724
|
-
function rt(t) {
|
|
725
|
-
let n;
|
|
726
|
-
const e = [];
|
|
727
|
-
for (n = 0; n < 5; n += 1) e[n] = [
|
|
728
|
-
new N(0, 0),
|
|
729
|
-
new N(0, 0),
|
|
730
|
-
new N(0, 0),
|
|
731
|
-
new N(0, 0),
|
|
732
|
-
new N(0, 0)
|
|
733
|
-
];
|
|
734
|
-
return e;
|
|
735
|
-
}
|
|
736
|
-
function it(t) {
|
|
737
|
-
let n;
|
|
738
|
-
const e = [];
|
|
739
|
-
for (n = 0; n < 5; n += 1) e[n] = t[n].slice();
|
|
740
|
-
return e;
|
|
741
|
-
}
|
|
742
|
-
function st(t, n) {
|
|
743
|
-
let e, r, i, s;
|
|
744
|
-
const o = [], h = [];
|
|
745
|
-
if (null !== t) for (r = 0; r < t.length; r += 2) n[(r >>> 1) % 5][(r >>> 1) / 5 | 0] = j(n[(r >>> 1) % 5][(r >>> 1) / 5 | 0], new N(t[r + 1], t[r]));
|
|
746
|
-
for (e = 0; e < 24; e += 1) {
|
|
747
|
-
for (s = rt(), r = 0; r < 5; r += 1) o[r] = q(n[r][0], n[r][1], n[r][2], n[r][3], n[r][4]);
|
|
748
|
-
for (r = 0; r < 5; r += 1) h[r] = j(o[(r + 4) % 5], I(o[(r + 1) % 5], 1));
|
|
749
|
-
for (r = 0; r < 5; r += 1) for (i = 0; i < 5; i += 1) n[r][i] = j(n[r][i], h[r]);
|
|
750
|
-
for (r = 0; r < 5; r += 1) for (i = 0; i < 5; i += 1) s[i][(2 * r + 3 * i) % 5] = I(n[r][i], et[r][i]);
|
|
751
|
-
for (r = 0; r < 5; r += 1) for (i = 0; i < 5; i += 1) n[r][i] = j(s[r][i], new N(~s[(r + 1) % 5][i].I & s[(r + 2) % 5][i].I, ~s[(r + 1) % 5][i].X & s[(r + 2) % 5][i].X));
|
|
752
|
-
n[0][0] = j(n[0][0], nt[e]);
|
|
753
|
-
}
|
|
754
|
-
return n;
|
|
755
|
-
}
|
|
756
|
-
function ot(t) {
|
|
757
|
-
let n, e, r = 0;
|
|
758
|
-
const i = [0, 0], s = [4294967295 & t, t / o & 2097151];
|
|
759
|
-
for (n = 6; n >= 0; n--) e = s[n >> 2] >>> 8 * n & 255, 0 === e && 0 === r || (i[r + 1 >> 2] |= e << 8 * (r + 1), r += 1);
|
|
760
|
-
return r = 0 !== r ? r : 1, i[0] |= r, {
|
|
761
|
-
value: r + 1 > 4 ? i : [i[0]],
|
|
762
|
-
binLen: 8 + 8 * r
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
|
-
function ht(t) {
|
|
766
|
-
return a(ot(t.binLen), t);
|
|
767
|
-
}
|
|
768
|
-
function ut(t, n) {
|
|
769
|
-
let e, r = ot(n);
|
|
770
|
-
r = a(r, t);
|
|
771
|
-
const i = n >>> 2, s = (i - r.value.length % i) % i;
|
|
772
|
-
for (e = 0; e < s; e++) r.value.push(0);
|
|
773
|
-
return r.value;
|
|
774
|
-
}
|
|
775
|
-
var wt = class extends E {
|
|
776
|
-
constructor(t, n, e) {
|
|
777
|
-
let r = 6, s = 0;
|
|
778
|
-
super(t, n, e);
|
|
779
|
-
const o = e || {};
|
|
780
|
-
if (1 !== this.numRounds) {
|
|
781
|
-
if (o.kmacKey || o.hmacKey) throw new Error(f);
|
|
782
|
-
if ("CSHAKE128" === this.o || "CSHAKE256" === this.o) throw new Error("Cannot set numRounds for CSHAKE variants");
|
|
783
|
-
}
|
|
784
|
-
switch (this.T = 1, this.C = i(this.t, this.i, this.T), this.R = st, this.B = it, this.M = rt, this.U = rt(), this.v = !1, t) {
|
|
785
|
-
case "SHA3-224":
|
|
786
|
-
this.m = s = 1152, this.K = 224, this.k = !0, this.F = this.N;
|
|
787
|
-
break;
|
|
788
|
-
case "SHA3-256":
|
|
789
|
-
this.m = s = 1088, this.K = 256, this.k = !0, this.F = this.N;
|
|
790
|
-
break;
|
|
791
|
-
case "SHA3-384":
|
|
792
|
-
this.m = s = 832, this.K = 384, this.k = !0, this.F = this.N;
|
|
793
|
-
break;
|
|
794
|
-
case "SHA3-512":
|
|
795
|
-
this.m = s = 576, this.K = 512, this.k = !0, this.F = this.N;
|
|
796
|
-
break;
|
|
797
|
-
case "SHAKE128":
|
|
798
|
-
r = 31, this.m = s = 1344, this.K = -1, this.v = !0, this.k = !1, this.F = null;
|
|
799
|
-
break;
|
|
800
|
-
case "SHAKE256":
|
|
801
|
-
r = 31, this.m = s = 1088, this.K = -1, this.v = !0, this.k = !1, this.F = null;
|
|
802
|
-
break;
|
|
803
|
-
case "KMAC128":
|
|
804
|
-
r = 4, this.m = s = 1344, this._(e), this.K = -1, this.v = !0, this.k = !1, this.F = this.O;
|
|
805
|
-
break;
|
|
806
|
-
case "KMAC256":
|
|
807
|
-
r = 4, this.m = s = 1088, this._(e), this.K = -1, this.v = !0, this.k = !1, this.F = this.O;
|
|
808
|
-
break;
|
|
809
|
-
case "CSHAKE128":
|
|
810
|
-
this.m = s = 1344, r = this.P(e), this.K = -1, this.v = !0, this.k = !1, this.F = null;
|
|
811
|
-
break;
|
|
812
|
-
case "CSHAKE256":
|
|
813
|
-
this.m = s = 1088, r = this.P(e), this.K = -1, this.v = !0, this.k = !1, this.F = null;
|
|
814
|
-
break;
|
|
815
|
-
default: throw new Error(c);
|
|
816
|
-
}
|
|
817
|
-
this.L = function(t, n, e, i, o) {
|
|
818
|
-
return function(t, n, e, r, i, s, o) {
|
|
819
|
-
let h, u, w = 0;
|
|
820
|
-
const c = [], f = i >>> 5, a = n >>> 5;
|
|
821
|
-
for (h = 0; h < a && n >= i; h += f) r = st(t.slice(h, h + f), r), n -= i;
|
|
822
|
-
for (t = t.slice(h), n %= i; t.length < f;) t.push(0);
|
|
823
|
-
for (h = n >>> 3, t[h >> 2] ^= s << h % 4 * 8, t[f - 1] ^= 2147483648, r = st(t, r); 32 * c.length < o && (u = r[w % 5][w / 5 | 0], c.push(u.X), !(32 * c.length >= o));) c.push(u.I), w += 1, 0 == 64 * w % i && (st(null, r), w = 0);
|
|
824
|
-
return c;
|
|
825
|
-
}(t, n, 0, i, s, r, o);
|
|
826
|
-
}, o.hmacKey && this.Y(A("hmacKey", o.hmacKey, this.T));
|
|
827
|
-
}
|
|
828
|
-
P(t, n) {
|
|
829
|
-
const e = function(t) {
|
|
830
|
-
const n = t || {};
|
|
831
|
-
return {
|
|
832
|
-
funcName: A("funcName", n.funcName, 1, {
|
|
833
|
-
value: [],
|
|
834
|
-
binLen: 0
|
|
835
|
-
}),
|
|
836
|
-
customization: A("Customization", n.customization, 1, {
|
|
837
|
-
value: [],
|
|
838
|
-
binLen: 0
|
|
839
|
-
})
|
|
840
|
-
};
|
|
841
|
-
}(t || {});
|
|
842
|
-
n && (e.funcName = n);
|
|
843
|
-
const r = a(ht(e.funcName), ht(e.customization));
|
|
844
|
-
if (0 !== e.customization.binLen || 0 !== e.funcName.binLen) {
|
|
845
|
-
const t = ut(r, this.m >>> 3);
|
|
846
|
-
for (let n = 0; n < t.length; n += this.m >>> 5) this.U = this.R(t.slice(n, n + (this.m >>> 5)), this.U), this.A += this.m;
|
|
847
|
-
return 4;
|
|
848
|
-
}
|
|
849
|
-
return 31;
|
|
850
|
-
}
|
|
851
|
-
_(t) {
|
|
852
|
-
const n = function(t) {
|
|
853
|
-
const n = t || {};
|
|
854
|
-
return {
|
|
855
|
-
kmacKey: A("kmacKey", n.kmacKey, 1),
|
|
856
|
-
funcName: {
|
|
857
|
-
value: [1128353099],
|
|
858
|
-
binLen: 32
|
|
859
|
-
},
|
|
860
|
-
customization: A("Customization", n.customization, 1, {
|
|
861
|
-
value: [],
|
|
862
|
-
binLen: 0
|
|
863
|
-
})
|
|
864
|
-
};
|
|
865
|
-
}(t || {});
|
|
866
|
-
this.P(t, n.funcName);
|
|
867
|
-
const e = ut(ht(n.kmacKey), this.m >>> 3);
|
|
868
|
-
for (let t = 0; t < e.length; t += this.m >>> 5) this.U = this.R(e.slice(t, t + (this.m >>> 5)), this.U), this.A += this.m;
|
|
869
|
-
this.H = !0;
|
|
870
|
-
}
|
|
871
|
-
O(t) {
|
|
872
|
-
const n = a({
|
|
873
|
-
value: this.h.slice(),
|
|
874
|
-
binLen: this.u
|
|
875
|
-
}, function(t) {
|
|
876
|
-
let n, e, r = 0;
|
|
877
|
-
const i = [0, 0], s = [4294967295 & t, t / o & 2097151];
|
|
878
|
-
for (n = 6; n >= 0; n--) e = s[n >> 2] >>> 8 * n & 255, 0 === e && 0 === r || (i[r >> 2] |= e << 8 * r, r += 1);
|
|
879
|
-
return r = 0 !== r ? r : 1, i[r >> 2] |= r << 8 * r, {
|
|
880
|
-
value: r + 1 > 4 ? i : [i[0]],
|
|
881
|
-
binLen: 8 + 8 * r
|
|
882
|
-
};
|
|
883
|
-
}(t.outputLen));
|
|
884
|
-
return this.L(n.value, n.binLen, this.A, this.B(this.U), t.outputLen);
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
var ct = class {
|
|
888
|
-
constructor(t, n, e) {
|
|
889
|
-
if ("SHA-1" == t) this.V = new B(t, n, e);
|
|
890
|
-
else if ("SHA-224" == t || "SHA-256" == t) this.V = new Y(t, n, e);
|
|
891
|
-
else if ("SHA-384" == t || "SHA-512" == t) this.V = new tt(t, n, e);
|
|
892
|
-
else {
|
|
893
|
-
if ("SHA3-224" != t && "SHA3-256" != t && "SHA3-384" != t && "SHA3-512" != t && "SHAKE128" != t && "SHAKE256" != t && "CSHAKE128" != t && "CSHAKE256" != t && "KMAC128" != t && "KMAC256" != t) throw new Error(c);
|
|
894
|
-
this.V = new wt(t, n, e);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
update(t) {
|
|
898
|
-
return this.V.update(t), this;
|
|
899
|
-
}
|
|
900
|
-
getHash(t, n) {
|
|
901
|
-
return this.V.getHash(t, n);
|
|
902
|
-
}
|
|
903
|
-
setHMACKey(t, n, e) {
|
|
904
|
-
this.V.setHMACKey(t, n, e);
|
|
905
|
-
}
|
|
906
|
-
getHMAC(t, n) {
|
|
907
|
-
return this.V.getHMAC(t, n);
|
|
908
|
-
}
|
|
909
|
-
};
|
|
910
|
-
//#endregion
|
|
911
|
-
export { ct as default };
|