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