ooxml-core 1.0.0 → 1.1.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/dist/{PptxHandler-G63S6YZU.mjs → PptxHandler-75LOVF7I.mjs} +2 -2
- package/dist/automation/index.cjs +2559 -1169
- package/dist/automation/index.mjs +2559 -1169
- package/dist/chart/gradient-definition.d.ts +2 -2
- package/dist/chart/gradient-definition.d.ts.map +1 -1
- package/dist/chart/index.cjs +7 -7
- package/dist/chart/index.mjs +7 -7
- package/dist/{chunk-BICQYRPW.mjs → chunk-75LA7H3F.mjs} +1339 -1435
- package/dist/{chunk-CKJSWE7N.mjs → chunk-LA7D6ZYQ.mjs} +244 -115
- package/dist/{chunk-ROM5MZ7O.mjs → chunk-OMGH6IKY.mjs} +3 -3
- package/dist/{chunk-RWXFQJVF.mjs → chunk-Q27H4HFS.mjs} +1 -1
- package/dist/{chunk-DDG5HTGX.mjs → chunk-RFX7AJDZ.mjs} +1 -1
- package/dist/crypto/index.cjs +1406 -184
- package/dist/crypto/index.mjs +1406 -184
- package/dist/diagram/dom.d.ts +1 -14
- package/dist/diagram/dom.d.ts.map +1 -1
- package/dist/diagram/index.cjs +15 -15
- package/dist/diagram/index.d.ts +12 -12
- package/dist/diagram/index.d.ts.map +1 -1
- package/dist/diagram/index.mjs +15 -15
- package/dist/diagram/types.d.ts +12 -148
- package/dist/diagram/types.d.ts.map +1 -1
- package/dist/digest/algorithm-names.d.ts +2 -2
- package/dist/digest/algorithm-names.d.ts.map +1 -1
- package/dist/digest/bit-ops.d.ts +30 -0
- package/dist/digest/bit-ops.d.ts.map +1 -0
- package/dist/digest/digest.d.ts +2 -2
- package/dist/digest/digest.d.ts.map +1 -1
- package/dist/digest/index.cjs +1319 -90
- package/dist/digest/index.d.ts +7 -1
- package/dist/digest/index.d.ts.map +1 -1
- package/dist/digest/index.mjs +1313 -91
- package/dist/digest/md2.d.ts +22 -0
- package/dist/digest/md2.d.ts.map +1 -0
- package/dist/digest/md4.d.ts +3 -0
- package/dist/digest/md4.d.ts.map +1 -0
- package/dist/digest/md5.d.ts +3 -0
- package/dist/digest/md5.d.ts.map +1 -0
- package/dist/digest/password-hash.d.ts +7 -0
- package/dist/digest/password-hash.d.ts.map +1 -1
- package/dist/digest/ripemd-functions.d.ts +18 -0
- package/dist/digest/ripemd-functions.d.ts.map +1 -0
- package/dist/digest/ripemd128.d.ts +3 -0
- package/dist/digest/ripemd128.d.ts.map +1 -0
- package/dist/digest/ripemd160.d.ts +3 -0
- package/dist/digest/ripemd160.d.ts.map +1 -0
- package/dist/digest/whirlpool-sbox.d.ts +15 -0
- package/dist/digest/whirlpool-sbox.d.ts.map +1 -0
- package/dist/digest/whirlpool-table.d.ts +12 -0
- package/dist/digest/whirlpool-table.d.ts.map +1 -0
- package/dist/digest/whirlpool.d.ts +3 -0
- package/dist/digest/whirlpool.d.ts.map +1 -0
- package/dist/docx/block-parser.d.ts.map +1 -1
- package/dist/docx/diagram-theme.d.ts +3 -3
- package/dist/docx/diagram-theme.d.ts.map +1 -1
- package/dist/docx/embedded.cjs +470 -276
- package/dist/docx/embedded.mjs +470 -276
- package/dist/docx/field-flags.d.ts +8 -0
- package/dist/docx/field-flags.d.ts.map +1 -0
- package/dist/docx/field-lock.d.ts +6 -0
- package/dist/docx/field-lock.d.ts.map +1 -0
- package/dist/docx/field-runs.d.ts +4 -1
- package/dist/docx/field-runs.d.ts.map +1 -1
- package/dist/docx/index.cjs +1029 -850
- package/dist/docx/index.d.ts +2 -0
- package/dist/docx/index.d.ts.map +1 -1
- package/dist/docx/index.mjs +1027 -850
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/index.cjs +61 -47
- package/dist/docx/layout/index.mjs +61 -47
- package/dist/docx/layout/page-fields.d.ts.map +1 -1
- package/dist/docx/load/index.cjs +1883 -467
- package/dist/docx/load/index.mjs +1883 -467
- package/dist/docx/model-run.d.ts +5 -0
- package/dist/docx/model-run.d.ts.map +1 -1
- package/dist/docx/numbering-model.d.ts +1 -1
- package/dist/docx/numbering-model.d.ts.map +1 -1
- package/dist/docx/numbering-package.d.ts +4 -4
- package/dist/docx/numbering-package.d.ts.map +1 -1
- package/dist/docx/numbering-start-edit.d.ts +8 -0
- package/dist/docx/numbering-start-edit.d.ts.map +1 -0
- package/dist/docx/numbering-start-patch.d.ts +13 -0
- package/dist/docx/numbering-start-patch.d.ts.map +1 -0
- package/dist/docx/theme-color.d.ts.map +1 -1
- package/dist/docx/theme-model.d.ts +3 -2
- package/dist/docx/theme-model.d.ts.map +1 -1
- package/dist/docx/theme.d.ts +5 -1
- package/dist/docx/theme.d.ts.map +1 -1
- package/dist/docx/ui/field-guard.d.ts +2 -0
- package/dist/docx/ui/field-guard.d.ts.map +1 -1
- package/dist/docx/ui/field-results.d.ts.map +1 -1
- package/dist/docx/ui/index.cjs +547 -375
- package/dist/docx/ui/index.mjs +547 -376
- package/dist/docx/ui/review-commands.d.ts.map +1 -1
- package/dist/docx/ui/run-extra-mark.d.ts +1 -1
- package/dist/docx/ui/run-extra-mark.d.ts.map +1 -1
- package/dist/docx/ui/simple-field-input.d.ts +3 -0
- package/dist/docx/ui/simple-field-input.d.ts.map +1 -1
- package/dist/docx/ui/track-changes-mode.d.ts.map +1 -1
- package/dist/docx/ui/track-paragraph-boundaries.d.ts +5 -0
- package/dist/docx/ui/track-paragraph-boundaries.d.ts.map +1 -0
- package/dist/docx/write-inline.d.ts.map +1 -1
- package/dist/docx/write-run.d.ts.map +1 -1
- package/dist/drawingml/dom.d.ts +15 -0
- package/dist/drawingml/dom.d.ts.map +1 -0
- package/dist/drawingml/drawing-color-brightness.d.ts +6 -0
- package/dist/drawingml/drawing-color-brightness.d.ts.map +1 -0
- package/dist/drawingml/drawing-color-css.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-color.d.ts +5 -5
- package/dist/drawingml/drawing-color.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-fill.d.ts +3 -3
- package/dist/drawingml/drawing-fill.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-geometry.d.ts +4 -4
- package/dist/drawingml/drawing-geometry.d.ts.map +1 -0
- package/dist/drawingml/drawing-shadow.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/drawing-text.d.ts +2 -2
- package/dist/drawingml/drawing-text.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/gradient-geometry.d.ts +2 -2
- package/dist/drawingml/gradient-geometry.d.ts.map +1 -0
- package/dist/drawingml/gradient-preset-data.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/gradient-presets.d.ts +3 -3
- package/dist/drawingml/gradient-presets.d.ts.map +1 -0
- package/dist/drawingml/index.cjs +1545 -0
- package/dist/drawingml/index.d.ts +19 -0
- package/dist/drawingml/index.d.ts.map +1 -0
- package/dist/drawingml/index.mjs +1497 -0
- package/dist/{diagram → drawingml}/ordered-color-transforms.d.ts +2 -2
- package/dist/drawingml/ordered-color-transforms.d.ts.map +1 -0
- package/dist/drawingml/rect-path-gradient.d.ts.map +1 -0
- package/dist/drawingml/theme-color.d.ts +19 -0
- package/dist/drawingml/theme-color.d.ts.map +1 -0
- package/dist/drawingml/theme-model.d.ts +40 -0
- package/dist/drawingml/theme-model.d.ts.map +1 -0
- package/dist/drawingml/theme.d.ts +21 -0
- package/dist/drawingml/theme.d.ts.map +1 -0
- package/dist/drawingml/types.d.ts +152 -0
- package/dist/drawingml/types.d.ts.map +1 -0
- package/dist/drawingml/write-color.d.ts +4 -0
- package/dist/drawingml/write-color.d.ts.map +1 -0
- package/dist/{diagram → drawingml}/write-fill.d.ts +2 -2
- package/dist/drawingml/write-fill.d.ts.map +1 -0
- package/dist/geometry/connector-elbow-geometry.d.ts +14 -0
- package/dist/geometry/connector-elbow-geometry.d.ts.map +1 -1
- package/dist/geometry/index.cjs +43 -0
- package/dist/geometry/index.mjs +42 -1
- package/dist/i18n/dictionary.d.ts +13 -0
- package/dist/i18n/dictionary.d.ts.map +1 -0
- package/dist/i18n/index.cjs +68 -0
- package/dist/i18n/index.d.ts +4 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.mjs +60 -0
- package/dist/i18n/locale.d.ts +17 -0
- package/dist/i18n/locale.d.ts.map +1 -0
- package/dist/i18n/translator.d.ts +18 -0
- package/dist/i18n/translator.d.ts.map +1 -0
- package/dist/index.cjs +3712 -2178
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +3711 -2179
- package/dist/pptx/automation/index.cjs +2852 -1568
- package/dist/pptx/automation/index.d.ts +3 -3
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{index-C4mfzVoY.d.ts → index-BHqL5KXH.d.ts} +2 -2
- package/dist/pptx/chunks/{index-C4mfzVoY.d.ts.map → index-BHqL5KXH.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-lk7dyOPS.d.ts → index-BYkdcS8J.d.ts} +12 -16
- package/dist/pptx/chunks/index-BYkdcS8J.d.ts.map +1 -0
- package/dist/pptx/chunks/smart-art-CO2jmJFf.d.ts.map +1 -1
- package/dist/pptx/chunks/{text-operations-CDLx4hD5.d.ts → text-operations-DEJ7alZR.d.ts} +2 -2
- package/dist/pptx/chunks/text-operations-DEJ7alZR.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +2680 -1396
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/index.cjs +1771 -1756
- package/dist/pptx/index.d.ts +3 -3
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/index.cjs +144 -74
- package/dist/teams/index.mjs +144 -74
- package/dist/visio/ui/index.cjs +14 -3
- package/dist/visio/ui/index.mjs +14 -3
- package/dist/visio/ui/shape-rotation.d.ts +1 -1
- package/dist/visio/ui/shape-rotation.d.ts.map +1 -1
- package/dist/xlsx/edit/chart-series-gradient.d.ts +1 -1
- package/dist/xlsx/edit/chart-series-gradient.d.ts.map +1 -1
- package/dist/xlsx/edit/protection.d.ts +1 -1
- package/dist/xlsx/index.cjs +3222 -1886
- package/dist/xlsx/index.mjs +3222 -1886
- package/dist/xlsx/layout/chart-appearance.d.ts +1 -1
- package/dist/xlsx/layout/chart-appearance.d.ts.map +1 -1
- package/dist/xlsx/layout/chart-scale.d.ts +5 -1
- package/dist/xlsx/layout/chart-scale.d.ts.map +1 -1
- package/dist/xlsx/layout/chart-svg-legend.d.ts +13 -0
- package/dist/xlsx/layout/chart-svg-legend.d.ts.map +1 -0
- package/dist/xlsx/layout/chart-svg.d.ts.map +1 -1
- package/dist/xlsx/layout/chart-view.d.ts +3 -1
- package/dist/xlsx/layout/chart-view.d.ts.map +1 -1
- package/dist/xlsx/load/index.cjs +2110 -838
- package/dist/xlsx/load/index.mjs +2110 -838
- package/dist/xlsx/read/theme.d.ts +2 -4
- package/dist/xlsx/read/theme.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +2017 -771
- package/dist/xlsx/ui/index.mjs +2017 -771
- package/dist/xlsx/ui/locales/merge.d.ts +2 -1
- package/dist/xlsx/ui/locales/merge.d.ts.map +1 -1
- package/dist/xlsx/ui/localization.d.ts.map +1 -1
- package/dist/xlsx/write/theme.d.ts.map +1 -1
- package/package.json +11 -1
- package/dist/diagram/drawing-color-brightness.d.ts +0 -6
- package/dist/diagram/drawing-color-brightness.d.ts.map +0 -1
- package/dist/diagram/drawing-color-css.d.ts.map +0 -1
- package/dist/diagram/drawing-color.d.ts.map +0 -1
- package/dist/diagram/drawing-fill.d.ts.map +0 -1
- package/dist/diagram/drawing-geometry.d.ts.map +0 -1
- package/dist/diagram/drawing-shadow.d.ts.map +0 -1
- package/dist/diagram/drawing-text.d.ts.map +0 -1
- package/dist/diagram/gradient-geometry.d.ts.map +0 -1
- package/dist/diagram/gradient-preset-data.d.ts.map +0 -1
- package/dist/diagram/gradient-presets.d.ts.map +0 -1
- package/dist/diagram/ordered-color-transforms.d.ts.map +0 -1
- package/dist/diagram/rect-path-gradient.d.ts.map +0 -1
- package/dist/diagram/write-color.d.ts +0 -4
- package/dist/diagram/write-color.d.ts.map +0 -1
- package/dist/diagram/write-fill.d.ts.map +0 -1
- package/dist/pptx/chunks/index-lk7dyOPS.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-CDLx4hD5.d.ts.map +0 -1
- /package/dist/{diagram → drawingml}/drawing-color-css.d.ts +0 -0
- /package/dist/{diagram → drawingml}/drawing-shadow.d.ts +0 -0
- /package/dist/{diagram → drawingml}/gradient-preset-data.d.ts +0 -0
- /package/dist/{diagram → drawingml}/rect-path-gradient.d.ts +0 -0
package/dist/crypto/index.mjs
CHANGED
|
@@ -23,8 +23,8 @@ function parseOle2(buffer) {
|
|
|
23
23
|
if (data.length < 512) {
|
|
24
24
|
throw new Ole2ParseError("Truncated OLE2 compound file header");
|
|
25
25
|
}
|
|
26
|
-
for (let
|
|
27
|
-
if (data[
|
|
26
|
+
for (let i2 = 0; i2 < OLE_MAGIC.length; i2++) {
|
|
27
|
+
if (data[i2] !== OLE_MAGIC[i2]) {
|
|
28
28
|
throw new Ole2ParseError("Not a valid OLE2 compound file");
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -66,8 +66,8 @@ function parseOle2(buffer) {
|
|
|
66
66
|
return data.subarray(offset, offset + sectorSize);
|
|
67
67
|
}
|
|
68
68
|
const fatSectors = [];
|
|
69
|
-
for (let
|
|
70
|
-
const sector = view.getUint32(76 +
|
|
69
|
+
for (let i2 = 0; i2 < 109 && fatSectors.length < totalFATSectors; i2++) {
|
|
70
|
+
const sector = view.getUint32(76 + i2 * 4, true);
|
|
71
71
|
if (sector <= MAXREGSECT) {
|
|
72
72
|
fatSectors.push(sector);
|
|
73
73
|
}
|
|
@@ -81,8 +81,8 @@ function parseOle2(buffer) {
|
|
|
81
81
|
const difatData = readSector(difatSector);
|
|
82
82
|
const difatView = new DataView(difatData.buffer, difatData.byteOffset, difatData.byteLength);
|
|
83
83
|
const entriesPerSector = (sectorSize - 4) / 4;
|
|
84
|
-
for (let
|
|
85
|
-
const sector = difatView.getUint32(
|
|
84
|
+
for (let i2 = 0; i2 < entriesPerSector && fatSectors.length < totalFATSectors; i2++) {
|
|
85
|
+
const sector = difatView.getUint32(i2 * 4, true);
|
|
86
86
|
if (sector <= MAXREGSECT) {
|
|
87
87
|
fatSectors.push(sector);
|
|
88
88
|
}
|
|
@@ -96,8 +96,8 @@ function parseOle2(buffer) {
|
|
|
96
96
|
for (const fatSector of fatSectors) {
|
|
97
97
|
const fatData = readSector(fatSector);
|
|
98
98
|
const fatView = new DataView(fatData.buffer, fatData.byteOffset, fatData.byteLength);
|
|
99
|
-
for (let
|
|
100
|
-
fatEntries.push(fatView.getUint32(
|
|
99
|
+
for (let i2 = 0; i2 < sectorSize / 4 && fatEntries.length < sectorCount; i2++) {
|
|
100
|
+
fatEntries.push(fatView.getUint32(i2 * 4, true));
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
function readSectorChain(startSector) {
|
|
@@ -138,8 +138,8 @@ function parseOle2(buffer) {
|
|
|
138
138
|
const dirRaw = readSectorChain(firstDirectorySector);
|
|
139
139
|
const numEntries = Math.floor(dirRaw.length / DIR_ENTRY_SIZE);
|
|
140
140
|
const entries = [];
|
|
141
|
-
for (let
|
|
142
|
-
const entryOffset =
|
|
141
|
+
for (let i2 = 0; i2 < numEntries; i2++) {
|
|
142
|
+
const entryOffset = i2 * DIR_ENTRY_SIZE;
|
|
143
143
|
const entryView = new DataView(dirRaw.buffer, dirRaw.byteOffset + entryOffset, DIR_ENTRY_SIZE);
|
|
144
144
|
const nameLen = entryView.getUint16(64, true);
|
|
145
145
|
const objectType = entryView.getUint8(66);
|
|
@@ -195,8 +195,8 @@ function parseOle2(buffer) {
|
|
|
195
195
|
}
|
|
196
196
|
const miniFatView = new DataView(miniFatRaw.buffer, miniFatRaw.byteOffset, miniFatRaw.byteLength);
|
|
197
197
|
const miniCapacity = Math.floor((miniStreamData?.length ?? 0) / miniSectorSize);
|
|
198
|
-
for (let
|
|
199
|
-
miniFatEntries.push(miniFatView.getUint32(
|
|
198
|
+
for (let i2 = 0; i2 < miniFatRaw.length / 4 && i2 < miniCapacity; i2++) {
|
|
199
|
+
miniFatEntries.push(miniFatView.getUint32(i2 * 4, true));
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
function readMiniStream(startSector, size) {
|
|
@@ -251,7 +251,7 @@ function randomBytes(length) {
|
|
|
251
251
|
const cryptoObj = globalThis.crypto;
|
|
252
252
|
if (cryptoObj?.getRandomValues) return cryptoObj.getRandomValues(new Uint8Array(length));
|
|
253
253
|
const bytes = new Uint8Array(length);
|
|
254
|
-
for (let
|
|
254
|
+
for (let i2 = 0; i2 < length; i2++) bytes[i2] = Math.floor(Math.random() * 256);
|
|
255
255
|
return bytes;
|
|
256
256
|
}
|
|
257
257
|
function randomHex(length) {
|
|
@@ -278,10 +278,10 @@ function getCrypto() {
|
|
|
278
278
|
}
|
|
279
279
|
function encodePasswordUtf16LE(password) {
|
|
280
280
|
const buf = new Uint8Array(password.length * 2);
|
|
281
|
-
for (let
|
|
282
|
-
const code = password.charCodeAt(
|
|
283
|
-
buf[
|
|
284
|
-
buf[
|
|
281
|
+
for (let i2 = 0; i2 < password.length; i2++) {
|
|
282
|
+
const code = password.charCodeAt(i2);
|
|
283
|
+
buf[i2 * 2] = code & 255;
|
|
284
|
+
buf[i2 * 2 + 1] = code >> 8 & 255;
|
|
285
285
|
}
|
|
286
286
|
return buf;
|
|
287
287
|
}
|
|
@@ -307,15 +307,15 @@ function uint32LE(value) {
|
|
|
307
307
|
function base64Decode(str) {
|
|
308
308
|
const binary = atob(str);
|
|
309
309
|
const bytes = new Uint8Array(binary.length);
|
|
310
|
-
for (let
|
|
311
|
-
bytes[
|
|
310
|
+
for (let i2 = 0; i2 < binary.length; i2++) {
|
|
311
|
+
bytes[i2] = binary.charCodeAt(i2);
|
|
312
312
|
}
|
|
313
313
|
return bytes;
|
|
314
314
|
}
|
|
315
315
|
function base64Encode(bytes) {
|
|
316
316
|
let binary = "";
|
|
317
|
-
for (let
|
|
318
|
-
binary += String.fromCharCode(bytes[
|
|
317
|
+
for (let i2 = 0; i2 < bytes.length; i2++) {
|
|
318
|
+
binary += String.fromCharCode(bytes[i2]);
|
|
319
319
|
}
|
|
320
320
|
return btoa(binary);
|
|
321
321
|
}
|
|
@@ -462,6 +462,846 @@ function normalizeDigestAlgorithmName(name) {
|
|
|
462
462
|
return Object.hasOwn(CANONICAL_BY_LOOKUP_KEY, key) ? CANONICAL_BY_LOOKUP_KEY[key] : void 0;
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
+
// digest/md2.ts
|
|
466
|
+
var S = [
|
|
467
|
+
41,
|
|
468
|
+
46,
|
|
469
|
+
67,
|
|
470
|
+
201,
|
|
471
|
+
162,
|
|
472
|
+
216,
|
|
473
|
+
124,
|
|
474
|
+
1,
|
|
475
|
+
61,
|
|
476
|
+
54,
|
|
477
|
+
84,
|
|
478
|
+
161,
|
|
479
|
+
236,
|
|
480
|
+
240,
|
|
481
|
+
6,
|
|
482
|
+
19,
|
|
483
|
+
98,
|
|
484
|
+
167,
|
|
485
|
+
5,
|
|
486
|
+
243,
|
|
487
|
+
192,
|
|
488
|
+
199,
|
|
489
|
+
115,
|
|
490
|
+
140,
|
|
491
|
+
152,
|
|
492
|
+
147,
|
|
493
|
+
43,
|
|
494
|
+
217,
|
|
495
|
+
188,
|
|
496
|
+
76,
|
|
497
|
+
130,
|
|
498
|
+
202,
|
|
499
|
+
30,
|
|
500
|
+
155,
|
|
501
|
+
87,
|
|
502
|
+
60,
|
|
503
|
+
253,
|
|
504
|
+
212,
|
|
505
|
+
224,
|
|
506
|
+
22,
|
|
507
|
+
103,
|
|
508
|
+
66,
|
|
509
|
+
111,
|
|
510
|
+
24,
|
|
511
|
+
138,
|
|
512
|
+
23,
|
|
513
|
+
229,
|
|
514
|
+
18,
|
|
515
|
+
190,
|
|
516
|
+
78,
|
|
517
|
+
196,
|
|
518
|
+
214,
|
|
519
|
+
218,
|
|
520
|
+
158,
|
|
521
|
+
222,
|
|
522
|
+
73,
|
|
523
|
+
160,
|
|
524
|
+
251,
|
|
525
|
+
245,
|
|
526
|
+
142,
|
|
527
|
+
187,
|
|
528
|
+
47,
|
|
529
|
+
238,
|
|
530
|
+
122,
|
|
531
|
+
169,
|
|
532
|
+
104,
|
|
533
|
+
121,
|
|
534
|
+
145,
|
|
535
|
+
21,
|
|
536
|
+
178,
|
|
537
|
+
7,
|
|
538
|
+
63,
|
|
539
|
+
148,
|
|
540
|
+
194,
|
|
541
|
+
16,
|
|
542
|
+
137,
|
|
543
|
+
11,
|
|
544
|
+
34,
|
|
545
|
+
95,
|
|
546
|
+
33,
|
|
547
|
+
128,
|
|
548
|
+
127,
|
|
549
|
+
93,
|
|
550
|
+
154,
|
|
551
|
+
90,
|
|
552
|
+
144,
|
|
553
|
+
50,
|
|
554
|
+
39,
|
|
555
|
+
53,
|
|
556
|
+
62,
|
|
557
|
+
204,
|
|
558
|
+
231,
|
|
559
|
+
191,
|
|
560
|
+
247,
|
|
561
|
+
151,
|
|
562
|
+
3,
|
|
563
|
+
255,
|
|
564
|
+
25,
|
|
565
|
+
48,
|
|
566
|
+
179,
|
|
567
|
+
72,
|
|
568
|
+
165,
|
|
569
|
+
181,
|
|
570
|
+
209,
|
|
571
|
+
215,
|
|
572
|
+
94,
|
|
573
|
+
146,
|
|
574
|
+
42,
|
|
575
|
+
172,
|
|
576
|
+
86,
|
|
577
|
+
170,
|
|
578
|
+
198,
|
|
579
|
+
79,
|
|
580
|
+
184,
|
|
581
|
+
56,
|
|
582
|
+
210,
|
|
583
|
+
150,
|
|
584
|
+
164,
|
|
585
|
+
125,
|
|
586
|
+
182,
|
|
587
|
+
118,
|
|
588
|
+
252,
|
|
589
|
+
107,
|
|
590
|
+
226,
|
|
591
|
+
156,
|
|
592
|
+
116,
|
|
593
|
+
4,
|
|
594
|
+
241,
|
|
595
|
+
69,
|
|
596
|
+
157,
|
|
597
|
+
112,
|
|
598
|
+
89,
|
|
599
|
+
100,
|
|
600
|
+
113,
|
|
601
|
+
135,
|
|
602
|
+
32,
|
|
603
|
+
134,
|
|
604
|
+
91,
|
|
605
|
+
207,
|
|
606
|
+
101,
|
|
607
|
+
230,
|
|
608
|
+
45,
|
|
609
|
+
168,
|
|
610
|
+
2,
|
|
611
|
+
27,
|
|
612
|
+
96,
|
|
613
|
+
37,
|
|
614
|
+
173,
|
|
615
|
+
174,
|
|
616
|
+
176,
|
|
617
|
+
185,
|
|
618
|
+
246,
|
|
619
|
+
28,
|
|
620
|
+
70,
|
|
621
|
+
97,
|
|
622
|
+
105,
|
|
623
|
+
52,
|
|
624
|
+
64,
|
|
625
|
+
126,
|
|
626
|
+
15,
|
|
627
|
+
85,
|
|
628
|
+
71,
|
|
629
|
+
163,
|
|
630
|
+
35,
|
|
631
|
+
221,
|
|
632
|
+
81,
|
|
633
|
+
175,
|
|
634
|
+
58,
|
|
635
|
+
195,
|
|
636
|
+
92,
|
|
637
|
+
249,
|
|
638
|
+
206,
|
|
639
|
+
186,
|
|
640
|
+
197,
|
|
641
|
+
234,
|
|
642
|
+
38,
|
|
643
|
+
44,
|
|
644
|
+
83,
|
|
645
|
+
13,
|
|
646
|
+
110,
|
|
647
|
+
133,
|
|
648
|
+
40,
|
|
649
|
+
132,
|
|
650
|
+
9,
|
|
651
|
+
211,
|
|
652
|
+
223,
|
|
653
|
+
205,
|
|
654
|
+
244,
|
|
655
|
+
65,
|
|
656
|
+
129,
|
|
657
|
+
77,
|
|
658
|
+
82,
|
|
659
|
+
106,
|
|
660
|
+
220,
|
|
661
|
+
55,
|
|
662
|
+
200,
|
|
663
|
+
108,
|
|
664
|
+
193,
|
|
665
|
+
171,
|
|
666
|
+
250,
|
|
667
|
+
36,
|
|
668
|
+
225,
|
|
669
|
+
123,
|
|
670
|
+
8,
|
|
671
|
+
12,
|
|
672
|
+
189,
|
|
673
|
+
177,
|
|
674
|
+
74,
|
|
675
|
+
120,
|
|
676
|
+
136,
|
|
677
|
+
149,
|
|
678
|
+
139,
|
|
679
|
+
227,
|
|
680
|
+
99,
|
|
681
|
+
232,
|
|
682
|
+
109,
|
|
683
|
+
233,
|
|
684
|
+
203,
|
|
685
|
+
213,
|
|
686
|
+
254,
|
|
687
|
+
59,
|
|
688
|
+
0,
|
|
689
|
+
29,
|
|
690
|
+
57,
|
|
691
|
+
242,
|
|
692
|
+
239,
|
|
693
|
+
183,
|
|
694
|
+
14,
|
|
695
|
+
102,
|
|
696
|
+
88,
|
|
697
|
+
208,
|
|
698
|
+
228,
|
|
699
|
+
166,
|
|
700
|
+
119,
|
|
701
|
+
114,
|
|
702
|
+
248,
|
|
703
|
+
235,
|
|
704
|
+
117,
|
|
705
|
+
75,
|
|
706
|
+
10,
|
|
707
|
+
49,
|
|
708
|
+
68,
|
|
709
|
+
80,
|
|
710
|
+
180,
|
|
711
|
+
143,
|
|
712
|
+
237,
|
|
713
|
+
31,
|
|
714
|
+
26,
|
|
715
|
+
219,
|
|
716
|
+
153,
|
|
717
|
+
141,
|
|
718
|
+
51,
|
|
719
|
+
159,
|
|
720
|
+
17,
|
|
721
|
+
131,
|
|
722
|
+
20
|
|
723
|
+
];
|
|
724
|
+
function transform(state, checksum, block) {
|
|
725
|
+
const x = new Uint8Array(48);
|
|
726
|
+
x.set(state, 0);
|
|
727
|
+
x.set(block, 16);
|
|
728
|
+
for (let k = 0; k < 16; k++) {
|
|
729
|
+
x[32 + k] = state[k] ^ block[k];
|
|
730
|
+
}
|
|
731
|
+
let t = 0;
|
|
732
|
+
for (let round2 = 0; round2 < 18; round2++) {
|
|
733
|
+
for (let k = 0; k < 48; k++) {
|
|
734
|
+
x[k] = x[k] ^ S[t];
|
|
735
|
+
t = x[k];
|
|
736
|
+
}
|
|
737
|
+
t = t + round2 & 255;
|
|
738
|
+
}
|
|
739
|
+
state.set(x.subarray(0, 16));
|
|
740
|
+
t = checksum[15];
|
|
741
|
+
for (let k = 0; k < 16; k++) {
|
|
742
|
+
checksum[k] = checksum[k] ^ S[block[k] ^ t];
|
|
743
|
+
t = checksum[k];
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
function md2(message) {
|
|
747
|
+
const padLength = 16 - message.length % 16;
|
|
748
|
+
const padded = new Uint8Array(message.length + padLength);
|
|
749
|
+
padded.set(message);
|
|
750
|
+
padded.fill(padLength, message.length);
|
|
751
|
+
const state = new Uint8Array(16);
|
|
752
|
+
const checksum = new Uint8Array(16);
|
|
753
|
+
for (let offset = 0; offset < padded.length; offset += 16) {
|
|
754
|
+
transform(state, checksum, padded.subarray(offset, offset + 16));
|
|
755
|
+
}
|
|
756
|
+
transform(state, checksum, checksum.slice());
|
|
757
|
+
return state;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
// digest/bit-ops.ts
|
|
761
|
+
function rotl32(x, n) {
|
|
762
|
+
return (x << n | x >>> 32 - n) >>> 0;
|
|
763
|
+
}
|
|
764
|
+
function add32(...values) {
|
|
765
|
+
let sum = 0;
|
|
766
|
+
for (const value of values) sum = sum + value >>> 0;
|
|
767
|
+
return sum;
|
|
768
|
+
}
|
|
769
|
+
function padMd4Style(message) {
|
|
770
|
+
const paddedLength = message.length + 9 + 63 & -64;
|
|
771
|
+
const padded = new Uint8Array(paddedLength);
|
|
772
|
+
padded.set(message);
|
|
773
|
+
padded[message.length] = 128;
|
|
774
|
+
new DataView(padded.buffer).setBigUint64(paddedLength - 8, BigInt(message.length) * 8n, true);
|
|
775
|
+
return padded;
|
|
776
|
+
}
|
|
777
|
+
function applyRotatingRound(r, ops, f6, x, feedback = false) {
|
|
778
|
+
let target = 0;
|
|
779
|
+
for (const [k, s, addConst] of ops) {
|
|
780
|
+
const i1 = target + 1 & 3;
|
|
781
|
+
const next = r[i1];
|
|
782
|
+
const rotated = rotl32(
|
|
783
|
+
add32(r[target], f6(next, r[target + 2 & 3], r[target + 3 & 3]), x[k], addConst),
|
|
784
|
+
s
|
|
785
|
+
);
|
|
786
|
+
r[target] = feedback ? add32(next, rotated) : rotated;
|
|
787
|
+
target = target + 3 & 3;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function mdStyleDigest(message, initialState, transform6) {
|
|
791
|
+
const padded = padMd4Style(message);
|
|
792
|
+
const view = new DataView(padded.buffer);
|
|
793
|
+
const state = [...initialState];
|
|
794
|
+
const words2 = new Array(16).fill(0);
|
|
795
|
+
for (let offset = 0; offset < padded.length; offset += 64) {
|
|
796
|
+
for (let i2 = 0; i2 < 16; i2++) words2[i2] = view.getUint32(offset + i2 * 4, true);
|
|
797
|
+
transform6(state, words2);
|
|
798
|
+
}
|
|
799
|
+
const out = new Uint8Array(state.length * 4);
|
|
800
|
+
const outView = new DataView(out.buffer);
|
|
801
|
+
for (let i2 = 0; i2 < state.length; i2++) outView.setUint32(i2 * 4, state[i2], true);
|
|
802
|
+
return out;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// digest/md4.ts
|
|
806
|
+
var INITIAL_STATE = [1732584193, 4023233417, 2562383102, 271733878];
|
|
807
|
+
var K2 = 1518500249;
|
|
808
|
+
var K3 = 1859775393;
|
|
809
|
+
var f1 = (x, y, z) => x & y | ~x & z;
|
|
810
|
+
var f2 = (x, y, z) => x & y | x & z | y & z;
|
|
811
|
+
var f3 = (x, y, z) => x ^ y ^ z;
|
|
812
|
+
function round(order, shifts, k) {
|
|
813
|
+
return order.map((word, i2) => [word, shifts[i2 % 4], k]);
|
|
814
|
+
}
|
|
815
|
+
var SEQUENTIAL = Array.from({ length: 16 }, (_, i2) => i2);
|
|
816
|
+
var COLUMNS = Array.from({ length: 16 }, (_, i2) => i2 % 4 * 4 + (i2 >> 2));
|
|
817
|
+
var BIT_REVERSED = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15];
|
|
818
|
+
var ROUND1 = round(SEQUENTIAL, [3, 7, 11, 19], 0);
|
|
819
|
+
var ROUND2 = round(COLUMNS, [3, 5, 9, 13], K2);
|
|
820
|
+
var ROUND3 = round(BIT_REVERSED, [3, 9, 11, 15], K3);
|
|
821
|
+
function transform2(state, x) {
|
|
822
|
+
const r = [...state];
|
|
823
|
+
applyRotatingRound(r, ROUND1, f1, x);
|
|
824
|
+
applyRotatingRound(r, ROUND2, f2, x);
|
|
825
|
+
applyRotatingRound(r, ROUND3, f3, x);
|
|
826
|
+
for (let i2 = 0; i2 < 4; i2++) state[i2] = add32(state[i2], r[i2]);
|
|
827
|
+
}
|
|
828
|
+
function md4(message) {
|
|
829
|
+
return mdStyleDigest(message, INITIAL_STATE, transform2);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// digest/md5.ts
|
|
833
|
+
var INITIAL_STATE2 = [1732584193, 4023233417, 2562383102, 271733878];
|
|
834
|
+
function f(x, y, z) {
|
|
835
|
+
return x & y | ~x & z;
|
|
836
|
+
}
|
|
837
|
+
function g(x, y, z) {
|
|
838
|
+
return x & z | y & ~z;
|
|
839
|
+
}
|
|
840
|
+
function h(x, y, z) {
|
|
841
|
+
return x ^ y ^ z;
|
|
842
|
+
}
|
|
843
|
+
function i(x, y, z) {
|
|
844
|
+
return y ^ (x | ~z);
|
|
845
|
+
}
|
|
846
|
+
var T = Array.from(
|
|
847
|
+
{ length: 64 },
|
|
848
|
+
(_, index) => Math.floor(Math.abs(Math.sin(index + 1)) * 2 ** 32)
|
|
849
|
+
);
|
|
850
|
+
var SHIFTS = [
|
|
851
|
+
[7, 12, 17, 22],
|
|
852
|
+
[5, 9, 14, 20],
|
|
853
|
+
[4, 11, 16, 23],
|
|
854
|
+
[6, 10, 15, 21]
|
|
855
|
+
];
|
|
856
|
+
var WORD_INDEX = [
|
|
857
|
+
(idx) => idx,
|
|
858
|
+
(idx) => (5 * idx + 1) % 16,
|
|
859
|
+
(idx) => (3 * idx + 5) % 16,
|
|
860
|
+
(idx) => 7 * idx % 16
|
|
861
|
+
];
|
|
862
|
+
var ROUND_FNS = [f, g, h, i];
|
|
863
|
+
function buildOps(round2) {
|
|
864
|
+
const shifts = SHIFTS[round2];
|
|
865
|
+
const wordIndex = WORD_INDEX[round2];
|
|
866
|
+
return Array.from({ length: 16 }, (_, idx) => {
|
|
867
|
+
const opNumber = round2 * 16 + idx;
|
|
868
|
+
return [wordIndex(idx), shifts[idx % 4], T[opNumber]];
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
var ROUNDS = [0, 1, 2, 3].map(buildOps);
|
|
872
|
+
function transform3(state, x) {
|
|
873
|
+
const r = [...state];
|
|
874
|
+
for (let round2 = 0; round2 < 4; round2++) {
|
|
875
|
+
applyRotatingRound(r, ROUNDS[round2], ROUND_FNS[round2], x, true);
|
|
876
|
+
}
|
|
877
|
+
for (let idx = 0; idx < 4; idx++) {
|
|
878
|
+
state[idx] = add32(state[idx], r[idx]);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
function md5(message) {
|
|
882
|
+
return mdStyleDigest(message, INITIAL_STATE2, transform3);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
// digest/ripemd-functions.ts
|
|
886
|
+
function f12(x, y, z) {
|
|
887
|
+
return x ^ y ^ z;
|
|
888
|
+
}
|
|
889
|
+
function f22(x, y, z) {
|
|
890
|
+
return x & y | ~x & z;
|
|
891
|
+
}
|
|
892
|
+
function f32(x, y, z) {
|
|
893
|
+
return (x | ~y) ^ z;
|
|
894
|
+
}
|
|
895
|
+
function f4(x, y, z) {
|
|
896
|
+
return z & x | ~z & y;
|
|
897
|
+
}
|
|
898
|
+
function f5(x, y, z) {
|
|
899
|
+
return x ^ (y | ~z);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
// digest/ripemd128.ts
|
|
903
|
+
var INITIAL_STATE3 = [1732584193, 4023233417, 2562383102, 271733878];
|
|
904
|
+
var LEFT_ROUNDS = [
|
|
905
|
+
[
|
|
906
|
+
[0, 11, 0],
|
|
907
|
+
[1, 14, 0],
|
|
908
|
+
[2, 15, 0],
|
|
909
|
+
[3, 12, 0],
|
|
910
|
+
[4, 5, 0],
|
|
911
|
+
[5, 8, 0],
|
|
912
|
+
[6, 7, 0],
|
|
913
|
+
[7, 9, 0],
|
|
914
|
+
[8, 11, 0],
|
|
915
|
+
[9, 13, 0],
|
|
916
|
+
[10, 14, 0],
|
|
917
|
+
[11, 15, 0],
|
|
918
|
+
[12, 6, 0],
|
|
919
|
+
[13, 7, 0],
|
|
920
|
+
[14, 9, 0],
|
|
921
|
+
[15, 8, 0]
|
|
922
|
+
],
|
|
923
|
+
[
|
|
924
|
+
[7, 7, 1518500249],
|
|
925
|
+
[4, 6, 1518500249],
|
|
926
|
+
[13, 8, 1518500249],
|
|
927
|
+
[1, 13, 1518500249],
|
|
928
|
+
[10, 11, 1518500249],
|
|
929
|
+
[6, 9, 1518500249],
|
|
930
|
+
[15, 7, 1518500249],
|
|
931
|
+
[3, 15, 1518500249],
|
|
932
|
+
[12, 7, 1518500249],
|
|
933
|
+
[0, 12, 1518500249],
|
|
934
|
+
[9, 15, 1518500249],
|
|
935
|
+
[5, 9, 1518500249],
|
|
936
|
+
[2, 11, 1518500249],
|
|
937
|
+
[14, 7, 1518500249],
|
|
938
|
+
[11, 13, 1518500249],
|
|
939
|
+
[8, 12, 1518500249]
|
|
940
|
+
],
|
|
941
|
+
[
|
|
942
|
+
[3, 11, 1859775393],
|
|
943
|
+
[10, 13, 1859775393],
|
|
944
|
+
[14, 6, 1859775393],
|
|
945
|
+
[4, 7, 1859775393],
|
|
946
|
+
[9, 14, 1859775393],
|
|
947
|
+
[15, 9, 1859775393],
|
|
948
|
+
[8, 13, 1859775393],
|
|
949
|
+
[1, 15, 1859775393],
|
|
950
|
+
[2, 14, 1859775393],
|
|
951
|
+
[7, 8, 1859775393],
|
|
952
|
+
[0, 13, 1859775393],
|
|
953
|
+
[6, 6, 1859775393],
|
|
954
|
+
[13, 5, 1859775393],
|
|
955
|
+
[11, 12, 1859775393],
|
|
956
|
+
[5, 7, 1859775393],
|
|
957
|
+
[12, 5, 1859775393]
|
|
958
|
+
],
|
|
959
|
+
[
|
|
960
|
+
[1, 11, 2400959708],
|
|
961
|
+
[9, 12, 2400959708],
|
|
962
|
+
[11, 14, 2400959708],
|
|
963
|
+
[10, 15, 2400959708],
|
|
964
|
+
[0, 14, 2400959708],
|
|
965
|
+
[8, 15, 2400959708],
|
|
966
|
+
[12, 9, 2400959708],
|
|
967
|
+
[4, 8, 2400959708],
|
|
968
|
+
[13, 9, 2400959708],
|
|
969
|
+
[3, 14, 2400959708],
|
|
970
|
+
[7, 5, 2400959708],
|
|
971
|
+
[15, 6, 2400959708],
|
|
972
|
+
[14, 8, 2400959708],
|
|
973
|
+
[5, 6, 2400959708],
|
|
974
|
+
[6, 5, 2400959708],
|
|
975
|
+
[2, 12, 2400959708]
|
|
976
|
+
]
|
|
977
|
+
];
|
|
978
|
+
var RIGHT_ROUNDS = [
|
|
979
|
+
[
|
|
980
|
+
[5, 8, 1352829926],
|
|
981
|
+
[14, 9, 1352829926],
|
|
982
|
+
[7, 9, 1352829926],
|
|
983
|
+
[0, 11, 1352829926],
|
|
984
|
+
[9, 13, 1352829926],
|
|
985
|
+
[2, 15, 1352829926],
|
|
986
|
+
[11, 15, 1352829926],
|
|
987
|
+
[4, 5, 1352829926],
|
|
988
|
+
[13, 7, 1352829926],
|
|
989
|
+
[6, 7, 1352829926],
|
|
990
|
+
[15, 8, 1352829926],
|
|
991
|
+
[8, 11, 1352829926],
|
|
992
|
+
[1, 14, 1352829926],
|
|
993
|
+
[10, 14, 1352829926],
|
|
994
|
+
[3, 12, 1352829926],
|
|
995
|
+
[12, 6, 1352829926]
|
|
996
|
+
],
|
|
997
|
+
[
|
|
998
|
+
[6, 9, 1548603684],
|
|
999
|
+
[11, 13, 1548603684],
|
|
1000
|
+
[3, 15, 1548603684],
|
|
1001
|
+
[7, 7, 1548603684],
|
|
1002
|
+
[0, 12, 1548603684],
|
|
1003
|
+
[13, 8, 1548603684],
|
|
1004
|
+
[5, 9, 1548603684],
|
|
1005
|
+
[10, 11, 1548603684],
|
|
1006
|
+
[14, 7, 1548603684],
|
|
1007
|
+
[15, 7, 1548603684],
|
|
1008
|
+
[8, 12, 1548603684],
|
|
1009
|
+
[12, 7, 1548603684],
|
|
1010
|
+
[4, 6, 1548603684],
|
|
1011
|
+
[9, 15, 1548603684],
|
|
1012
|
+
[1, 13, 1548603684],
|
|
1013
|
+
[2, 11, 1548603684]
|
|
1014
|
+
],
|
|
1015
|
+
[
|
|
1016
|
+
[15, 9, 1836072691],
|
|
1017
|
+
[5, 7, 1836072691],
|
|
1018
|
+
[1, 15, 1836072691],
|
|
1019
|
+
[3, 11, 1836072691],
|
|
1020
|
+
[7, 8, 1836072691],
|
|
1021
|
+
[14, 6, 1836072691],
|
|
1022
|
+
[6, 6, 1836072691],
|
|
1023
|
+
[9, 14, 1836072691],
|
|
1024
|
+
[11, 12, 1836072691],
|
|
1025
|
+
[8, 13, 1836072691],
|
|
1026
|
+
[12, 5, 1836072691],
|
|
1027
|
+
[2, 14, 1836072691],
|
|
1028
|
+
[10, 13, 1836072691],
|
|
1029
|
+
[0, 13, 1836072691],
|
|
1030
|
+
[4, 7, 1836072691],
|
|
1031
|
+
[13, 5, 1836072691]
|
|
1032
|
+
],
|
|
1033
|
+
[
|
|
1034
|
+
[8, 15, 0],
|
|
1035
|
+
[6, 5, 0],
|
|
1036
|
+
[4, 8, 0],
|
|
1037
|
+
[1, 11, 0],
|
|
1038
|
+
[3, 14, 0],
|
|
1039
|
+
[11, 14, 0],
|
|
1040
|
+
[15, 6, 0],
|
|
1041
|
+
[0, 14, 0],
|
|
1042
|
+
[5, 6, 0],
|
|
1043
|
+
[12, 9, 0],
|
|
1044
|
+
[2, 12, 0],
|
|
1045
|
+
[13, 9, 0],
|
|
1046
|
+
[9, 12, 0],
|
|
1047
|
+
[7, 5, 0],
|
|
1048
|
+
[10, 15, 0],
|
|
1049
|
+
[14, 8, 0]
|
|
1050
|
+
]
|
|
1051
|
+
];
|
|
1052
|
+
var LEFT_FNS = [f12, f22, f32, f4];
|
|
1053
|
+
var RIGHT_FNS = [f4, f32, f22, f12];
|
|
1054
|
+
function transform4(state, x) {
|
|
1055
|
+
const left = [...state];
|
|
1056
|
+
const right = [...state];
|
|
1057
|
+
for (let round2 = 0; round2 < 4; round2++) {
|
|
1058
|
+
applyRotatingRound(left, LEFT_ROUNDS[round2], LEFT_FNS[round2], x);
|
|
1059
|
+
applyRotatingRound(right, RIGHT_ROUNDS[round2], RIGHT_FNS[round2], x);
|
|
1060
|
+
}
|
|
1061
|
+
const orig = state;
|
|
1062
|
+
const newState = [
|
|
1063
|
+
add32(right[3], left[2], orig[1]),
|
|
1064
|
+
add32(orig[2], left[3], right[0]),
|
|
1065
|
+
add32(orig[3], left[0], right[1]),
|
|
1066
|
+
add32(orig[0], left[1], right[2])
|
|
1067
|
+
];
|
|
1068
|
+
for (let i2 = 0; i2 < 4; i2++) {
|
|
1069
|
+
state[i2] = newState[i2];
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
function ripemd128(message) {
|
|
1073
|
+
return mdStyleDigest(message, INITIAL_STATE3, transform4);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
// digest/ripemd160.ts
|
|
1077
|
+
var INITIAL_STATE4 = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
|
|
1078
|
+
var LEFT_ROUNDS2 = [
|
|
1079
|
+
[
|
|
1080
|
+
[0, 11, 0],
|
|
1081
|
+
[1, 14, 0],
|
|
1082
|
+
[2, 15, 0],
|
|
1083
|
+
[3, 12, 0],
|
|
1084
|
+
[4, 5, 0],
|
|
1085
|
+
[5, 8, 0],
|
|
1086
|
+
[6, 7, 0],
|
|
1087
|
+
[7, 9, 0],
|
|
1088
|
+
[8, 11, 0],
|
|
1089
|
+
[9, 13, 0],
|
|
1090
|
+
[10, 14, 0],
|
|
1091
|
+
[11, 15, 0],
|
|
1092
|
+
[12, 6, 0],
|
|
1093
|
+
[13, 7, 0],
|
|
1094
|
+
[14, 9, 0],
|
|
1095
|
+
[15, 8, 0]
|
|
1096
|
+
],
|
|
1097
|
+
[
|
|
1098
|
+
[7, 7, 1518500249],
|
|
1099
|
+
[4, 6, 1518500249],
|
|
1100
|
+
[13, 8, 1518500249],
|
|
1101
|
+
[1, 13, 1518500249],
|
|
1102
|
+
[10, 11, 1518500249],
|
|
1103
|
+
[6, 9, 1518500249],
|
|
1104
|
+
[15, 7, 1518500249],
|
|
1105
|
+
[3, 15, 1518500249],
|
|
1106
|
+
[12, 7, 1518500249],
|
|
1107
|
+
[0, 12, 1518500249],
|
|
1108
|
+
[9, 15, 1518500249],
|
|
1109
|
+
[5, 9, 1518500249],
|
|
1110
|
+
[2, 11, 1518500249],
|
|
1111
|
+
[14, 7, 1518500249],
|
|
1112
|
+
[11, 13, 1518500249],
|
|
1113
|
+
[8, 12, 1518500249]
|
|
1114
|
+
],
|
|
1115
|
+
[
|
|
1116
|
+
[3, 11, 1859775393],
|
|
1117
|
+
[10, 13, 1859775393],
|
|
1118
|
+
[14, 6, 1859775393],
|
|
1119
|
+
[4, 7, 1859775393],
|
|
1120
|
+
[9, 14, 1859775393],
|
|
1121
|
+
[15, 9, 1859775393],
|
|
1122
|
+
[8, 13, 1859775393],
|
|
1123
|
+
[1, 15, 1859775393],
|
|
1124
|
+
[2, 14, 1859775393],
|
|
1125
|
+
[7, 8, 1859775393],
|
|
1126
|
+
[0, 13, 1859775393],
|
|
1127
|
+
[6, 6, 1859775393],
|
|
1128
|
+
[13, 5, 1859775393],
|
|
1129
|
+
[11, 12, 1859775393],
|
|
1130
|
+
[5, 7, 1859775393],
|
|
1131
|
+
[12, 5, 1859775393]
|
|
1132
|
+
],
|
|
1133
|
+
[
|
|
1134
|
+
[1, 11, 2400959708],
|
|
1135
|
+
[9, 12, 2400959708],
|
|
1136
|
+
[11, 14, 2400959708],
|
|
1137
|
+
[10, 15, 2400959708],
|
|
1138
|
+
[0, 14, 2400959708],
|
|
1139
|
+
[8, 15, 2400959708],
|
|
1140
|
+
[12, 9, 2400959708],
|
|
1141
|
+
[4, 8, 2400959708],
|
|
1142
|
+
[13, 9, 2400959708],
|
|
1143
|
+
[3, 14, 2400959708],
|
|
1144
|
+
[7, 5, 2400959708],
|
|
1145
|
+
[15, 6, 2400959708],
|
|
1146
|
+
[14, 8, 2400959708],
|
|
1147
|
+
[5, 6, 2400959708],
|
|
1148
|
+
[6, 5, 2400959708],
|
|
1149
|
+
[2, 12, 2400959708]
|
|
1150
|
+
],
|
|
1151
|
+
[
|
|
1152
|
+
[4, 9, 2840853838],
|
|
1153
|
+
[0, 15, 2840853838],
|
|
1154
|
+
[5, 5, 2840853838],
|
|
1155
|
+
[9, 11, 2840853838],
|
|
1156
|
+
[7, 6, 2840853838],
|
|
1157
|
+
[12, 8, 2840853838],
|
|
1158
|
+
[2, 13, 2840853838],
|
|
1159
|
+
[10, 12, 2840853838],
|
|
1160
|
+
[14, 5, 2840853838],
|
|
1161
|
+
[1, 12, 2840853838],
|
|
1162
|
+
[3, 13, 2840853838],
|
|
1163
|
+
[8, 14, 2840853838],
|
|
1164
|
+
[11, 11, 2840853838],
|
|
1165
|
+
[6, 8, 2840853838],
|
|
1166
|
+
[15, 5, 2840853838],
|
|
1167
|
+
[13, 6, 2840853838]
|
|
1168
|
+
]
|
|
1169
|
+
];
|
|
1170
|
+
var RIGHT_ROUNDS2 = [
|
|
1171
|
+
[
|
|
1172
|
+
[5, 8, 1352829926],
|
|
1173
|
+
[14, 9, 1352829926],
|
|
1174
|
+
[7, 9, 1352829926],
|
|
1175
|
+
[0, 11, 1352829926],
|
|
1176
|
+
[9, 13, 1352829926],
|
|
1177
|
+
[2, 15, 1352829926],
|
|
1178
|
+
[11, 15, 1352829926],
|
|
1179
|
+
[4, 5, 1352829926],
|
|
1180
|
+
[13, 7, 1352829926],
|
|
1181
|
+
[6, 7, 1352829926],
|
|
1182
|
+
[15, 8, 1352829926],
|
|
1183
|
+
[8, 11, 1352829926],
|
|
1184
|
+
[1, 14, 1352829926],
|
|
1185
|
+
[10, 14, 1352829926],
|
|
1186
|
+
[3, 12, 1352829926],
|
|
1187
|
+
[12, 6, 1352829926]
|
|
1188
|
+
],
|
|
1189
|
+
[
|
|
1190
|
+
[6, 9, 1548603684],
|
|
1191
|
+
[11, 13, 1548603684],
|
|
1192
|
+
[3, 15, 1548603684],
|
|
1193
|
+
[7, 7, 1548603684],
|
|
1194
|
+
[0, 12, 1548603684],
|
|
1195
|
+
[13, 8, 1548603684],
|
|
1196
|
+
[5, 9, 1548603684],
|
|
1197
|
+
[10, 11, 1548603684],
|
|
1198
|
+
[14, 7, 1548603684],
|
|
1199
|
+
[15, 7, 1548603684],
|
|
1200
|
+
[8, 12, 1548603684],
|
|
1201
|
+
[12, 7, 1548603684],
|
|
1202
|
+
[4, 6, 1548603684],
|
|
1203
|
+
[9, 15, 1548603684],
|
|
1204
|
+
[1, 13, 1548603684],
|
|
1205
|
+
[2, 11, 1548603684]
|
|
1206
|
+
],
|
|
1207
|
+
[
|
|
1208
|
+
[15, 9, 1836072691],
|
|
1209
|
+
[5, 7, 1836072691],
|
|
1210
|
+
[1, 15, 1836072691],
|
|
1211
|
+
[3, 11, 1836072691],
|
|
1212
|
+
[7, 8, 1836072691],
|
|
1213
|
+
[14, 6, 1836072691],
|
|
1214
|
+
[6, 6, 1836072691],
|
|
1215
|
+
[9, 14, 1836072691],
|
|
1216
|
+
[11, 12, 1836072691],
|
|
1217
|
+
[8, 13, 1836072691],
|
|
1218
|
+
[12, 5, 1836072691],
|
|
1219
|
+
[2, 14, 1836072691],
|
|
1220
|
+
[10, 13, 1836072691],
|
|
1221
|
+
[0, 13, 1836072691],
|
|
1222
|
+
[4, 7, 1836072691],
|
|
1223
|
+
[13, 5, 1836072691]
|
|
1224
|
+
],
|
|
1225
|
+
[
|
|
1226
|
+
[8, 15, 2053994217],
|
|
1227
|
+
[6, 5, 2053994217],
|
|
1228
|
+
[4, 8, 2053994217],
|
|
1229
|
+
[1, 11, 2053994217],
|
|
1230
|
+
[3, 14, 2053994217],
|
|
1231
|
+
[11, 14, 2053994217],
|
|
1232
|
+
[15, 6, 2053994217],
|
|
1233
|
+
[0, 14, 2053994217],
|
|
1234
|
+
[5, 6, 2053994217],
|
|
1235
|
+
[12, 9, 2053994217],
|
|
1236
|
+
[2, 12, 2053994217],
|
|
1237
|
+
[13, 9, 2053994217],
|
|
1238
|
+
[9, 12, 2053994217],
|
|
1239
|
+
[7, 5, 2053994217],
|
|
1240
|
+
[10, 15, 2053994217],
|
|
1241
|
+
[14, 8, 2053994217]
|
|
1242
|
+
],
|
|
1243
|
+
[
|
|
1244
|
+
[12, 8, 0],
|
|
1245
|
+
[15, 5, 0],
|
|
1246
|
+
[10, 12, 0],
|
|
1247
|
+
[4, 9, 0],
|
|
1248
|
+
[1, 12, 0],
|
|
1249
|
+
[5, 5, 0],
|
|
1250
|
+
[8, 14, 0],
|
|
1251
|
+
[7, 6, 0],
|
|
1252
|
+
[6, 8, 0],
|
|
1253
|
+
[2, 13, 0],
|
|
1254
|
+
[13, 6, 0],
|
|
1255
|
+
[14, 5, 0],
|
|
1256
|
+
[0, 15, 0],
|
|
1257
|
+
[3, 13, 0],
|
|
1258
|
+
[9, 11, 0],
|
|
1259
|
+
[11, 11, 0]
|
|
1260
|
+
]
|
|
1261
|
+
];
|
|
1262
|
+
var LEFT_FNS2 = [f12, f22, f32, f4, f5];
|
|
1263
|
+
var RIGHT_FNS2 = [f5, f4, f32, f22, f12];
|
|
1264
|
+
function applyLane(r, ops, f6, x, startTarget) {
|
|
1265
|
+
let target = startTarget;
|
|
1266
|
+
for (const [k, s, addConst] of ops) {
|
|
1267
|
+
const i1 = (target + 1) % 5;
|
|
1268
|
+
const i2 = (target + 2) % 5;
|
|
1269
|
+
const i3 = (target + 3) % 5;
|
|
1270
|
+
const i4 = (target + 4) % 5;
|
|
1271
|
+
const sum = r[target] + f6(r[i1], r[i2], r[i3]) + x[k] + addConst >>> 0;
|
|
1272
|
+
const newTarget = (sum << s | sum >>> 32 - s) + r[i4] >>> 0;
|
|
1273
|
+
const c = r[i2];
|
|
1274
|
+
r[i2] = (c << 10 | c >>> 22) >>> 0;
|
|
1275
|
+
r[target] = newTarget;
|
|
1276
|
+
target = (target + 4) % 5;
|
|
1277
|
+
}
|
|
1278
|
+
return target;
|
|
1279
|
+
}
|
|
1280
|
+
function transform5(state, x) {
|
|
1281
|
+
const left = [...state];
|
|
1282
|
+
const right = [...state];
|
|
1283
|
+
let leftTarget = 0;
|
|
1284
|
+
let rightTarget = 0;
|
|
1285
|
+
for (let round2 = 0; round2 < 5; round2++) {
|
|
1286
|
+
leftTarget = applyLane(left, LEFT_ROUNDS2[round2], LEFT_FNS2[round2], x, leftTarget);
|
|
1287
|
+
rightTarget = applyLane(right, RIGHT_ROUNDS2[round2], RIGHT_FNS2[round2], x, rightTarget);
|
|
1288
|
+
}
|
|
1289
|
+
const orig = state;
|
|
1290
|
+
const newState = [
|
|
1291
|
+
add32(right[3], left[2], orig[1]),
|
|
1292
|
+
add32(orig[2], left[3], right[4]),
|
|
1293
|
+
add32(orig[3], left[4], right[0]),
|
|
1294
|
+
add32(orig[4], left[0], right[1]),
|
|
1295
|
+
add32(orig[0], left[1], right[2])
|
|
1296
|
+
];
|
|
1297
|
+
for (let i2 = 0; i2 < 5; i2++) {
|
|
1298
|
+
state[i2] = newState[i2];
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
function ripemd160(message) {
|
|
1302
|
+
return mdStyleDigest(message, INITIAL_STATE4, transform5);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
465
1305
|
// digest/sha256.ts
|
|
466
1306
|
var K = new Uint32Array([
|
|
467
1307
|
1116352408,
|
|
@@ -541,40 +1381,40 @@ var IV = [
|
|
|
541
1381
|
];
|
|
542
1382
|
var W = new Uint32Array(64);
|
|
543
1383
|
var rotr = (x, n) => x >>> n | x << 32 - n;
|
|
544
|
-
function compress(
|
|
545
|
-
for (let
|
|
546
|
-
for (let
|
|
547
|
-
const a2 = W[
|
|
548
|
-
const b2 = W[
|
|
1384
|
+
function compress(h2, view, offset) {
|
|
1385
|
+
for (let i2 = 0; i2 < 16; i2++) W[i2] = view.getUint32(offset + i2 * 4);
|
|
1386
|
+
for (let i2 = 16; i2 < 64; i2++) {
|
|
1387
|
+
const a2 = W[i2 - 15];
|
|
1388
|
+
const b2 = W[i2 - 2];
|
|
549
1389
|
const s0 = rotr(a2, 7) ^ rotr(a2, 18) ^ a2 >>> 3;
|
|
550
1390
|
const s1 = rotr(b2, 17) ^ rotr(b2, 19) ^ b2 >>> 10;
|
|
551
|
-
W[
|
|
1391
|
+
W[i2] = W[i2 - 16] + s0 + W[i2 - 7] + s1 >>> 0;
|
|
552
1392
|
}
|
|
553
|
-
let a =
|
|
554
|
-
for (let
|
|
1393
|
+
let a = h2[0], b = h2[1], c = h2[2], d = h2[3], e = h2[4], f6 = h2[5], g2 = h2[6], k = h2[7];
|
|
1394
|
+
for (let i2 = 0; i2 < 64; i2++) {
|
|
555
1395
|
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
556
|
-
const ch = e &
|
|
557
|
-
const t1 = k + S1 + ch + K[
|
|
1396
|
+
const ch = e & f6 ^ ~e & g2;
|
|
1397
|
+
const t1 = k + S1 + ch + K[i2] + W[i2] >>> 0;
|
|
558
1398
|
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
559
1399
|
const maj = a & b ^ a & c ^ b & c;
|
|
560
1400
|
const t2 = S0 + maj >>> 0;
|
|
561
|
-
k =
|
|
562
|
-
|
|
563
|
-
|
|
1401
|
+
k = g2;
|
|
1402
|
+
g2 = f6;
|
|
1403
|
+
f6 = e;
|
|
564
1404
|
e = d + t1 >>> 0;
|
|
565
1405
|
d = c;
|
|
566
1406
|
c = b;
|
|
567
1407
|
b = a;
|
|
568
1408
|
a = t1 + t2 >>> 0;
|
|
569
1409
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
1410
|
+
h2[0] = h2[0] + a >>> 0;
|
|
1411
|
+
h2[1] = h2[1] + b >>> 0;
|
|
1412
|
+
h2[2] = h2[2] + c >>> 0;
|
|
1413
|
+
h2[3] = h2[3] + d >>> 0;
|
|
1414
|
+
h2[4] = h2[4] + e >>> 0;
|
|
1415
|
+
h2[5] = h2[5] + f6 >>> 0;
|
|
1416
|
+
h2[6] = h2[6] + g2 >>> 0;
|
|
1417
|
+
h2[7] = h2[7] + k >>> 0;
|
|
578
1418
|
}
|
|
579
1419
|
function pad64(data) {
|
|
580
1420
|
const padded = new Uint8Array(Math.ceil((data.length + 9) / 64) * 64);
|
|
@@ -586,64 +1426,64 @@ function pad64(data) {
|
|
|
586
1426
|
view.setUint32(padded.length - 4, bits >>> 0);
|
|
587
1427
|
return view;
|
|
588
1428
|
}
|
|
589
|
-
function wordsOut(
|
|
590
|
-
const out = new Uint8Array(
|
|
1429
|
+
function wordsOut(h2) {
|
|
1430
|
+
const out = new Uint8Array(h2.length * 4);
|
|
591
1431
|
const view = new DataView(out.buffer);
|
|
592
|
-
for (let
|
|
1432
|
+
for (let i2 = 0; i2 < h2.length; i2++) view.setUint32(i2 * 4, h2[i2]);
|
|
593
1433
|
return out;
|
|
594
1434
|
}
|
|
595
1435
|
function sha256(data) {
|
|
596
|
-
const
|
|
1436
|
+
const h2 = new Uint32Array(IV);
|
|
597
1437
|
const view = pad64(data);
|
|
598
|
-
for (let offset = 0; offset < view.byteLength; offset += 64) compress(
|
|
599
|
-
return wordsOut(
|
|
1438
|
+
for (let offset = 0; offset < view.byteLength; offset += 64) compress(h2, view, offset);
|
|
1439
|
+
return wordsOut(h2);
|
|
600
1440
|
}
|
|
601
1441
|
|
|
602
1442
|
// digest/sha1.ts
|
|
603
1443
|
var W2 = new Uint32Array(80);
|
|
604
1444
|
var rotl = (x, n) => x << n | x >>> 32 - n;
|
|
605
|
-
function compress2(
|
|
606
|
-
for (let
|
|
607
|
-
for (let
|
|
608
|
-
let a =
|
|
609
|
-
for (let
|
|
610
|
-
let
|
|
1445
|
+
function compress2(h2, view, offset) {
|
|
1446
|
+
for (let i2 = 0; i2 < 16; i2++) W2[i2] = view.getUint32(offset + i2 * 4);
|
|
1447
|
+
for (let i2 = 16; i2 < 80; i2++) W2[i2] = rotl(W2[i2 - 3] ^ W2[i2 - 8] ^ W2[i2 - 14] ^ W2[i2 - 16], 1);
|
|
1448
|
+
let a = h2[0], b = h2[1], c = h2[2], d = h2[3], e = h2[4];
|
|
1449
|
+
for (let i2 = 0; i2 < 80; i2++) {
|
|
1450
|
+
let f6;
|
|
611
1451
|
let k;
|
|
612
|
-
if (
|
|
613
|
-
|
|
1452
|
+
if (i2 < 20) {
|
|
1453
|
+
f6 = b & c | ~b & d;
|
|
614
1454
|
k = 1518500249;
|
|
615
|
-
} else if (
|
|
616
|
-
|
|
1455
|
+
} else if (i2 < 40) {
|
|
1456
|
+
f6 = b ^ c ^ d;
|
|
617
1457
|
k = 1859775393;
|
|
618
|
-
} else if (
|
|
619
|
-
|
|
1458
|
+
} else if (i2 < 60) {
|
|
1459
|
+
f6 = b & c | b & d | c & d;
|
|
620
1460
|
k = 2400959708;
|
|
621
1461
|
} else {
|
|
622
|
-
|
|
1462
|
+
f6 = b ^ c ^ d;
|
|
623
1463
|
k = 3395469782;
|
|
624
1464
|
}
|
|
625
|
-
const t = rotl(a, 5) +
|
|
1465
|
+
const t = rotl(a, 5) + f6 + e + k + W2[i2] >>> 0;
|
|
626
1466
|
e = d;
|
|
627
1467
|
d = c;
|
|
628
1468
|
c = rotl(b, 30) >>> 0;
|
|
629
1469
|
b = a;
|
|
630
1470
|
a = t;
|
|
631
1471
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
1472
|
+
h2[0] = h2[0] + a >>> 0;
|
|
1473
|
+
h2[1] = h2[1] + b >>> 0;
|
|
1474
|
+
h2[2] = h2[2] + c >>> 0;
|
|
1475
|
+
h2[3] = h2[3] + d >>> 0;
|
|
1476
|
+
h2[4] = h2[4] + e >>> 0;
|
|
637
1477
|
}
|
|
638
1478
|
function sha1(data) {
|
|
639
|
-
const
|
|
1479
|
+
const h2 = new Uint32Array([1732584193, 4023233417, 2562383102, 271733878, 3285377520]);
|
|
640
1480
|
const view = pad64(data);
|
|
641
|
-
for (let offset = 0; offset < view.byteLength; offset += 64) compress2(
|
|
642
|
-
return wordsOut(
|
|
1481
|
+
for (let offset = 0; offset < view.byteLength; offset += 64) compress2(h2, view, offset);
|
|
1482
|
+
return wordsOut(h2);
|
|
643
1483
|
}
|
|
644
1484
|
|
|
645
1485
|
// digest/sha512.ts
|
|
646
|
-
var
|
|
1486
|
+
var K4 = new Uint32Array([
|
|
647
1487
|
1116352408,
|
|
648
1488
|
3609767458,
|
|
649
1489
|
1899447441,
|
|
@@ -842,35 +1682,35 @@ var IV_384 = [
|
|
|
842
1682
|
3204075428
|
|
843
1683
|
];
|
|
844
1684
|
var W3 = new Uint32Array(160);
|
|
845
|
-
function compress3(
|
|
846
|
-
for (let
|
|
847
|
-
const o = offset +
|
|
848
|
-
W3[
|
|
849
|
-
}
|
|
850
|
-
for (let
|
|
851
|
-
const xh = W3[(
|
|
852
|
-
const xl = W3[(
|
|
1685
|
+
function compress3(h2, data, offset) {
|
|
1686
|
+
for (let i2 = 0; i2 < 32; i2++) {
|
|
1687
|
+
const o = offset + i2 * 4;
|
|
1688
|
+
W3[i2] = (data[o] << 24 | data[o + 1] << 16 | data[o + 2] << 8 | data[o + 3]) >>> 0;
|
|
1689
|
+
}
|
|
1690
|
+
for (let i2 = 16; i2 < 80; i2++) {
|
|
1691
|
+
const xh = W3[(i2 - 15) * 2];
|
|
1692
|
+
const xl = W3[(i2 - 15) * 2 + 1];
|
|
853
1693
|
const s0h = (xh >>> 1 | xl << 31) ^ (xh >>> 8 | xl << 24) ^ xh >>> 7;
|
|
854
1694
|
const s0l = (xl >>> 1 | xh << 31) ^ (xl >>> 8 | xh << 24) ^ (xl >>> 7 | xh << 25);
|
|
855
|
-
const yh = W3[(
|
|
856
|
-
const yl = W3[(
|
|
1695
|
+
const yh = W3[(i2 - 2) * 2];
|
|
1696
|
+
const yl = W3[(i2 - 2) * 2 + 1];
|
|
857
1697
|
const s1h = (yh >>> 19 | yl << 13) ^ (yl >>> 29 | yh << 3) ^ yh >>> 6;
|
|
858
1698
|
const s1l = (yl >>> 19 | yh << 13) ^ (yh >>> 29 | yl << 3) ^ (yl >>> 6 | yh << 26);
|
|
859
|
-
let lo = (s0l >>> 0) + (s1l >>> 0) + W3[(
|
|
860
|
-
const hi = s0h + s1h + W3[(
|
|
1699
|
+
let lo = (s0l >>> 0) + (s1l >>> 0) + W3[(i2 - 7) * 2 + 1] + W3[(i2 - 16) * 2 + 1];
|
|
1700
|
+
const hi = s0h + s1h + W3[(i2 - 7) * 2] + W3[(i2 - 16) * 2] + Math.floor(lo / 4294967296);
|
|
861
1701
|
lo >>>= 0;
|
|
862
|
-
W3[
|
|
863
|
-
W3[
|
|
1702
|
+
W3[i2 * 2] = hi >>> 0;
|
|
1703
|
+
W3[i2 * 2 + 1] = lo;
|
|
864
1704
|
}
|
|
865
|
-
let ah =
|
|
866
|
-
let eh =
|
|
867
|
-
for (let
|
|
1705
|
+
let ah = h2[0], al = h2[1], bh = h2[2], bl = h2[3], ch = h2[4], cl = h2[5], dh = h2[6], dl = h2[7];
|
|
1706
|
+
let eh = h2[8], el = h2[9], fh = h2[10], fl = h2[11], gh = h2[12], gl = h2[13], hh = h2[14], hl = h2[15];
|
|
1707
|
+
for (let i2 = 0; i2 < 80; i2++) {
|
|
868
1708
|
const S1h = (eh >>> 14 | el << 18) ^ (eh >>> 18 | el << 14) ^ (el >>> 9 | eh << 23);
|
|
869
1709
|
const S1l = (el >>> 14 | eh << 18) ^ (el >>> 18 | eh << 14) ^ (eh >>> 9 | el << 23);
|
|
870
1710
|
const chh = eh & fh ^ ~eh & gh;
|
|
871
1711
|
const chl = el & fl ^ ~el & gl;
|
|
872
|
-
let t1l = (hl >>> 0) + (S1l >>> 0) + (chl >>> 0) +
|
|
873
|
-
const t1h = hh + S1h + chh +
|
|
1712
|
+
let t1l = (hl >>> 0) + (S1l >>> 0) + (chl >>> 0) + K4[i2 * 2 + 1] + W3[i2 * 2 + 1];
|
|
1713
|
+
const t1h = hh + S1h + chh + K4[i2 * 2] + W3[i2 * 2] + Math.floor(t1l / 4294967296);
|
|
874
1714
|
t1l >>>= 0;
|
|
875
1715
|
const S0h = (ah >>> 28 | al << 4) ^ (al >>> 2 | ah << 30) ^ (al >>> 7 | ah << 25);
|
|
876
1716
|
const S0l = (al >>> 28 | ah << 4) ^ (ah >>> 2 | al << 30) ^ (ah >>> 7 | al << 25);
|
|
@@ -898,10 +1738,10 @@ function compress3(h, data, offset) {
|
|
|
898
1738
|
ah = t1h + t2h + Math.floor(nl / 4294967296) >>> 0;
|
|
899
1739
|
al = nl >>> 0;
|
|
900
1740
|
}
|
|
901
|
-
const add = (
|
|
902
|
-
const lo = (
|
|
903
|
-
|
|
904
|
-
|
|
1741
|
+
const add = (i2, xh, xl) => {
|
|
1742
|
+
const lo = (h2[i2 + 1] >>> 0) + (xl >>> 0);
|
|
1743
|
+
h2[i2] = h2[i2] + xh + Math.floor(lo / 4294967296) >>> 0;
|
|
1744
|
+
h2[i2 + 1] = lo >>> 0;
|
|
905
1745
|
};
|
|
906
1746
|
add(0, ah, al);
|
|
907
1747
|
add(2, bh, bl);
|
|
@@ -913,7 +1753,7 @@ function compress3(h, data, offset) {
|
|
|
913
1753
|
add(14, hh, hl);
|
|
914
1754
|
}
|
|
915
1755
|
function digest64(data, iv, bytes) {
|
|
916
|
-
const
|
|
1756
|
+
const h2 = new Uint32Array(iv);
|
|
917
1757
|
const padded = new Uint8Array(Math.ceil((data.length + 17) / 128) * 128);
|
|
918
1758
|
padded.set(data);
|
|
919
1759
|
padded[data.length] = 128;
|
|
@@ -921,25 +1761,407 @@ function digest64(data, iv, bytes) {
|
|
|
921
1761
|
const view = new DataView(padded.buffer);
|
|
922
1762
|
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
923
1763
|
view.setUint32(padded.length - 4, bits >>> 0);
|
|
924
|
-
for (let offset = 0; offset < padded.length; offset += 128) compress3(
|
|
1764
|
+
for (let offset = 0; offset < padded.length; offset += 128) compress3(h2, padded, offset);
|
|
925
1765
|
const out = new Uint8Array(bytes);
|
|
926
1766
|
const outView = new DataView(out.buffer);
|
|
927
|
-
for (let
|
|
1767
|
+
for (let i2 = 0; i2 < bytes / 4; i2++) outView.setUint32(i2 * 4, h2[i2]);
|
|
928
1768
|
return out;
|
|
929
1769
|
}
|
|
930
1770
|
var sha512 = (data) => digest64(data, IV_512, 64);
|
|
931
1771
|
var sha384 = (data) => digest64(data, IV_384, 48);
|
|
932
1772
|
|
|
1773
|
+
// digest/whirlpool-sbox.ts
|
|
1774
|
+
var TABLE0 = [
|
|
1775
|
+
0x18186018c07830d8n,
|
|
1776
|
+
0x23238c2305af4626n,
|
|
1777
|
+
0xc6c63fc67ef991b8n,
|
|
1778
|
+
0xe8e887e8136fcdfbn,
|
|
1779
|
+
0x878726874ca113cbn,
|
|
1780
|
+
0xb8b8dab8a9626d11n,
|
|
1781
|
+
0x0101040108050209n,
|
|
1782
|
+
0x4f4f214f426e9e0dn,
|
|
1783
|
+
0x3636d836adee6c9bn,
|
|
1784
|
+
0xa6a6a2a6590451ffn,
|
|
1785
|
+
0xd2d26fd2debdb90cn,
|
|
1786
|
+
0xf5f5f3f5fb06f70en,
|
|
1787
|
+
0x7979f979ef80f296n,
|
|
1788
|
+
0x6f6fa16f5fcede30n,
|
|
1789
|
+
0x91917e91fcef3f6dn,
|
|
1790
|
+
0x52525552aa07a4f8n,
|
|
1791
|
+
0x60609d6027fdc047n,
|
|
1792
|
+
0xbcbccabc89766535n,
|
|
1793
|
+
0x9b9b569baccd2b37n,
|
|
1794
|
+
0x8e8e028e048c018an,
|
|
1795
|
+
0xa3a3b6a371155bd2n,
|
|
1796
|
+
0x0c0c300c603c186cn,
|
|
1797
|
+
0x7b7bf17bff8af684n,
|
|
1798
|
+
0x3535d435b5e16a80n,
|
|
1799
|
+
0x1d1d741de8693af5n,
|
|
1800
|
+
0xe0e0a7e05347ddb3n,
|
|
1801
|
+
0xd7d77bd7f6acb321n,
|
|
1802
|
+
0xc2c22fc25eed999cn,
|
|
1803
|
+
0x2e2eb82e6d965c43n,
|
|
1804
|
+
0x4b4b314b627a9629n,
|
|
1805
|
+
0xfefedffea321e15dn,
|
|
1806
|
+
0x575741578216aed5n,
|
|
1807
|
+
0x15155415a8412abdn,
|
|
1808
|
+
0x7777c1779fb6eee8n,
|
|
1809
|
+
0x3737dc37a5eb6e92n,
|
|
1810
|
+
0xe5e5b3e57b56d79en,
|
|
1811
|
+
0x9f9f469f8cd92313n,
|
|
1812
|
+
0xf0f0e7f0d317fd23n,
|
|
1813
|
+
0x4a4a354a6a7f9420n,
|
|
1814
|
+
0xdada4fda9e95a944n,
|
|
1815
|
+
0x58587d58fa25b0a2n,
|
|
1816
|
+
0xc9c903c906ca8fcfn,
|
|
1817
|
+
0x2929a429558d527cn,
|
|
1818
|
+
0x0a0a280a5022145an,
|
|
1819
|
+
0xb1b1feb1e14f7f50n,
|
|
1820
|
+
0xa0a0baa0691a5dc9n,
|
|
1821
|
+
0x6b6bb16b7fdad614n,
|
|
1822
|
+
0x85852e855cab17d9n,
|
|
1823
|
+
0xbdbdcebd8173673cn,
|
|
1824
|
+
0x5d5d695dd234ba8fn,
|
|
1825
|
+
0x1010401080502090n,
|
|
1826
|
+
0xf4f4f7f4f303f507n,
|
|
1827
|
+
0xcbcb0bcb16c08bddn,
|
|
1828
|
+
0x3e3ef83eedc67cd3n,
|
|
1829
|
+
0x0505140528110a2dn,
|
|
1830
|
+
0x676781671fe6ce78n,
|
|
1831
|
+
0xe4e4b7e47353d597n,
|
|
1832
|
+
0x27279c2725bb4e02n,
|
|
1833
|
+
0x4141194132588273n,
|
|
1834
|
+
0x8b8b168b2c9d0ba7n,
|
|
1835
|
+
0xa7a7a6a7510153f6n,
|
|
1836
|
+
0x7d7de97dcf94fab2n,
|
|
1837
|
+
0x95956e95dcfb3749n,
|
|
1838
|
+
0xd8d847d88e9fad56n,
|
|
1839
|
+
0xfbfbcbfb8b30eb70n,
|
|
1840
|
+
0xeeee9fee2371c1cdn,
|
|
1841
|
+
0x7c7ced7cc791f8bbn,
|
|
1842
|
+
0x6666856617e3cc71n,
|
|
1843
|
+
0xdddd53dda68ea77bn,
|
|
1844
|
+
0x17175c17b84b2eafn,
|
|
1845
|
+
0x4747014702468e45n,
|
|
1846
|
+
0x9e9e429e84dc211an,
|
|
1847
|
+
0xcaca0fca1ec589d4n,
|
|
1848
|
+
0x2d2db42d75995a58n,
|
|
1849
|
+
0xbfbfc6bf9179632en,
|
|
1850
|
+
0x07071c07381b0e3fn,
|
|
1851
|
+
0xadad8ead012347acn,
|
|
1852
|
+
0x5a5a755aea2fb4b0n,
|
|
1853
|
+
0x838336836cb51befn,
|
|
1854
|
+
0x3333cc3385ff66b6n,
|
|
1855
|
+
0x636391633ff2c65cn,
|
|
1856
|
+
0x02020802100a0412n,
|
|
1857
|
+
0xaaaa92aa39384993n,
|
|
1858
|
+
0x7171d971afa8e2den,
|
|
1859
|
+
0xc8c807c80ecf8dc6n,
|
|
1860
|
+
0x19196419c87d32d1n,
|
|
1861
|
+
0x494939497270923bn,
|
|
1862
|
+
0xd9d943d9869aaf5fn,
|
|
1863
|
+
0xf2f2eff2c31df931n,
|
|
1864
|
+
0xe3e3abe34b48dba8n,
|
|
1865
|
+
0x5b5b715be22ab6b9n,
|
|
1866
|
+
0x88881a8834920dbcn,
|
|
1867
|
+
0x9a9a529aa4c8293en,
|
|
1868
|
+
0x262698262dbe4c0bn,
|
|
1869
|
+
0x3232c8328dfa64bfn,
|
|
1870
|
+
0xb0b0fab0e94a7d59n,
|
|
1871
|
+
0xe9e983e91b6acff2n,
|
|
1872
|
+
0x0f0f3c0f78331e77n,
|
|
1873
|
+
0xd5d573d5e6a6b733n,
|
|
1874
|
+
0x80803a8074ba1df4n,
|
|
1875
|
+
0xbebec2be997c6127n,
|
|
1876
|
+
0xcdcd13cd26de87ebn,
|
|
1877
|
+
0x3434d034bde46889n,
|
|
1878
|
+
0x48483d487a759032n,
|
|
1879
|
+
0xffffdbffab24e354n,
|
|
1880
|
+
0x7a7af57af78ff48dn,
|
|
1881
|
+
0x90907a90f4ea3d64n,
|
|
1882
|
+
0x5f5f615fc23ebe9dn,
|
|
1883
|
+
0x202080201da0403dn,
|
|
1884
|
+
0x6868bd6867d5d00fn,
|
|
1885
|
+
0x1a1a681ad07234can,
|
|
1886
|
+
0xaeae82ae192c41b7n,
|
|
1887
|
+
0xb4b4eab4c95e757dn,
|
|
1888
|
+
0x54544d549a19a8cen,
|
|
1889
|
+
0x93937693ece53b7fn,
|
|
1890
|
+
0x222288220daa442fn,
|
|
1891
|
+
0x64648d6407e9c863n,
|
|
1892
|
+
0xf1f1e3f1db12ff2an,
|
|
1893
|
+
0x7373d173bfa2e6ccn,
|
|
1894
|
+
0x12124812905a2482n,
|
|
1895
|
+
0x40401d403a5d807an,
|
|
1896
|
+
0x0808200840281048n,
|
|
1897
|
+
0xc3c32bc356e89b95n,
|
|
1898
|
+
0xecec97ec337bc5dfn,
|
|
1899
|
+
0xdbdb4bdb9690ab4dn,
|
|
1900
|
+
0xa1a1bea1611f5fc0n,
|
|
1901
|
+
0x8d8d0e8d1c830791n,
|
|
1902
|
+
0x3d3df43df5c97ac8n,
|
|
1903
|
+
0x97976697ccf1335bn,
|
|
1904
|
+
0x0000000000000000n,
|
|
1905
|
+
0xcfcf1bcf36d483f9n,
|
|
1906
|
+
0x2b2bac2b4587566en,
|
|
1907
|
+
0x7676c57697b3ece1n,
|
|
1908
|
+
0x8282328264b019e6n,
|
|
1909
|
+
0xd6d67fd6fea9b128n,
|
|
1910
|
+
0x1b1b6c1bd87736c3n,
|
|
1911
|
+
0xb5b5eeb5c15b7774n,
|
|
1912
|
+
0xafaf86af112943ben,
|
|
1913
|
+
0x6a6ab56a77dfd41dn,
|
|
1914
|
+
0x50505d50ba0da0ean,
|
|
1915
|
+
0x45450945124c8a57n,
|
|
1916
|
+
0xf3f3ebf3cb18fb38n,
|
|
1917
|
+
0x3030c0309df060adn,
|
|
1918
|
+
0xefef9bef2b74c3c4n,
|
|
1919
|
+
0x3f3ffc3fe5c37edan,
|
|
1920
|
+
0x55554955921caac7n,
|
|
1921
|
+
0xa2a2b2a2791059dbn,
|
|
1922
|
+
0xeaea8fea0365c9e9n,
|
|
1923
|
+
0x656589650fecca6an,
|
|
1924
|
+
0xbabad2bab9686903n,
|
|
1925
|
+
0x2f2fbc2f65935e4an,
|
|
1926
|
+
0xc0c027c04ee79d8en,
|
|
1927
|
+
0xdede5fdebe81a160n,
|
|
1928
|
+
0x1c1c701ce06c38fcn,
|
|
1929
|
+
0xfdfdd3fdbb2ee746n,
|
|
1930
|
+
0x4d4d294d52649a1fn,
|
|
1931
|
+
0x92927292e4e03976n,
|
|
1932
|
+
0x7575c9758fbceafan,
|
|
1933
|
+
0x06061806301e0c36n,
|
|
1934
|
+
0x8a8a128a249809aen,
|
|
1935
|
+
0xb2b2f2b2f940794bn,
|
|
1936
|
+
0xe6e6bfe66359d185n,
|
|
1937
|
+
0x0e0e380e70361c7en,
|
|
1938
|
+
0x1f1f7c1ff8633ee7n,
|
|
1939
|
+
0x6262956237f7c455n,
|
|
1940
|
+
0xd4d477d4eea3b53an,
|
|
1941
|
+
0xa8a89aa829324d81n,
|
|
1942
|
+
0x96966296c4f43152n,
|
|
1943
|
+
0xf9f9c3f99b3aef62n,
|
|
1944
|
+
0xc5c533c566f697a3n,
|
|
1945
|
+
0x2525942535b14a10n,
|
|
1946
|
+
0x59597959f220b2abn,
|
|
1947
|
+
0x84842a8454ae15d0n,
|
|
1948
|
+
0x7272d572b7a7e4c5n,
|
|
1949
|
+
0x3939e439d5dd72ecn,
|
|
1950
|
+
0x4c4c2d4c5a619816n,
|
|
1951
|
+
0x5e5e655eca3bbc94n,
|
|
1952
|
+
0x7878fd78e785f09fn,
|
|
1953
|
+
0x3838e038ddd870e5n,
|
|
1954
|
+
0x8c8c0a8c14860598n,
|
|
1955
|
+
0xd1d163d1c6b2bf17n,
|
|
1956
|
+
0xa5a5aea5410b57e4n,
|
|
1957
|
+
0xe2e2afe2434dd9a1n,
|
|
1958
|
+
0x616199612ff8c24en,
|
|
1959
|
+
0xb3b3f6b3f1457b42n,
|
|
1960
|
+
0x2121842115a54234n,
|
|
1961
|
+
0x9c9c4a9c94d62508n,
|
|
1962
|
+
0x1e1e781ef0663ceen,
|
|
1963
|
+
0x4343114322528661n,
|
|
1964
|
+
0xc7c73bc776fc93b1n,
|
|
1965
|
+
0xfcfcd7fcb32be54fn,
|
|
1966
|
+
0x0404100420140824n,
|
|
1967
|
+
0x51515951b208a2e3n,
|
|
1968
|
+
0x99995e99bcc72f25n,
|
|
1969
|
+
0x6d6da96d4fc4da22n,
|
|
1970
|
+
0x0d0d340d68391a65n,
|
|
1971
|
+
0xfafacffa8335e979n,
|
|
1972
|
+
0xdfdf5bdfb684a369n,
|
|
1973
|
+
0x7e7ee57ed79bfca9n,
|
|
1974
|
+
0x242490243db44819n,
|
|
1975
|
+
0x3b3bec3bc5d776fen,
|
|
1976
|
+
0xabab96ab313d4b9an,
|
|
1977
|
+
0xcece1fce3ed181f0n,
|
|
1978
|
+
0x1111441188552299n,
|
|
1979
|
+
0x8f8f068f0c890383n,
|
|
1980
|
+
0x4e4e254e4a6b9c04n,
|
|
1981
|
+
0xb7b7e6b7d1517366n,
|
|
1982
|
+
0xebeb8beb0b60cbe0n,
|
|
1983
|
+
0x3c3cf03cfdcc78c1n,
|
|
1984
|
+
0x81813e817cbf1ffdn,
|
|
1985
|
+
0x94946a94d4fe3540n,
|
|
1986
|
+
0xf7f7fbf7eb0cf31cn,
|
|
1987
|
+
0xb9b9deb9a1676f18n,
|
|
1988
|
+
0x13134c13985f268bn,
|
|
1989
|
+
0x2c2cb02c7d9c5851n,
|
|
1990
|
+
0xd3d36bd3d6b8bb05n,
|
|
1991
|
+
0xe7e7bbe76b5cd38cn,
|
|
1992
|
+
0x6e6ea56e57cbdc39n,
|
|
1993
|
+
0xc4c437c46ef395aan,
|
|
1994
|
+
0x03030c03180f061bn,
|
|
1995
|
+
0x565645568a13acdcn,
|
|
1996
|
+
0x44440d441a49885en,
|
|
1997
|
+
0x7f7fe17fdf9efea0n,
|
|
1998
|
+
0xa9a99ea921374f88n,
|
|
1999
|
+
0x2a2aa82a4d825467n,
|
|
2000
|
+
0xbbbbd6bbb16d6b0an,
|
|
2001
|
+
0xc1c123c146e29f87n,
|
|
2002
|
+
0x53535153a202a6f1n,
|
|
2003
|
+
0xdcdc57dcae8ba572n,
|
|
2004
|
+
0x0b0b2c0b58271653n,
|
|
2005
|
+
0x9d9d4e9d9cd32701n,
|
|
2006
|
+
0x6c6cad6c47c1d82bn,
|
|
2007
|
+
0x3131c43195f562a4n,
|
|
2008
|
+
0x7474cd7487b9e8f3n,
|
|
2009
|
+
0xf6f6fff6e309f115n,
|
|
2010
|
+
0x464605460a438c4cn,
|
|
2011
|
+
0xacac8aac092645a5n,
|
|
2012
|
+
0x89891e893c970fb5n,
|
|
2013
|
+
0x14145014a04428b4n,
|
|
2014
|
+
0xe1e1a3e15b42dfban,
|
|
2015
|
+
0x16165816b04e2ca6n,
|
|
2016
|
+
0x3a3ae83acdd274f7n,
|
|
2017
|
+
0x6969b9696fd0d206n,
|
|
2018
|
+
0x09092409482d1241n,
|
|
2019
|
+
0x7070dd70a7ade0d7n,
|
|
2020
|
+
0xb6b6e2b6d954716fn,
|
|
2021
|
+
0xd0d067d0ceb7bd1en,
|
|
2022
|
+
0xeded93ed3b7ec7d6n,
|
|
2023
|
+
0xcccc17cc2edb85e2n,
|
|
2024
|
+
0x424215422a578468n,
|
|
2025
|
+
0x98985a98b4c22d2cn,
|
|
2026
|
+
0xa4a4aaa4490e55edn,
|
|
2027
|
+
0x2828a0285d885075n,
|
|
2028
|
+
0x5c5c6d5cda31b886n,
|
|
2029
|
+
0xf8f8c7f8933fed6bn,
|
|
2030
|
+
0x8686228644a411c2n
|
|
2031
|
+
];
|
|
2032
|
+
|
|
2033
|
+
// digest/whirlpool-table.ts
|
|
2034
|
+
var WORD_MASK = (1n << 64n) - 1n;
|
|
2035
|
+
var LOW_MASK = 0xffffffffn;
|
|
2036
|
+
function rotateBytesRight(value, bytes) {
|
|
2037
|
+
const bits = BigInt(bytes) * 8n;
|
|
2038
|
+
return (value >> bits | value << 64n - bits) & WORD_MASK;
|
|
2039
|
+
}
|
|
2040
|
+
var TABLES_HI = new Uint32Array(8 * 256);
|
|
2041
|
+
var TABLES_LO = new Uint32Array(8 * 256);
|
|
2042
|
+
for (let t = 0; t < 8; t++) {
|
|
2043
|
+
for (let x = 0; x < 256; x++) {
|
|
2044
|
+
const value = t === 0 ? TABLE0[x] : rotateBytesRight(TABLE0[x], t);
|
|
2045
|
+
TABLES_HI[t * 256 + x] = Number(value >> 32n);
|
|
2046
|
+
TABLES_LO[t * 256 + x] = Number(value & LOW_MASK);
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
var ROUND_CONSTANTS = [
|
|
2050
|
+
0x1823c6e887b8014fn,
|
|
2051
|
+
0x36a6d2f5796f9152n,
|
|
2052
|
+
0x60bc9b8ea30c7b35n,
|
|
2053
|
+
0x1de0d7c22e4bfe57n,
|
|
2054
|
+
0x157737e59ff04adan,
|
|
2055
|
+
0x58c9290ab1a06b85n,
|
|
2056
|
+
0xbd5d10f4cb3e0567n,
|
|
2057
|
+
0xe427418ba77d95d8n,
|
|
2058
|
+
0xfbee7c66dd17479en,
|
|
2059
|
+
0xca2dbf07ad5a8333n
|
|
2060
|
+
];
|
|
2061
|
+
var ROUND_CONSTANTS_HI = Uint32Array.from(ROUND_CONSTANTS, (c) => Number(c >> 32n));
|
|
2062
|
+
var ROUND_CONSTANTS_LO = Uint32Array.from(ROUND_CONSTANTS, (c) => Number(c & LOW_MASK));
|
|
2063
|
+
|
|
2064
|
+
// digest/whirlpool.ts
|
|
2065
|
+
var TABLES_HI2 = TABLES_HI;
|
|
2066
|
+
var TABLES_LO2 = TABLES_LO;
|
|
2067
|
+
var ROUND_CONSTANTS_HI2 = ROUND_CONSTANTS_HI;
|
|
2068
|
+
var ROUND_CONSTANTS_LO2 = ROUND_CONSTANTS_LO;
|
|
2069
|
+
var BLOCK_BYTES = 64;
|
|
2070
|
+
var WORDS = 8;
|
|
2071
|
+
var ROUNDS2 = 10;
|
|
2072
|
+
var words = () => ({ hi: new Uint32Array(WORDS), lo: new Uint32Array(WORDS) });
|
|
2073
|
+
function op(src, column, out) {
|
|
2074
|
+
const { hi: h2, lo: l } = src;
|
|
2075
|
+
const b0 = h2[column] >>> 24;
|
|
2076
|
+
const b1 = h2[column + 7 & 7] >>> 16 & 255;
|
|
2077
|
+
const b2 = h2[column + 6 & 7] >>> 8 & 255;
|
|
2078
|
+
const b3 = h2[column + 5 & 7] & 255;
|
|
2079
|
+
const b4 = l[column + 4 & 7] >>> 24;
|
|
2080
|
+
const b5 = l[column + 3 & 7] >>> 16 & 255;
|
|
2081
|
+
const b6 = l[column + 2 & 7] >>> 8 & 255;
|
|
2082
|
+
const b7 = l[column + 1 & 7] & 255;
|
|
2083
|
+
out.hi[column] = TABLES_HI2[b0] ^ TABLES_HI2[256 + b1] ^ TABLES_HI2[512 + b2] ^ TABLES_HI2[768 + b3] ^ TABLES_HI2[1024 + b4] ^ TABLES_HI2[1280 + b5] ^ TABLES_HI2[1536 + b6] ^ TABLES_HI2[1792 + b7];
|
|
2084
|
+
out.lo[column] = TABLES_LO2[b0] ^ TABLES_LO2[256 + b1] ^ TABLES_LO2[512 + b2] ^ TABLES_LO2[768 + b3] ^ TABLES_LO2[1024 + b4] ^ TABLES_LO2[1280 + b5] ^ TABLES_LO2[1536 + b6] ^ TABLES_LO2[1792 + b7];
|
|
2085
|
+
}
|
|
2086
|
+
var scratch = { key: words(), state: words(), initial: words(), nextKey: words(), next: words() };
|
|
2087
|
+
function processBlock(hash2, block) {
|
|
2088
|
+
const { key, state, initial, nextKey, next } = scratch;
|
|
2089
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
2090
|
+
initial.hi[i2] = block.hi[i2] ^ hash2.hi[i2];
|
|
2091
|
+
initial.lo[i2] = block.lo[i2] ^ hash2.lo[i2];
|
|
2092
|
+
}
|
|
2093
|
+
key.hi.set(hash2.hi);
|
|
2094
|
+
key.lo.set(hash2.lo);
|
|
2095
|
+
state.hi.set(initial.hi);
|
|
2096
|
+
state.lo.set(initial.lo);
|
|
2097
|
+
for (let round2 = 0; round2 < ROUNDS2; round2++) {
|
|
2098
|
+
for (let j = 0; j < WORDS; j++) op(key, j, nextKey);
|
|
2099
|
+
nextKey.hi[0] = nextKey.hi[0] ^ ROUND_CONSTANTS_HI2[round2];
|
|
2100
|
+
nextKey.lo[0] = nextKey.lo[0] ^ ROUND_CONSTANTS_LO2[round2];
|
|
2101
|
+
for (let j = 0; j < WORDS; j++) {
|
|
2102
|
+
op(state, j, next);
|
|
2103
|
+
next.hi[j] = next.hi[j] ^ nextKey.hi[j];
|
|
2104
|
+
next.lo[j] = next.lo[j] ^ nextKey.lo[j];
|
|
2105
|
+
}
|
|
2106
|
+
key.hi.set(nextKey.hi);
|
|
2107
|
+
key.lo.set(nextKey.lo);
|
|
2108
|
+
state.hi.set(next.hi);
|
|
2109
|
+
state.lo.set(next.lo);
|
|
2110
|
+
}
|
|
2111
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
2112
|
+
hash2.hi[i2] = initial.hi[i2] ^ state.hi[i2];
|
|
2113
|
+
hash2.lo[i2] = initial.lo[i2] ^ state.lo[i2];
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
function pad(message) {
|
|
2117
|
+
let total = message.length + 1;
|
|
2118
|
+
while (total % BLOCK_BYTES !== 32) {
|
|
2119
|
+
total++;
|
|
2120
|
+
}
|
|
2121
|
+
total += 32;
|
|
2122
|
+
const padded = new Uint8Array(total);
|
|
2123
|
+
padded.set(message);
|
|
2124
|
+
padded[message.length] = 128;
|
|
2125
|
+
new DataView(padded.buffer).setBigUint64(total - 8, BigInt(message.length) * 8n, false);
|
|
2126
|
+
return padded;
|
|
2127
|
+
}
|
|
2128
|
+
function whirlpool(message) {
|
|
2129
|
+
const padded = pad(message);
|
|
2130
|
+
const view = new DataView(padded.buffer);
|
|
2131
|
+
const hash2 = words();
|
|
2132
|
+
const block = words();
|
|
2133
|
+
for (let offset = 0; offset < padded.length; offset += BLOCK_BYTES) {
|
|
2134
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
2135
|
+
block.hi[i2] = view.getUint32(offset + i2 * 8, false);
|
|
2136
|
+
block.lo[i2] = view.getUint32(offset + i2 * 8 + 4, false);
|
|
2137
|
+
}
|
|
2138
|
+
processBlock(hash2, block);
|
|
2139
|
+
}
|
|
2140
|
+
const out = new Uint8Array(BLOCK_BYTES);
|
|
2141
|
+
const outView = new DataView(out.buffer);
|
|
2142
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
2143
|
+
outView.setUint32(i2 * 8, hash2.hi[i2], false);
|
|
2144
|
+
outView.setUint32(i2 * 8 + 4, hash2.lo[i2], false);
|
|
2145
|
+
}
|
|
2146
|
+
return out;
|
|
2147
|
+
}
|
|
2148
|
+
|
|
933
2149
|
// digest/digest.ts
|
|
934
2150
|
var DIGESTS = {
|
|
935
2151
|
"SHA-1": sha1,
|
|
936
2152
|
"SHA-256": sha256,
|
|
937
2153
|
"SHA-384": sha384,
|
|
938
|
-
"SHA-512": sha512
|
|
2154
|
+
"SHA-512": sha512,
|
|
2155
|
+
MD2: md2,
|
|
2156
|
+
MD4: md4,
|
|
2157
|
+
MD5: md5,
|
|
2158
|
+
"RIPEMD-128": ripemd128,
|
|
2159
|
+
"RIPEMD-160": ripemd160,
|
|
2160
|
+
WHIRLPOOL: whirlpool
|
|
939
2161
|
};
|
|
940
2162
|
function digestFunction(name) {
|
|
941
2163
|
const canonical = normalizeDigestAlgorithmName(name);
|
|
942
|
-
return canonical &&
|
|
2164
|
+
return canonical && DIGESTS[canonical];
|
|
943
2165
|
}
|
|
944
2166
|
|
|
945
2167
|
// crypto/key-derivation.ts
|
|
@@ -958,39 +2180,39 @@ async function spinPassword(password, salt, spinCount, hashAlgorithm) {
|
|
|
958
2180
|
const passwordBytes = encodePasswordUtf16LE(password);
|
|
959
2181
|
const digest = digestFunction(hashAlgorithm);
|
|
960
2182
|
if (digest) {
|
|
961
|
-
let
|
|
962
|
-
const buffer = new Uint8Array(4 +
|
|
2183
|
+
let h3 = digest(concatArrays(salt, passwordBytes));
|
|
2184
|
+
const buffer = new Uint8Array(4 + h3.length);
|
|
963
2185
|
const view = new DataView(buffer.buffer);
|
|
964
|
-
for (let
|
|
965
|
-
view.setUint32(0,
|
|
966
|
-
buffer.set(
|
|
967
|
-
|
|
2186
|
+
for (let i2 = 0; i2 < spinCount; i2++) {
|
|
2187
|
+
view.setUint32(0, i2, true);
|
|
2188
|
+
buffer.set(h3, 4);
|
|
2189
|
+
h3 = digest(buffer);
|
|
968
2190
|
}
|
|
969
|
-
return
|
|
2191
|
+
return h3;
|
|
970
2192
|
}
|
|
971
|
-
let
|
|
972
|
-
for (let
|
|
973
|
-
|
|
2193
|
+
let h2 = await hash(hashAlgorithm, concatArrays(salt, passwordBytes));
|
|
2194
|
+
for (let i2 = 0; i2 < spinCount; i2++) {
|
|
2195
|
+
h2 = await hash(hashAlgorithm, concatArrays(uint32LE(i2), h2));
|
|
974
2196
|
}
|
|
975
|
-
return
|
|
2197
|
+
return h2;
|
|
976
2198
|
}
|
|
977
|
-
async function extendKey(
|
|
978
|
-
const
|
|
2199
|
+
async function extendKey(h2, hashAlgorithm, keyLength) {
|
|
2200
|
+
const pad2 = async (value) => {
|
|
979
2201
|
const input = new Uint8Array(64).fill(value);
|
|
980
|
-
for (let
|
|
2202
|
+
for (let i2 = 0; i2 < h2.length && i2 < 64; i2++) input[i2] = h2[i2] ^ value;
|
|
981
2203
|
return hash(hashAlgorithm, input);
|
|
982
2204
|
};
|
|
983
|
-
const x3 = concatArrays(await
|
|
2205
|
+
const x3 = concatArrays(await pad2(54), await pad2(92));
|
|
984
2206
|
return x3.subarray(0, keyLength);
|
|
985
2207
|
}
|
|
986
2208
|
function computeAgileKeyBase(password, salt, spinCount, hashAlgorithm) {
|
|
987
2209
|
return spinPassword(password, salt, spinCount, hashAlgorithm);
|
|
988
2210
|
}
|
|
989
2211
|
async function deriveAgileKeyFromBase(base, hashAlgorithm, blockKey, keyBits, hashSize) {
|
|
990
|
-
const
|
|
2212
|
+
const h2 = await hash(hashAlgorithm, concatArrays(base, blockKey));
|
|
991
2213
|
const keyLength = keyBits / 8;
|
|
992
|
-
if (hashSize >= keyLength) return
|
|
993
|
-
return extendKey(
|
|
2214
|
+
if (hashSize >= keyLength) return h2.subarray(0, keyLength);
|
|
2215
|
+
return extendKey(h2, hashAlgorithm, keyLength);
|
|
994
2216
|
}
|
|
995
2217
|
async function deriveAgileKey(password, salt, spinCount, hashAlgorithm, blockKey, keyBits, hashSize) {
|
|
996
2218
|
const base = await computeAgileKeyBase(password, salt, spinCount, hashAlgorithm);
|
|
@@ -1000,18 +2222,18 @@ function computeStandardKeyBase(password, salt) {
|
|
|
1000
2222
|
return spinPassword(password, salt, 5e4, "SHA-1");
|
|
1001
2223
|
}
|
|
1002
2224
|
async function deriveStandardKeyFromBase(base, keySize, blockNumber = 0) {
|
|
1003
|
-
const
|
|
1004
|
-
return extendKey(
|
|
2225
|
+
const h2 = await hash("SHA-1", concatArrays(base, uint32LE(blockNumber)));
|
|
2226
|
+
return extendKey(h2, "SHA-1", keySize / 8);
|
|
1005
2227
|
}
|
|
1006
2228
|
async function deriveStandardKey(password, salt, keySize, _algIdHash, blockNumber = 0) {
|
|
1007
2229
|
const base = await computeStandardKeyBase(password, salt);
|
|
1008
2230
|
return deriveStandardKeyFromBase(base, keySize, blockNumber);
|
|
1009
2231
|
}
|
|
1010
2232
|
async function generateIV(hashAlgorithm, salt, blockKey, blockSize) {
|
|
1011
|
-
const
|
|
1012
|
-
if (
|
|
2233
|
+
const h2 = await hash(hashAlgorithm, concatArrays(salt, blockKey));
|
|
2234
|
+
if (h2.length >= blockSize) return h2.subarray(0, blockSize);
|
|
1013
2235
|
const padded = new Uint8Array(blockSize).fill(54);
|
|
1014
|
-
padded.set(
|
|
2236
|
+
padded.set(h2);
|
|
1015
2237
|
return padded;
|
|
1016
2238
|
}
|
|
1017
2239
|
|
|
@@ -1033,7 +2255,7 @@ async function verifyAgilePassword(info, password) {
|
|
|
1033
2255
|
const computedHash = await hash(pke.hashAlgorithm, verifierHashInput.subarray(0, pke.saltSize));
|
|
1034
2256
|
if (computedHash.length < pke.hashSize || verifierHashValue.length < pke.hashSize) return null;
|
|
1035
2257
|
let difference = 0;
|
|
1036
|
-
for (let
|
|
2258
|
+
for (let i2 = 0; i2 < pke.hashSize; i2++) difference |= verifierHashValue[i2] ^ computedHash[i2];
|
|
1037
2259
|
if (difference !== 0) return null;
|
|
1038
2260
|
const decryptedKey = await aesCbcDecryptRaw(
|
|
1039
2261
|
await blockKey(BLOCK_KEYS.encryptedKeyValue),
|
|
@@ -1054,8 +2276,8 @@ async function verifyStandardPassword(info, password) {
|
|
|
1054
2276
|
const computedHash = await hash("SHA-1", decryptedVerifier);
|
|
1055
2277
|
const hashSize = info.verifier.verifierHashSize;
|
|
1056
2278
|
let match = true;
|
|
1057
|
-
for (let
|
|
1058
|
-
if (computedHash[
|
|
2279
|
+
for (let i2 = 0; i2 < Math.min(hashSize, 20); i2++) {
|
|
2280
|
+
if (computedHash[i2] !== decryptedHash[i2]) {
|
|
1059
2281
|
match = false;
|
|
1060
2282
|
break;
|
|
1061
2283
|
}
|
|
@@ -1096,8 +2318,8 @@ async function verifyAgileDataIntegrity(info, key, encryptedPackage) {
|
|
|
1096
2318
|
if (computedHmac.length < keyData.hashSize) {
|
|
1097
2319
|
match = false;
|
|
1098
2320
|
} else {
|
|
1099
|
-
for (let
|
|
1100
|
-
if (computedHmac[
|
|
2321
|
+
for (let i2 = 0; i2 < keyData.hashSize; i2++) {
|
|
2322
|
+
if (computedHmac[i2] !== expectedHmac[i2]) {
|
|
1101
2323
|
match = false;
|
|
1102
2324
|
break;
|
|
1103
2325
|
}
|
|
@@ -1205,8 +2427,8 @@ function compareDirEntryNames(a, b) {
|
|
|
1205
2427
|
if (a.length !== b.length) {
|
|
1206
2428
|
return a.length - b.length;
|
|
1207
2429
|
}
|
|
1208
|
-
for (let
|
|
1209
|
-
const diff = ua.charCodeAt(
|
|
2430
|
+
for (let i2 = 0; i2 < ua.length; i2++) {
|
|
2431
|
+
const diff = ua.charCodeAt(i2) - ub.charCodeAt(i2);
|
|
1210
2432
|
if (diff !== 0) {
|
|
1211
2433
|
return diff;
|
|
1212
2434
|
}
|
|
@@ -1215,9 +2437,9 @@ function compareDirEntryNames(a, b) {
|
|
|
1215
2437
|
}
|
|
1216
2438
|
function encodeName(name) {
|
|
1217
2439
|
const bytes = new Uint8Array((name.length + 1) * 2);
|
|
1218
|
-
for (let
|
|
1219
|
-
bytes[
|
|
1220
|
-
bytes[
|
|
2440
|
+
for (let i2 = 0; i2 < name.length; i2++) {
|
|
2441
|
+
bytes[i2 * 2] = name.charCodeAt(i2) & 255;
|
|
2442
|
+
bytes[i2 * 2 + 1] = name.charCodeAt(i2) >> 8 & 255;
|
|
1221
2443
|
}
|
|
1222
2444
|
return bytes;
|
|
1223
2445
|
}
|
|
@@ -1240,21 +2462,21 @@ function buildDirectoryTree(entryCount) {
|
|
|
1240
2462
|
return { root: build(1, entryCount - 1, 0), links };
|
|
1241
2463
|
}
|
|
1242
2464
|
function writeFatChain(fat, chain) {
|
|
1243
|
-
for (let
|
|
1244
|
-
fat[chain.sectors[
|
|
2465
|
+
for (let i2 = 0; i2 < chain.sectors.length; i2++) {
|
|
2466
|
+
fat[chain.sectors[i2]] = i2 < chain.sectors.length - 1 ? chain.sectors[i2 + 1] : ENDOFCHAIN;
|
|
1245
2467
|
}
|
|
1246
2468
|
}
|
|
1247
2469
|
function writeFatRun(fat, firstSector, count) {
|
|
1248
|
-
for (let
|
|
1249
|
-
const sector = firstSector +
|
|
1250
|
-
fat[sector] =
|
|
2470
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
2471
|
+
const sector = firstSector + i2;
|
|
2472
|
+
fat[sector] = i2 < count - 1 ? sector + 1 : ENDOFCHAIN;
|
|
1251
2473
|
}
|
|
1252
2474
|
}
|
|
1253
2475
|
function writeInt32Sectors(outBytes, int32Data, firstSector, numSectors, sectorSize) {
|
|
1254
2476
|
const entriesPerSector = sectorSize / 4;
|
|
1255
|
-
for (let
|
|
1256
|
-
const sectorOff = (firstSector +
|
|
1257
|
-
const start =
|
|
2477
|
+
for (let i2 = 0; i2 < numSectors; i2++) {
|
|
2478
|
+
const sectorOff = (firstSector + i2 + 1) * sectorSize;
|
|
2479
|
+
const start = i2 * entriesPerSector;
|
|
1258
2480
|
const end = start + entriesPerSector;
|
|
1259
2481
|
const chunk = int32Data.subarray(start, end);
|
|
1260
2482
|
const chunkBytes = new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
|
|
@@ -1280,11 +2502,11 @@ function writeHeader(outView, outBytes, params) {
|
|
|
1280
2502
|
const numDIFATSectors = params.numDIFATSectors ?? 0;
|
|
1281
2503
|
outView.setUint32(68, numDIFATSectors > 0 ? params.firstDIFATSector ?? ENDOFCHAIN : ENDOFCHAIN, true);
|
|
1282
2504
|
outView.setUint32(72, numDIFATSectors, true);
|
|
1283
|
-
for (let
|
|
1284
|
-
if (
|
|
1285
|
-
outView.setUint32(76 +
|
|
2505
|
+
for (let i2 = 0; i2 < HEADER_DIFAT_ENTRIES; i2++) {
|
|
2506
|
+
if (i2 < params.numFATSectors) {
|
|
2507
|
+
outView.setUint32(76 + i2 * 4, params.firstFATSector + i2, true);
|
|
1286
2508
|
} else {
|
|
1287
|
-
outView.setUint32(76 +
|
|
2509
|
+
outView.setUint32(76 + i2 * 4, FREESECT, true);
|
|
1288
2510
|
}
|
|
1289
2511
|
}
|
|
1290
2512
|
}
|
|
@@ -1321,24 +2543,24 @@ function serializeDirectoryEntries(dirEntries, numDirSectors, sectorSize) {
|
|
|
1321
2543
|
const dirData = new Uint8Array(numDirSectors * sectorSize);
|
|
1322
2544
|
const dirView = new DataView(dirData.buffer);
|
|
1323
2545
|
const tree = buildDirectoryTree(dirEntries.length);
|
|
1324
|
-
for (let
|
|
1325
|
-
const entry = dirEntries[
|
|
1326
|
-
const entryOffset =
|
|
2546
|
+
for (let i2 = 0; i2 < dirEntries.length; i2++) {
|
|
2547
|
+
const entry = dirEntries[i2];
|
|
2548
|
+
const entryOffset = i2 * DIR_ENTRY_SIZE;
|
|
1327
2549
|
const nameBytes = encodeName(entry.name);
|
|
1328
2550
|
dirData.set(nameBytes.subarray(0, Math.min(nameBytes.length, 64)), entryOffset);
|
|
1329
2551
|
dirView.setUint16(entryOffset + 64, Math.min((entry.name.length + 1) * 2, 64), true);
|
|
1330
2552
|
dirData[entryOffset + 66] = entry.type;
|
|
1331
|
-
dirData[entryOffset + 67] =
|
|
2553
|
+
dirData[entryOffset + 67] = i2 === 0 ? 1 : tree.links.get(i2).color;
|
|
1332
2554
|
if (entry.clsid) {
|
|
1333
2555
|
dirData.set(entry.clsid.subarray(0, 16), entryOffset + 80);
|
|
1334
2556
|
}
|
|
1335
|
-
if (
|
|
2557
|
+
if (i2 === 0) {
|
|
1336
2558
|
dirView.setUint32(entryOffset + 68, 4294967295, true);
|
|
1337
2559
|
dirView.setUint32(entryOffset + 72, 4294967295, true);
|
|
1338
2560
|
dirView.setUint32(entryOffset + 76, tree.root, true);
|
|
1339
2561
|
} else {
|
|
1340
|
-
dirView.setUint32(entryOffset + 68, tree.links.get(
|
|
1341
|
-
dirView.setUint32(entryOffset + 72, tree.links.get(
|
|
2562
|
+
dirView.setUint32(entryOffset + 68, tree.links.get(i2).left, true);
|
|
2563
|
+
dirView.setUint32(entryOffset + 72, tree.links.get(i2).right, true);
|
|
1342
2564
|
dirView.setUint32(entryOffset + 76, 4294967295, true);
|
|
1343
2565
|
}
|
|
1344
2566
|
dirView.setUint32(entryOffset + 116, entry.startSector, true);
|
|
@@ -1347,9 +2569,9 @@ function serializeDirectoryEntries(dirEntries, numDirSectors, sectorSize) {
|
|
|
1347
2569
|
return dirData;
|
|
1348
2570
|
}
|
|
1349
2571
|
function writeStreamSectors(outBytes, streamData, chain, sectorSize) {
|
|
1350
|
-
for (let
|
|
1351
|
-
const sectorOffset = (chain.sectors[
|
|
1352
|
-
const srcOffset =
|
|
2572
|
+
for (let i2 = 0; i2 < chain.sectors.length; i2++) {
|
|
2573
|
+
const sectorOffset = (chain.sectors[i2] + 1) * sectorSize;
|
|
2574
|
+
const srcOffset = i2 * sectorSize;
|
|
1353
2575
|
const srcEnd = Math.min(srcOffset + sectorSize, streamData.length);
|
|
1354
2576
|
outBytes.set(streamData.subarray(srcOffset, srcEnd), sectorOffset);
|
|
1355
2577
|
}
|
|
@@ -1360,15 +2582,15 @@ function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
|
|
|
1360
2582
|
const sectorSize = 512;
|
|
1361
2583
|
const miniSectorSize = 64;
|
|
1362
2584
|
const names = [...streams2.keys()].sort(compareDirEntryNames);
|
|
1363
|
-
for (let
|
|
1364
|
-
const name = names[
|
|
2585
|
+
for (let i2 = 0; i2 < names.length; i2++) {
|
|
2586
|
+
const name = names[i2];
|
|
1365
2587
|
if (name.toUpperCase().length !== name.length) {
|
|
1366
2588
|
throw new Error("CFB stream names with expanding uppercase mappings are unsupported");
|
|
1367
2589
|
}
|
|
1368
2590
|
if (!name.length || name.length > 31 || /[\x00\\/:!]/.test(name)) {
|
|
1369
2591
|
throw new Error("CFB stream names must be 1-31 UTF-16 code units without NUL, \\, /, :, or !");
|
|
1370
2592
|
}
|
|
1371
|
-
if (
|
|
2593
|
+
if (i2 > 0 && compareDirEntryNames(names[i2 - 1], name) === 0) {
|
|
1372
2594
|
throw new Error("Duplicate CFB stream names");
|
|
1373
2595
|
}
|
|
1374
2596
|
}
|
|
@@ -1386,7 +2608,7 @@ function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
|
|
|
1386
2608
|
for (const stream of regularStreams) {
|
|
1387
2609
|
const numSectors = Math.ceil(stream.data.length / sectorSize);
|
|
1388
2610
|
const sectors = [];
|
|
1389
|
-
for (let
|
|
2611
|
+
for (let i2 = 0; i2 < numSectors; i2++) {
|
|
1390
2612
|
sectors.push(nextSector++);
|
|
1391
2613
|
}
|
|
1392
2614
|
fatChains.set(stream.name, { start: sectors[0] ?? ENDOFCHAIN, sectors });
|
|
@@ -1404,9 +2626,9 @@ function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
|
|
|
1404
2626
|
for (const stream of miniStreams) {
|
|
1405
2627
|
const numMiniSectors = Math.ceil(stream.data.length / miniSectorSize);
|
|
1406
2628
|
const miniSectors = [];
|
|
1407
|
-
for (let
|
|
2629
|
+
for (let i2 = 0; i2 < numMiniSectors; i2++) {
|
|
1408
2630
|
miniSectors.push(nextMiniSector++);
|
|
1409
|
-
const srcOffset =
|
|
2631
|
+
const srcOffset = i2 * miniSectorSize;
|
|
1410
2632
|
const srcEnd = Math.min(srcOffset + miniSectorSize, stream.data.length);
|
|
1411
2633
|
miniStreamContainer.set(stream.data.subarray(srcOffset, srcEnd), miniOffset);
|
|
1412
2634
|
miniOffset += miniSectorSize;
|
|
@@ -1422,7 +2644,7 @@ function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
|
|
|
1422
2644
|
if (miniStreamContainer.length > 0) {
|
|
1423
2645
|
const numSectors = Math.ceil(miniStreamContainer.length / sectorSize);
|
|
1424
2646
|
rootStartSector = nextSector;
|
|
1425
|
-
for (let
|
|
2647
|
+
for (let i2 = 0; i2 < numSectors; i2++) {
|
|
1426
2648
|
rootSectors.push(nextSector++);
|
|
1427
2649
|
}
|
|
1428
2650
|
}
|
|
@@ -1481,11 +2703,11 @@ function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
|
|
|
1481
2703
|
if (numMiniFATSectors > 0) {
|
|
1482
2704
|
writeFatRun(fat, firstMiniFATSector, numMiniFATSectors);
|
|
1483
2705
|
}
|
|
1484
|
-
for (let
|
|
1485
|
-
fat[firstFATSector +
|
|
2706
|
+
for (let i2 = 0; i2 < numFATSectors; i2++) {
|
|
2707
|
+
fat[firstFATSector + i2] = FATSECT;
|
|
1486
2708
|
}
|
|
1487
|
-
for (let
|
|
1488
|
-
fat[firstDIFATSector +
|
|
2709
|
+
for (let i2 = 0; i2 < numDIFATSectors; i2++) {
|
|
2710
|
+
fat[firstDIFATSector + i2] = DIFSECT;
|
|
1489
2711
|
}
|
|
1490
2712
|
let miniFat;
|
|
1491
2713
|
if (miniStreams.length > 0) {
|
|
@@ -1516,9 +2738,9 @@ function buildOle2(streams2, rootClsid, miniStreamCutoff = 4096) {
|
|
|
1516
2738
|
writeStreamSectors(outBytes, miniStreamContainer, { start: rootSectors[0] ?? 0, sectors: rootSectors }, sectorSize);
|
|
1517
2739
|
}
|
|
1518
2740
|
const dirData = serializeDirectoryEntries(sortedDirEntries, numDirSectors, sectorSize);
|
|
1519
|
-
for (let
|
|
1520
|
-
const sectorOff = (firstDirSector +
|
|
1521
|
-
outBytes.set(dirData.subarray(
|
|
2741
|
+
for (let i2 = 0; i2 < numDirSectors; i2++) {
|
|
2742
|
+
const sectorOff = (firstDirSector + i2 + 1) * sectorSize;
|
|
2743
|
+
outBytes.set(dirData.subarray(i2 * sectorSize, (i2 + 1) * sectorSize), sectorOff);
|
|
1522
2744
|
}
|
|
1523
2745
|
if (miniFat) {
|
|
1524
2746
|
writeInt32Sectors(outBytes, miniFat, firstMiniFATSector, numMiniFATSectors, sectorSize);
|
|
@@ -1571,10 +2793,10 @@ function buildStandardEncryptionInfoStream(keyBits, salt, encryptedVerifier, enc
|
|
|
1571
2793
|
);
|
|
1572
2794
|
}
|
|
1573
2795
|
const cspNameBytes = new Uint8Array((STANDARD_CSP_NAME.length + 1) * 2);
|
|
1574
|
-
for (let
|
|
1575
|
-
const code = STANDARD_CSP_NAME.charCodeAt(
|
|
1576
|
-
cspNameBytes[
|
|
1577
|
-
cspNameBytes[
|
|
2796
|
+
for (let i2 = 0; i2 < STANDARD_CSP_NAME.length; i2++) {
|
|
2797
|
+
const code = STANDARD_CSP_NAME.charCodeAt(i2);
|
|
2798
|
+
cspNameBytes[i2 * 2] = code & 255;
|
|
2799
|
+
cspNameBytes[i2 * 2 + 1] = code >> 8 & 255;
|
|
1578
2800
|
}
|
|
1579
2801
|
const headerFixedSize = 32;
|
|
1580
2802
|
const headerSize = headerFixedSize + cspNameBytes.length;
|
|
@@ -1586,16 +2808,16 @@ function buildStandardEncryptionInfoStream(keyBits, salt, encryptedVerifier, enc
|
|
|
1586
2808
|
view.setUint16(2, 2, true);
|
|
1587
2809
|
view.setUint32(4, STANDARD_FLAGS, true);
|
|
1588
2810
|
view.setUint32(8, headerSize, true);
|
|
1589
|
-
const
|
|
1590
|
-
view.setUint32(
|
|
1591
|
-
view.setUint32(
|
|
1592
|
-
view.setUint32(
|
|
1593
|
-
view.setUint32(
|
|
1594
|
-
view.setUint32(
|
|
1595
|
-
view.setUint32(
|
|
1596
|
-
view.setUint32(
|
|
1597
|
-
view.setUint32(
|
|
1598
|
-
data.set(cspNameBytes,
|
|
2811
|
+
const h2 = 12;
|
|
2812
|
+
view.setUint32(h2, STANDARD_FLAGS, true);
|
|
2813
|
+
view.setUint32(h2 + 4, 0, true);
|
|
2814
|
+
view.setUint32(h2 + 8, algId, true);
|
|
2815
|
+
view.setUint32(h2 + 12, STANDARD_ALG_ID_HASH_SHA1, true);
|
|
2816
|
+
view.setUint32(h2 + 16, keyBits, true);
|
|
2817
|
+
view.setUint32(h2 + 20, STANDARD_PROVIDER_TYPE_RSA_AES, true);
|
|
2818
|
+
view.setUint32(h2 + 24, 0, true);
|
|
2819
|
+
view.setUint32(h2 + 28, 0, true);
|
|
2820
|
+
data.set(cspNameBytes, h2 + 32);
|
|
1599
2821
|
const v = 12 + headerSize;
|
|
1600
2822
|
view.setUint32(v, 16, true);
|
|
1601
2823
|
data.set(salt.subarray(0, 16), v + 4);
|
|
@@ -1752,8 +2974,8 @@ function parseStandardEncryptionInfo(data) {
|
|
|
1752
2974
|
const providerType = view.getUint32(headerOffset + 20, true);
|
|
1753
2975
|
let cspName = "";
|
|
1754
2976
|
const cspEnd = headerOffset + headerSize;
|
|
1755
|
-
for (let
|
|
1756
|
-
const ch = view.getUint16(
|
|
2977
|
+
for (let i2 = headerOffset + 32; i2 < cspEnd - 1; i2 += 2) {
|
|
2978
|
+
const ch = view.getUint16(i2, true);
|
|
1757
2979
|
if (ch === 0) break;
|
|
1758
2980
|
cspName += String.fromCharCode(ch);
|
|
1759
2981
|
}
|