@protontech/openpgp 6.0.0-beta.3.patch.1 → 6.0.1
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 +34 -37
- package/dist/lightweight/argon2id.min.mjs +1 -1
- package/dist/lightweight/argon2id.min.mjs.map +1 -1
- package/dist/lightweight/argon2id.mjs +1 -1
- package/dist/lightweight/legacy_ciphers.min.mjs +1 -1
- package/dist/lightweight/legacy_ciphers.min.mjs.map +1 -1
- package/dist/lightweight/legacy_ciphers.mjs +1 -1
- package/dist/lightweight/noble_curves.min.mjs +11 -11
- package/dist/lightweight/noble_curves.min.mjs.map +1 -1
- package/dist/lightweight/noble_curves.mjs +260 -158
- package/dist/lightweight/noble_hashes.min.mjs +2 -2
- package/dist/lightweight/noble_hashes.min.mjs.map +1 -1
- package/dist/lightweight/noble_hashes.mjs +3 -2
- package/dist/lightweight/noble_post_quantum.min.mjs +5 -0
- package/dist/lightweight/noble_post_quantum.min.mjs.map +1 -0
- package/dist/lightweight/noble_post_quantum.mjs +1002 -0
- package/dist/lightweight/openpgp.min.mjs +4 -4
- package/dist/lightweight/openpgp.min.mjs.map +1 -1
- package/dist/lightweight/openpgp.mjs +863 -1056
- package/dist/lightweight/seek-bzip.min.mjs +3 -0
- package/dist/lightweight/seek-bzip.min.mjs.map +1 -0
- package/dist/lightweight/seek-bzip.mjs +866 -0
- package/dist/lightweight/sha3.min.mjs +3 -3
- package/dist/lightweight/sha3.min.mjs.map +1 -1
- package/dist/lightweight/sha3.mjs +27 -456
- package/dist/lightweight/sha512.min.mjs +3 -0
- package/dist/lightweight/sha512.min.mjs.map +1 -0
- package/dist/lightweight/sha512.mjs +436 -0
- package/dist/node/openpgp.cjs +14499 -12719
- package/dist/node/openpgp.min.cjs +16 -14
- package/dist/node/openpgp.min.cjs.map +1 -1
- package/dist/node/openpgp.min.mjs +16 -14
- package/dist/node/openpgp.min.mjs.map +1 -1
- package/dist/node/openpgp.mjs +11878 -10098
- package/dist/openpgp.js +11909 -10129
- package/dist/openpgp.min.js +16 -14
- package/dist/openpgp.min.js.map +1 -1
- package/dist/openpgp.min.mjs +16 -14
- package/dist/openpgp.min.mjs.map +1 -1
- package/dist/openpgp.mjs +11909 -10129
- package/openpgp.d.ts +3 -9
- package/package.json +27 -26
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
/*! OpenPGP.js v6.0.
|
|
1
|
+
/*! OpenPGP.js v6.0.1 - 2024-11-25 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
|
|
2
2
|
const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3
3
|
|
|
4
|
-
function
|
|
4
|
+
function anumber(n) {
|
|
5
5
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
6
|
-
throw new Error(
|
|
6
|
+
throw new Error('positive integer expected, got ' + n);
|
|
7
7
|
}
|
|
8
8
|
// copied from utils
|
|
9
9
|
function isBytes(a) {
|
|
10
|
-
return
|
|
11
|
-
(a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
|
|
10
|
+
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
|
|
12
11
|
}
|
|
13
|
-
function
|
|
12
|
+
function abytes(b, ...lengths) {
|
|
14
13
|
if (!isBytes(b))
|
|
15
14
|
throw new Error('Uint8Array expected');
|
|
16
15
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
17
|
-
throw new Error(
|
|
16
|
+
throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
|
|
18
17
|
}
|
|
19
|
-
function
|
|
18
|
+
function ahash(h) {
|
|
20
19
|
if (typeof h !== 'function' || typeof h.create !== 'function')
|
|
21
20
|
throw new Error('Hash should be wrapped by utils.wrapConstructor');
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
anumber(h.outputLen);
|
|
22
|
+
anumber(h.blockLen);
|
|
24
23
|
}
|
|
25
|
-
function
|
|
24
|
+
function aexists(instance, checkFinished = true) {
|
|
26
25
|
if (instance.destroyed)
|
|
27
26
|
throw new Error('Hash instance has been destroyed');
|
|
28
27
|
if (checkFinished && instance.finished)
|
|
29
28
|
throw new Error('Hash#digest() has already been called');
|
|
30
29
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
30
|
+
function aoutput(out, instance) {
|
|
31
|
+
abytes(out);
|
|
33
32
|
const min = instance.outputLen;
|
|
34
33
|
if (out.length < min) {
|
|
35
|
-
throw new Error(
|
|
34
|
+
throw new Error('digestInto() expects output buffer of length at least ' + min);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -52,7 +51,7 @@ const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLen
|
|
|
52
51
|
const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
|
|
53
52
|
// The rotate left (circular left shift) operation for uint32
|
|
54
53
|
const rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);
|
|
55
|
-
const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
|
|
54
|
+
const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
|
|
56
55
|
// The byte swap operation for uint32
|
|
57
56
|
const byteSwap = (word) => ((word << 24) & 0xff000000) |
|
|
58
57
|
((word << 8) & 0xff0000) |
|
|
@@ -69,7 +68,7 @@ function byteSwap32(arr) {
|
|
|
69
68
|
*/
|
|
70
69
|
function utf8ToBytes(str) {
|
|
71
70
|
if (typeof str !== 'string')
|
|
72
|
-
throw new Error(
|
|
71
|
+
throw new Error('utf8ToBytes expected string, got ' + typeof str);
|
|
73
72
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
74
73
|
}
|
|
75
74
|
/**
|
|
@@ -80,7 +79,7 @@ function utf8ToBytes(str) {
|
|
|
80
79
|
function toBytes(data) {
|
|
81
80
|
if (typeof data === 'string')
|
|
82
81
|
data = utf8ToBytes(data);
|
|
83
|
-
|
|
82
|
+
abytes(data);
|
|
84
83
|
return data;
|
|
85
84
|
}
|
|
86
85
|
/**
|
|
@@ -90,7 +89,7 @@ function concatBytes(...arrays) {
|
|
|
90
89
|
let sum = 0;
|
|
91
90
|
for (let i = 0; i < arrays.length; i++) {
|
|
92
91
|
const a = arrays[i];
|
|
93
|
-
|
|
92
|
+
abytes(a);
|
|
94
93
|
sum += a.length;
|
|
95
94
|
}
|
|
96
95
|
const res = new Uint8Array(sum);
|
|
@@ -138,259 +137,10 @@ function randomBytes(bytesLength = 32) {
|
|
|
138
137
|
throw new Error('crypto.getRandomValues must be defined');
|
|
139
138
|
}
|
|
140
139
|
|
|
141
|
-
/**
|
|
142
|
-
* Polyfill for Safari 14
|
|
143
|
-
*/
|
|
144
|
-
function setBigUint64(view, byteOffset, value, isLE) {
|
|
145
|
-
if (typeof view.setBigUint64 === 'function')
|
|
146
|
-
return view.setBigUint64(byteOffset, value, isLE);
|
|
147
|
-
const _32n = BigInt(32);
|
|
148
|
-
const _u32_max = BigInt(0xffffffff);
|
|
149
|
-
const wh = Number((value >> _32n) & _u32_max);
|
|
150
|
-
const wl = Number(value & _u32_max);
|
|
151
|
-
const h = isLE ? 4 : 0;
|
|
152
|
-
const l = isLE ? 0 : 4;
|
|
153
|
-
view.setUint32(byteOffset + h, wh, isLE);
|
|
154
|
-
view.setUint32(byteOffset + l, wl, isLE);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Choice: a ? b : c
|
|
158
|
-
*/
|
|
159
|
-
const Chi = (a, b, c) => (a & b) ^ (~a & c);
|
|
160
|
-
/**
|
|
161
|
-
* Majority function, true if any two inputs is true
|
|
162
|
-
*/
|
|
163
|
-
const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
|
|
164
|
-
/**
|
|
165
|
-
* Merkle-Damgard hash construction base class.
|
|
166
|
-
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
167
|
-
*/
|
|
168
|
-
class HashMD extends Hash {
|
|
169
|
-
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
170
|
-
super();
|
|
171
|
-
this.blockLen = blockLen;
|
|
172
|
-
this.outputLen = outputLen;
|
|
173
|
-
this.padOffset = padOffset;
|
|
174
|
-
this.isLE = isLE;
|
|
175
|
-
this.finished = false;
|
|
176
|
-
this.length = 0;
|
|
177
|
-
this.pos = 0;
|
|
178
|
-
this.destroyed = false;
|
|
179
|
-
this.buffer = new Uint8Array(blockLen);
|
|
180
|
-
this.view = createView(this.buffer);
|
|
181
|
-
}
|
|
182
|
-
update(data) {
|
|
183
|
-
exists(this);
|
|
184
|
-
const { view, buffer, blockLen } = this;
|
|
185
|
-
data = toBytes(data);
|
|
186
|
-
const len = data.length;
|
|
187
|
-
for (let pos = 0; pos < len;) {
|
|
188
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
189
|
-
// Fast path: we have at least one block in input, cast it to view and process
|
|
190
|
-
if (take === blockLen) {
|
|
191
|
-
const dataView = createView(data);
|
|
192
|
-
for (; blockLen <= len - pos; pos += blockLen)
|
|
193
|
-
this.process(dataView, pos);
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
197
|
-
this.pos += take;
|
|
198
|
-
pos += take;
|
|
199
|
-
if (this.pos === blockLen) {
|
|
200
|
-
this.process(view, 0);
|
|
201
|
-
this.pos = 0;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
this.length += data.length;
|
|
205
|
-
this.roundClean();
|
|
206
|
-
return this;
|
|
207
|
-
}
|
|
208
|
-
digestInto(out) {
|
|
209
|
-
exists(this);
|
|
210
|
-
output(out, this);
|
|
211
|
-
this.finished = true;
|
|
212
|
-
// Padding
|
|
213
|
-
// We can avoid allocation of buffer for padding completely if it
|
|
214
|
-
// was previously not allocated here. But it won't change performance.
|
|
215
|
-
const { buffer, view, blockLen, isLE } = this;
|
|
216
|
-
let { pos } = this;
|
|
217
|
-
// append the bit '1' to the message
|
|
218
|
-
buffer[pos++] = 0b10000000;
|
|
219
|
-
this.buffer.subarray(pos).fill(0);
|
|
220
|
-
// we have less than padOffset left in buffer, so we cannot put length in
|
|
221
|
-
// current block, need process it and pad again
|
|
222
|
-
if (this.padOffset > blockLen - pos) {
|
|
223
|
-
this.process(view, 0);
|
|
224
|
-
pos = 0;
|
|
225
|
-
}
|
|
226
|
-
// Pad until full block byte with zeros
|
|
227
|
-
for (let i = pos; i < blockLen; i++)
|
|
228
|
-
buffer[i] = 0;
|
|
229
|
-
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
230
|
-
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
231
|
-
// So we just write lowest 64 bits of that value.
|
|
232
|
-
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
233
|
-
this.process(view, 0);
|
|
234
|
-
const oview = createView(out);
|
|
235
|
-
const len = this.outputLen;
|
|
236
|
-
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
237
|
-
if (len % 4)
|
|
238
|
-
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
|
239
|
-
const outLen = len / 4;
|
|
240
|
-
const state = this.get();
|
|
241
|
-
if (outLen > state.length)
|
|
242
|
-
throw new Error('_sha2: outputLen bigger than state');
|
|
243
|
-
for (let i = 0; i < outLen; i++)
|
|
244
|
-
oview.setUint32(4 * i, state[i], isLE);
|
|
245
|
-
}
|
|
246
|
-
digest() {
|
|
247
|
-
const { buffer, outputLen } = this;
|
|
248
|
-
this.digestInto(buffer);
|
|
249
|
-
const res = buffer.slice(0, outputLen);
|
|
250
|
-
this.destroy();
|
|
251
|
-
return res;
|
|
252
|
-
}
|
|
253
|
-
_cloneInto(to) {
|
|
254
|
-
to || (to = new this.constructor());
|
|
255
|
-
to.set(...this.get());
|
|
256
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
257
|
-
to.length = length;
|
|
258
|
-
to.pos = pos;
|
|
259
|
-
to.finished = finished;
|
|
260
|
-
to.destroyed = destroyed;
|
|
261
|
-
if (length % blockLen)
|
|
262
|
-
to.buffer.set(buffer);
|
|
263
|
-
return to;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// SHA2-256 need to try 2^128 hashes to execute birthday attack.
|
|
268
|
-
// BTC network is doing 2^67 hashes/sec as per early 2023.
|
|
269
|
-
// Round constants:
|
|
270
|
-
// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
|
|
271
|
-
// prettier-ignore
|
|
272
|
-
const SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
273
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
274
|
-
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
275
|
-
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
276
|
-
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
277
|
-
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
278
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
279
|
-
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
280
|
-
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
281
|
-
]);
|
|
282
|
-
// Initial state:
|
|
283
|
-
// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
|
|
284
|
-
// prettier-ignore
|
|
285
|
-
const SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
|
286
|
-
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
287
|
-
]);
|
|
288
|
-
// Temporary buffer, not used to store anything between runs
|
|
289
|
-
// Named this way because it matches specification.
|
|
290
|
-
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
291
|
-
class SHA256 extends HashMD {
|
|
292
|
-
constructor() {
|
|
293
|
-
super(64, 32, 8, false);
|
|
294
|
-
// We cannot use array here since array allows indexing by variable
|
|
295
|
-
// which means optimizer/compiler cannot use registers.
|
|
296
|
-
this.A = SHA256_IV[0] | 0;
|
|
297
|
-
this.B = SHA256_IV[1] | 0;
|
|
298
|
-
this.C = SHA256_IV[2] | 0;
|
|
299
|
-
this.D = SHA256_IV[3] | 0;
|
|
300
|
-
this.E = SHA256_IV[4] | 0;
|
|
301
|
-
this.F = SHA256_IV[5] | 0;
|
|
302
|
-
this.G = SHA256_IV[6] | 0;
|
|
303
|
-
this.H = SHA256_IV[7] | 0;
|
|
304
|
-
}
|
|
305
|
-
get() {
|
|
306
|
-
const { A, B, C, D, E, F, G, H } = this;
|
|
307
|
-
return [A, B, C, D, E, F, G, H];
|
|
308
|
-
}
|
|
309
|
-
// prettier-ignore
|
|
310
|
-
set(A, B, C, D, E, F, G, H) {
|
|
311
|
-
this.A = A | 0;
|
|
312
|
-
this.B = B | 0;
|
|
313
|
-
this.C = C | 0;
|
|
314
|
-
this.D = D | 0;
|
|
315
|
-
this.E = E | 0;
|
|
316
|
-
this.F = F | 0;
|
|
317
|
-
this.G = G | 0;
|
|
318
|
-
this.H = H | 0;
|
|
319
|
-
}
|
|
320
|
-
process(view, offset) {
|
|
321
|
-
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
322
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
|
323
|
-
SHA256_W[i] = view.getUint32(offset, false);
|
|
324
|
-
for (let i = 16; i < 64; i++) {
|
|
325
|
-
const W15 = SHA256_W[i - 15];
|
|
326
|
-
const W2 = SHA256_W[i - 2];
|
|
327
|
-
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
|
|
328
|
-
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
|
|
329
|
-
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
330
|
-
}
|
|
331
|
-
// Compression function main loop, 64 rounds
|
|
332
|
-
let { A, B, C, D, E, F, G, H } = this;
|
|
333
|
-
for (let i = 0; i < 64; i++) {
|
|
334
|
-
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
335
|
-
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
336
|
-
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
337
|
-
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
338
|
-
H = G;
|
|
339
|
-
G = F;
|
|
340
|
-
F = E;
|
|
341
|
-
E = (D + T1) | 0;
|
|
342
|
-
D = C;
|
|
343
|
-
C = B;
|
|
344
|
-
B = A;
|
|
345
|
-
A = (T1 + T2) | 0;
|
|
346
|
-
}
|
|
347
|
-
// Add the compressed chunk to the current hash value
|
|
348
|
-
A = (A + this.A) | 0;
|
|
349
|
-
B = (B + this.B) | 0;
|
|
350
|
-
C = (C + this.C) | 0;
|
|
351
|
-
D = (D + this.D) | 0;
|
|
352
|
-
E = (E + this.E) | 0;
|
|
353
|
-
F = (F + this.F) | 0;
|
|
354
|
-
G = (G + this.G) | 0;
|
|
355
|
-
H = (H + this.H) | 0;
|
|
356
|
-
this.set(A, B, C, D, E, F, G, H);
|
|
357
|
-
}
|
|
358
|
-
roundClean() {
|
|
359
|
-
SHA256_W.fill(0);
|
|
360
|
-
}
|
|
361
|
-
destroy() {
|
|
362
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
363
|
-
this.buffer.fill(0);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf
|
|
367
|
-
class SHA224 extends SHA256 {
|
|
368
|
-
constructor() {
|
|
369
|
-
super();
|
|
370
|
-
this.A = 0xc1059ed8 | 0;
|
|
371
|
-
this.B = 0x367cd507 | 0;
|
|
372
|
-
this.C = 0x3070dd17 | 0;
|
|
373
|
-
this.D = 0xf70e5939 | 0;
|
|
374
|
-
this.E = 0xffc00b31 | 0;
|
|
375
|
-
this.F = 0x68581511 | 0;
|
|
376
|
-
this.G = 0x64f98fa7 | 0;
|
|
377
|
-
this.H = 0xbefa4fa4 | 0;
|
|
378
|
-
this.outputLen = 28;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* SHA2-256 hash function
|
|
383
|
-
* @param message - data that would be hashed
|
|
384
|
-
*/
|
|
385
|
-
const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
|
|
386
|
-
/**
|
|
387
|
-
* SHA2-224 hash function
|
|
388
|
-
*/
|
|
389
|
-
const sha224 = /* @__PURE__ */ wrapConstructor(() => new SHA224());
|
|
390
|
-
|
|
391
140
|
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
392
141
|
const _32n = /* @__PURE__ */ BigInt(32);
|
|
393
|
-
//
|
|
142
|
+
// BigUint64Array is too slow as per 2024, so we implement it using Uint32Array.
|
|
143
|
+
// TODO: re-check https://issues.chromium.org/issues/42212588
|
|
394
144
|
function fromBig(n, le = false) {
|
|
395
145
|
if (le)
|
|
396
146
|
return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
|
|
@@ -447,186 +197,6 @@ const u64 = {
|
|
|
447
197
|
add, add3L, add3H, add4L, add4H, add5H, add5L,
|
|
448
198
|
};
|
|
449
199
|
|
|
450
|
-
// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):
|
|
451
|
-
// prettier-ignore
|
|
452
|
-
const [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64.split([
|
|
453
|
-
'0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',
|
|
454
|
-
'0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',
|
|
455
|
-
'0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',
|
|
456
|
-
'0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',
|
|
457
|
-
'0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',
|
|
458
|
-
'0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',
|
|
459
|
-
'0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',
|
|
460
|
-
'0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',
|
|
461
|
-
'0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',
|
|
462
|
-
'0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',
|
|
463
|
-
'0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',
|
|
464
|
-
'0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',
|
|
465
|
-
'0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',
|
|
466
|
-
'0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',
|
|
467
|
-
'0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',
|
|
468
|
-
'0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',
|
|
469
|
-
'0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',
|
|
470
|
-
'0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',
|
|
471
|
-
'0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',
|
|
472
|
-
'0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'
|
|
473
|
-
].map(n => BigInt(n))))();
|
|
474
|
-
// Temporary buffer, not used to store anything between runs
|
|
475
|
-
const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
476
|
-
const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
477
|
-
class SHA512 extends HashMD {
|
|
478
|
-
constructor() {
|
|
479
|
-
super(128, 64, 16, false);
|
|
480
|
-
// We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.
|
|
481
|
-
// Also looks cleaner and easier to verify with spec.
|
|
482
|
-
// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
|
|
483
|
-
// h -- high 32 bits, l -- low 32 bits
|
|
484
|
-
this.Ah = 0x6a09e667 | 0;
|
|
485
|
-
this.Al = 0xf3bcc908 | 0;
|
|
486
|
-
this.Bh = 0xbb67ae85 | 0;
|
|
487
|
-
this.Bl = 0x84caa73b | 0;
|
|
488
|
-
this.Ch = 0x3c6ef372 | 0;
|
|
489
|
-
this.Cl = 0xfe94f82b | 0;
|
|
490
|
-
this.Dh = 0xa54ff53a | 0;
|
|
491
|
-
this.Dl = 0x5f1d36f1 | 0;
|
|
492
|
-
this.Eh = 0x510e527f | 0;
|
|
493
|
-
this.El = 0xade682d1 | 0;
|
|
494
|
-
this.Fh = 0x9b05688c | 0;
|
|
495
|
-
this.Fl = 0x2b3e6c1f | 0;
|
|
496
|
-
this.Gh = 0x1f83d9ab | 0;
|
|
497
|
-
this.Gl = 0xfb41bd6b | 0;
|
|
498
|
-
this.Hh = 0x5be0cd19 | 0;
|
|
499
|
-
this.Hl = 0x137e2179 | 0;
|
|
500
|
-
}
|
|
501
|
-
// prettier-ignore
|
|
502
|
-
get() {
|
|
503
|
-
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
504
|
-
return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
|
|
505
|
-
}
|
|
506
|
-
// prettier-ignore
|
|
507
|
-
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
508
|
-
this.Ah = Ah | 0;
|
|
509
|
-
this.Al = Al | 0;
|
|
510
|
-
this.Bh = Bh | 0;
|
|
511
|
-
this.Bl = Bl | 0;
|
|
512
|
-
this.Ch = Ch | 0;
|
|
513
|
-
this.Cl = Cl | 0;
|
|
514
|
-
this.Dh = Dh | 0;
|
|
515
|
-
this.Dl = Dl | 0;
|
|
516
|
-
this.Eh = Eh | 0;
|
|
517
|
-
this.El = El | 0;
|
|
518
|
-
this.Fh = Fh | 0;
|
|
519
|
-
this.Fl = Fl | 0;
|
|
520
|
-
this.Gh = Gh | 0;
|
|
521
|
-
this.Gl = Gl | 0;
|
|
522
|
-
this.Hh = Hh | 0;
|
|
523
|
-
this.Hl = Hl | 0;
|
|
524
|
-
}
|
|
525
|
-
process(view, offset) {
|
|
526
|
-
// Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array
|
|
527
|
-
for (let i = 0; i < 16; i++, offset += 4) {
|
|
528
|
-
SHA512_W_H[i] = view.getUint32(offset);
|
|
529
|
-
SHA512_W_L[i] = view.getUint32((offset += 4));
|
|
530
|
-
}
|
|
531
|
-
for (let i = 16; i < 80; i++) {
|
|
532
|
-
// s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)
|
|
533
|
-
const W15h = SHA512_W_H[i - 15] | 0;
|
|
534
|
-
const W15l = SHA512_W_L[i - 15] | 0;
|
|
535
|
-
const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);
|
|
536
|
-
const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);
|
|
537
|
-
// s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)
|
|
538
|
-
const W2h = SHA512_W_H[i - 2] | 0;
|
|
539
|
-
const W2l = SHA512_W_L[i - 2] | 0;
|
|
540
|
-
const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);
|
|
541
|
-
const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);
|
|
542
|
-
// SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];
|
|
543
|
-
const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
544
|
-
const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
|
|
545
|
-
SHA512_W_H[i] = SUMh | 0;
|
|
546
|
-
SHA512_W_L[i] = SUMl | 0;
|
|
547
|
-
}
|
|
548
|
-
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
549
|
-
// Compression function main loop, 80 rounds
|
|
550
|
-
for (let i = 0; i < 80; i++) {
|
|
551
|
-
// S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)
|
|
552
|
-
const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);
|
|
553
|
-
const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);
|
|
554
|
-
//const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
555
|
-
const CHIh = (Eh & Fh) ^ (~Eh & Gh);
|
|
556
|
-
const CHIl = (El & Fl) ^ (~El & Gl);
|
|
557
|
-
// T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]
|
|
558
|
-
// prettier-ignore
|
|
559
|
-
const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
560
|
-
const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
561
|
-
const T1l = T1ll | 0;
|
|
562
|
-
// S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)
|
|
563
|
-
const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);
|
|
564
|
-
const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);
|
|
565
|
-
const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);
|
|
566
|
-
const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);
|
|
567
|
-
Hh = Gh | 0;
|
|
568
|
-
Hl = Gl | 0;
|
|
569
|
-
Gh = Fh | 0;
|
|
570
|
-
Gl = Fl | 0;
|
|
571
|
-
Fh = Eh | 0;
|
|
572
|
-
Fl = El | 0;
|
|
573
|
-
({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
574
|
-
Dh = Ch | 0;
|
|
575
|
-
Dl = Cl | 0;
|
|
576
|
-
Ch = Bh | 0;
|
|
577
|
-
Cl = Bl | 0;
|
|
578
|
-
Bh = Ah | 0;
|
|
579
|
-
Bl = Al | 0;
|
|
580
|
-
const All = u64.add3L(T1l, sigma0l, MAJl);
|
|
581
|
-
Ah = u64.add3H(All, T1h, sigma0h, MAJh);
|
|
582
|
-
Al = All | 0;
|
|
583
|
-
}
|
|
584
|
-
// Add the compressed chunk to the current hash value
|
|
585
|
-
({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
586
|
-
({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
587
|
-
({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
588
|
-
({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
589
|
-
({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
590
|
-
({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
591
|
-
({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
592
|
-
({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
593
|
-
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
594
|
-
}
|
|
595
|
-
roundClean() {
|
|
596
|
-
SHA512_W_H.fill(0);
|
|
597
|
-
SHA512_W_L.fill(0);
|
|
598
|
-
}
|
|
599
|
-
destroy() {
|
|
600
|
-
this.buffer.fill(0);
|
|
601
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
class SHA384 extends SHA512 {
|
|
605
|
-
constructor() {
|
|
606
|
-
super();
|
|
607
|
-
// h -- high 32 bits, l -- low 32 bits
|
|
608
|
-
this.Ah = 0xcbbb9d5d | 0;
|
|
609
|
-
this.Al = 0xc1059ed8 | 0;
|
|
610
|
-
this.Bh = 0x629a292a | 0;
|
|
611
|
-
this.Bl = 0x367cd507 | 0;
|
|
612
|
-
this.Ch = 0x9159015a | 0;
|
|
613
|
-
this.Cl = 0x3070dd17 | 0;
|
|
614
|
-
this.Dh = 0x152fecd8 | 0;
|
|
615
|
-
this.Dl = 0xf70e5939 | 0;
|
|
616
|
-
this.Eh = 0x67332667 | 0;
|
|
617
|
-
this.El = 0xffc00b31 | 0;
|
|
618
|
-
this.Fh = 0x8eb44a87 | 0;
|
|
619
|
-
this.Fl = 0x68581511 | 0;
|
|
620
|
-
this.Gh = 0xdb0c2e0d | 0;
|
|
621
|
-
this.Gl = 0x64f98fa7 | 0;
|
|
622
|
-
this.Hh = 0x47b5481d | 0;
|
|
623
|
-
this.Hl = 0xbefa4fa4 | 0;
|
|
624
|
-
this.outputLen = 48;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());
|
|
628
|
-
const sha384 = /* @__PURE__ */ wrapConstructor(() => new SHA384());
|
|
629
|
-
|
|
630
200
|
// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.
|
|
631
201
|
// It's called a sponge function.
|
|
632
202
|
// Various per round constants calculations
|
|
@@ -718,7 +288,7 @@ class Keccak extends Hash {
|
|
|
718
288
|
this.finished = false;
|
|
719
289
|
this.destroyed = false;
|
|
720
290
|
// Can be passed from user as dkLen
|
|
721
|
-
|
|
291
|
+
anumber(outputLen);
|
|
722
292
|
// 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
|
|
723
293
|
if (0 >= this.blockLen || this.blockLen >= 200)
|
|
724
294
|
throw new Error('Sha3 supports only keccak-f1600 function');
|
|
@@ -735,7 +305,7 @@ class Keccak extends Hash {
|
|
|
735
305
|
this.pos = 0;
|
|
736
306
|
}
|
|
737
307
|
update(data) {
|
|
738
|
-
|
|
308
|
+
aexists(this);
|
|
739
309
|
const { blockLen, state } = this;
|
|
740
310
|
data = toBytes(data);
|
|
741
311
|
const len = data.length;
|
|
@@ -761,8 +331,8 @@ class Keccak extends Hash {
|
|
|
761
331
|
this.keccak();
|
|
762
332
|
}
|
|
763
333
|
writeInto(out) {
|
|
764
|
-
|
|
765
|
-
|
|
334
|
+
aexists(this, false);
|
|
335
|
+
abytes(out);
|
|
766
336
|
this.finish();
|
|
767
337
|
const bufferOut = this.state;
|
|
768
338
|
const { blockLen } = this;
|
|
@@ -783,11 +353,11 @@ class Keccak extends Hash {
|
|
|
783
353
|
return this.writeInto(out);
|
|
784
354
|
}
|
|
785
355
|
xof(bytes) {
|
|
786
|
-
|
|
356
|
+
anumber(bytes);
|
|
787
357
|
return this.xofInto(new Uint8Array(bytes));
|
|
788
358
|
}
|
|
789
359
|
digestInto(out) {
|
|
790
|
-
|
|
360
|
+
aoutput(out, this);
|
|
791
361
|
if (this.finished)
|
|
792
362
|
throw new Error('digest() was already called');
|
|
793
363
|
this.writeInto(out);
|
|
@@ -825,6 +395,7 @@ const gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(bl
|
|
|
825
395
|
const sha3_256 = /* @__PURE__ */ gen(0x06, 136, 256 / 8);
|
|
826
396
|
const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8);
|
|
827
397
|
const genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
|
|
398
|
+
const shake128 = /* @__PURE__ */ genShake(0x1f, 168, 128 / 8);
|
|
828
399
|
const shake256 = /* @__PURE__ */ genShake(0x1f, 136, 256 / 8);
|
|
829
400
|
|
|
830
|
-
export {
|
|
401
|
+
export { Hash as H, ahash as a, aexists as b, abytes as c, concatBytes as d, rotl as e, sha3_256 as f, sha3_512 as g, createView as h, aoutput as i, rotr as j, u64 as k, shake128 as l, u32 as m, randomBytes as r, shake256 as s, toBytes as t, utf8ToBytes as u, wrapConstructor as w };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! OpenPGP.js v6.0.1 - 2024-11-25 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
|
|
2
|
+
"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;import{H as t,h as s,b as h,t as e,i,w as c,j as a,k as r}from"./sha3.min.mjs";const f=(t,s,h)=>t&s^~t&h,d=(t,s,h)=>t&s^t&h^s&h;class o extends t{constructor(t,h,e,i){super(),this.blockLen=t,this.outputLen=h,this.padOffset=e,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=s(this.buffer)}update(t){h(this);const{view:i,buffer:c,blockLen:a}=this,r=(t=e(t)).length;for(let h=0;h<r;){const e=Math.min(a-this.pos,r-h);if(e!==a)c.set(t.subarray(h,h+e),this.pos),this.pos+=e,h+=e,this.pos===a&&(this.process(i,0),this.pos=0);else{const e=s(t);for(;a<=r-h;h+=a)this.process(e,h)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){h(this),i(t,this),this.finished=!0;const{buffer:e,view:c,blockLen:a,isLE:r}=this;let{pos:f}=this;e[f++]=128,this.buffer.subarray(f).fill(0),this.padOffset>a-f&&(this.process(c,0),f=0);for(let t=f;t<a;t++)e[t]=0;!function(t,s,h,e){if("function"==typeof t.setBigUint64)return t.setBigUint64(s,h,e);const i=BigInt(32),c=BigInt(4294967295),a=Number(h>>i&c),r=Number(h&c),f=e?4:0,d=e?0:4;t.setUint32(s+f,a,e),t.setUint32(s+d,r,e)}(c,a-8,BigInt(8*this.length),r),this.process(c,0);const d=s(t),o=this.outputLen;if(o%4)throw Error("_sha2: outputLen should be aligned to 32bit");const b=o/4,n=this.get();if(b>n.length)throw Error("_sha2: outputLen bigger than state");for(let t=0;t<b;t++)d.setUint32(4*t,n[t],r)}digest(){const{buffer:t,outputLen:s}=this;this.digestInto(t);const h=t.slice(0,s);return this.destroy(),h}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:s,buffer:h,length:e,finished:i,destroyed:c,pos:a}=this;return t.length=e,t.pos=a,t.finished=i,t.destroyed=c,e%s&&t.buffer.set(h),t}}const b=/* @__PURE__ */new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),n=/* @__PURE__ */new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),l=/* @__PURE__ */new Uint32Array(64);class x extends o{constructor(){super(64,32,8,!1),this.A=0|n[0],this.B=0|n[1],this.C=0|n[2],this.D=0|n[3],this.E=0|n[4],this.F=0|n[5],this.G=0|n[6],this.H=0|n[7]}get(){const{A:t,B:s,C:h,D:e,E:i,F:c,G:a,H:r}=this;return[t,s,h,e,i,c,a,r]}set(t,s,h,e,i,c,a,r){this.A=0|t,this.B=0|s,this.C=0|h,this.D=0|e,this.E=0|i,this.F=0|c,this.G=0|a,this.H=0|r}process(t,s){for(let h=0;h<16;h++,s+=4)l[h]=t.getUint32(s,!1);for(let t=16;t<64;t++){const s=l[t-15],h=l[t-2],e=a(s,7)^a(s,18)^s>>>3,i=a(h,17)^a(h,19)^h>>>10;l[t]=i+l[t-7]+e+l[t-16]|0}let{A:h,B:e,C:i,D:c,E:r,F:o,G:n,H:x}=this;for(let t=0;t<64;t++){const s=x+(a(r,6)^a(r,11)^a(r,25))+f(r,o,n)+b[t]+l[t]|0,u=(a(h,2)^a(h,13)^a(h,22))+d(h,e,i)|0;x=n,n=o,o=r,r=c+s|0,c=i,i=e,e=h,h=s+u|0}h=h+this.A|0,e=e+this.B|0,i=i+this.C|0,c=c+this.D|0,r=r+this.E|0,o=o+this.F|0,n=n+this.G|0,x=x+this.H|0,this.set(h,e,i,c,r,o,n,x)}roundClean(){l.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class u extends x{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const p=/* @__PURE__ */c((()=>new x)),H=/* @__PURE__ */c((()=>new u)),[B,g]=/* @__PURE__ */(()=>r.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((t=>BigInt(t)))))(),L=/* @__PURE__ */new Uint32Array(80),A=/* @__PURE__ */new Uint32Array(80);class C extends o{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:s,Bh:h,Bl:e,Ch:i,Cl:c,Dh:a,Dl:r,Eh:f,El:d,Fh:o,Fl:b,Gh:n,Gl:l,Hh:x,Hl:u}=this;return[t,s,h,e,i,c,a,r,f,d,o,b,n,l,x,u]}set(t,s,h,e,i,c,a,r,f,d,o,b,n,l,x,u){this.Ah=0|t,this.Al=0|s,this.Bh=0|h,this.Bl=0|e,this.Ch=0|i,this.Cl=0|c,this.Dh=0|a,this.Dl=0|r,this.Eh=0|f,this.El=0|d,this.Fh=0|o,this.Fl=0|b,this.Gh=0|n,this.Gl=0|l,this.Hh=0|x,this.Hl=0|u}process(t,s){for(let h=0;h<16;h++,s+=4)L[h]=t.getUint32(s),A[h]=t.getUint32(s+=4);for(let t=16;t<80;t++){const s=0|L[t-15],h=0|A[t-15],e=r.rotrSH(s,h,1)^r.rotrSH(s,h,8)^r.shrSH(s,h,7),i=r.rotrSL(s,h,1)^r.rotrSL(s,h,8)^r.shrSL(s,h,7),c=0|L[t-2],a=0|A[t-2],f=r.rotrSH(c,a,19)^r.rotrBH(c,a,61)^r.shrSH(c,a,6),d=r.rotrSL(c,a,19)^r.rotrBL(c,a,61)^r.shrSL(c,a,6),o=r.add4L(i,d,A[t-7],A[t-16]),b=r.add4H(o,e,f,L[t-7],L[t-16]);L[t]=0|b,A[t]=0|o}let{Ah:h,Al:e,Bh:i,Bl:c,Ch:a,Cl:f,Dh:d,Dl:o,Eh:b,El:n,Fh:l,Fl:x,Gh:u,Gl:p,Hh:H,Hl:C}=this;for(let t=0;t<80;t++){const s=r.rotrSH(b,n,14)^r.rotrSH(b,n,18)^r.rotrBH(b,n,41),E=r.rotrSL(b,n,14)^r.rotrSL(b,n,18)^r.rotrBL(b,n,41),w=b&l^~b&u,y=n&x^~n&p,D=r.add5L(C,E,y,g[t],A[t]),F=r.add5H(D,H,s,w,B[t],L[t]),G=0|D,S=r.rotrSH(h,e,28)^r.rotrBH(h,e,34)^r.rotrBH(h,e,39),U=r.rotrSL(h,e,28)^r.rotrBL(h,e,34)^r.rotrBL(h,e,39),m=h&i^h&a^i&a,I=e&c^e&f^c&f;H=0|u,C=0|p,u=0|l,p=0|x,l=0|b,x=0|n,({h:b,l:n}=r.add(0|d,0|o,0|F,0|G)),d=0|a,o=0|f,a=0|i,f=0|c,i=0|h,c=0|e;const k=r.add3L(G,U,I);h=r.add3H(k,F,S,m),e=0|k}({h,l:e}=r.add(0|this.Ah,0|this.Al,0|h,0|e)),({h:i,l:c}=r.add(0|this.Bh,0|this.Bl,0|i,0|c)),({h:a,l:f}=r.add(0|this.Ch,0|this.Cl,0|a,0|f)),({h:d,l:o}=r.add(0|this.Dh,0|this.Dl,0|d,0|o)),({h:b,l:n}=r.add(0|this.Eh,0|this.El,0|b,0|n)),({h:l,l:x}=r.add(0|this.Fh,0|this.Fl,0|l,0|x)),({h:u,l:p}=r.add(0|this.Gh,0|this.Gl,0|u,0|p)),({h:H,l:C}=r.add(0|this.Hh,0|this.Hl,0|H,0|C)),this.set(h,e,i,c,a,f,d,o,b,n,l,x,u,p,H,C)}roundClean(){L.fill(0),A.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class E extends C{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const w=/* @__PURE__ */c((()=>new C)),y=/* @__PURE__ */c((()=>new E));export{f as C,o as H,d as M,y as a,w as b,H as c,p as s};
|
|
3
|
+
//# sourceMappingURL=sha512.min.mjs.map
|