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
|
@@ -21567,7 +21567,7 @@ function findTextBearingElementById(elements2, elementId) {
|
|
|
21567
21567
|
}
|
|
21568
21568
|
async function loadNestedDeck(pptxBytes) {
|
|
21569
21569
|
try {
|
|
21570
|
-
const { PptxHandler } = await import('./PptxHandler-
|
|
21570
|
+
const { PptxHandler } = await import('./PptxHandler-75LOVF7I.mjs');
|
|
21571
21571
|
const handler = new PptxHandler();
|
|
21572
21572
|
const data = await handler.load(pptxBytes.buffer.slice(0));
|
|
21573
21573
|
return { handler, slides: data.slides };
|
|
@@ -22352,9 +22352,9 @@ function renderOleDocumentPreviewPng(paragraphs) {
|
|
|
22352
22352
|
if (y > PREVIEW_HEIGHT - lineHeight) {
|
|
22353
22353
|
break;
|
|
22354
22354
|
}
|
|
22355
|
-
const
|
|
22355
|
+
const words2 = paragraph.split(/\s+/u).filter((w) => w.length > 0);
|
|
22356
22356
|
let line2 = "";
|
|
22357
|
-
for (const word of
|
|
22357
|
+
for (const word of words2) {
|
|
22358
22358
|
const candidate = line2.length > 0 ? `${line2} ${word}` : word;
|
|
22359
22359
|
if (candidate.length > maxCharsPerLine) {
|
|
22360
22360
|
if (line2.length > 0) {
|
|
@@ -27402,14 +27402,14 @@ function greedyWrap(text, maxWidth, fontSize, table) {
|
|
|
27402
27402
|
let lines = 0;
|
|
27403
27403
|
let widestLineWidth = 0;
|
|
27404
27404
|
for (const paragraph of text.split("\n")) {
|
|
27405
|
-
const
|
|
27406
|
-
if (
|
|
27405
|
+
const words2 = paragraph.split(/\s+/u).filter((word) => word.length > 0);
|
|
27406
|
+
if (words2.length === 0) {
|
|
27407
27407
|
lines += 1;
|
|
27408
27408
|
continue;
|
|
27409
27409
|
}
|
|
27410
27410
|
let lineWidth = 0;
|
|
27411
27411
|
let paragraphLines = 1;
|
|
27412
|
-
for (const word of
|
|
27412
|
+
for (const word of words2) {
|
|
27413
27413
|
const wordWidth = measureTextWidth(word, fontSize, table);
|
|
27414
27414
|
const extended = lineWidth === 0 ? wordWidth : lineWidth + spaceWidth + wordWidth;
|
|
27415
27415
|
if (extended > maxWidth && lineWidth > 0) {
|
|
@@ -34192,8 +34192,8 @@ async function verifySignatureDigests(signature, getPartContent) {
|
|
|
34192
34192
|
continue;
|
|
34193
34193
|
}
|
|
34194
34194
|
try {
|
|
34195
|
-
const
|
|
34196
|
-
const digestBase64 = arrayBufferToBase64(
|
|
34195
|
+
const digest = await crypto.subtle.digest(hashAlgo, content);
|
|
34196
|
+
const digestBase64 = arrayBufferToBase64(digest);
|
|
34197
34197
|
if (digestBase64 !== ref.digestValue) {
|
|
34198
34198
|
return "invalid";
|
|
34199
34199
|
}
|
|
@@ -35938,1061 +35938,7 @@ function normalizeDigestAlgorithmName(name) {
|
|
|
35938
35938
|
return Object.hasOwn(CANONICAL_BY_LOOKUP_KEY, key) ? CANONICAL_BY_LOOKUP_KEY[key] : void 0;
|
|
35939
35939
|
}
|
|
35940
35940
|
|
|
35941
|
-
// digest/
|
|
35942
|
-
var K = new Uint32Array([
|
|
35943
|
-
1116352408,
|
|
35944
|
-
1899447441,
|
|
35945
|
-
3049323471,
|
|
35946
|
-
3921009573,
|
|
35947
|
-
961987163,
|
|
35948
|
-
1508970993,
|
|
35949
|
-
2453635748,
|
|
35950
|
-
2870763221,
|
|
35951
|
-
3624381080,
|
|
35952
|
-
310598401,
|
|
35953
|
-
607225278,
|
|
35954
|
-
1426881987,
|
|
35955
|
-
1925078388,
|
|
35956
|
-
2162078206,
|
|
35957
|
-
2614888103,
|
|
35958
|
-
3248222580,
|
|
35959
|
-
3835390401,
|
|
35960
|
-
4022224774,
|
|
35961
|
-
264347078,
|
|
35962
|
-
604807628,
|
|
35963
|
-
770255983,
|
|
35964
|
-
1249150122,
|
|
35965
|
-
1555081692,
|
|
35966
|
-
1996064986,
|
|
35967
|
-
2554220882,
|
|
35968
|
-
2821834349,
|
|
35969
|
-
2952996808,
|
|
35970
|
-
3210313671,
|
|
35971
|
-
3336571891,
|
|
35972
|
-
3584528711,
|
|
35973
|
-
113926993,
|
|
35974
|
-
338241895,
|
|
35975
|
-
666307205,
|
|
35976
|
-
773529912,
|
|
35977
|
-
1294757372,
|
|
35978
|
-
1396182291,
|
|
35979
|
-
1695183700,
|
|
35980
|
-
1986661051,
|
|
35981
|
-
2177026350,
|
|
35982
|
-
2456956037,
|
|
35983
|
-
2730485921,
|
|
35984
|
-
2820302411,
|
|
35985
|
-
3259730800,
|
|
35986
|
-
3345764771,
|
|
35987
|
-
3516065817,
|
|
35988
|
-
3600352804,
|
|
35989
|
-
4094571909,
|
|
35990
|
-
275423344,
|
|
35991
|
-
430227734,
|
|
35992
|
-
506948616,
|
|
35993
|
-
659060556,
|
|
35994
|
-
883997877,
|
|
35995
|
-
958139571,
|
|
35996
|
-
1322822218,
|
|
35997
|
-
1537002063,
|
|
35998
|
-
1747873779,
|
|
35999
|
-
1955562222,
|
|
36000
|
-
2024104815,
|
|
36001
|
-
2227730452,
|
|
36002
|
-
2361852424,
|
|
36003
|
-
2428436474,
|
|
36004
|
-
2756734187,
|
|
36005
|
-
3204031479,
|
|
36006
|
-
3329325298
|
|
36007
|
-
]);
|
|
36008
|
-
var IV = [
|
|
36009
|
-
1779033703,
|
|
36010
|
-
3144134277,
|
|
36011
|
-
1013904242,
|
|
36012
|
-
2773480762,
|
|
36013
|
-
1359893119,
|
|
36014
|
-
2600822924,
|
|
36015
|
-
528734635,
|
|
36016
|
-
1541459225
|
|
36017
|
-
];
|
|
36018
|
-
var W = new Uint32Array(64);
|
|
36019
|
-
var rotr = (x, n) => x >>> n | x << 32 - n;
|
|
36020
|
-
function compress(h2, view, offset) {
|
|
36021
|
-
for (let i2 = 0; i2 < 16; i2++) W[i2] = view.getUint32(offset + i2 * 4);
|
|
36022
|
-
for (let i2 = 16; i2 < 64; i2++) {
|
|
36023
|
-
const a2 = W[i2 - 15];
|
|
36024
|
-
const b2 = W[i2 - 2];
|
|
36025
|
-
const s0 = rotr(a2, 7) ^ rotr(a2, 18) ^ a2 >>> 3;
|
|
36026
|
-
const s1 = rotr(b2, 17) ^ rotr(b2, 19) ^ b2 >>> 10;
|
|
36027
|
-
W[i2] = W[i2 - 16] + s0 + W[i2 - 7] + s1 >>> 0;
|
|
36028
|
-
}
|
|
36029
|
-
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];
|
|
36030
|
-
for (let i2 = 0; i2 < 64; i2++) {
|
|
36031
|
-
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
36032
|
-
const ch = e & f6 ^ ~e & g2;
|
|
36033
|
-
const t1 = k + S1 + ch + K[i2] + W[i2] >>> 0;
|
|
36034
|
-
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
36035
|
-
const maj = a & b ^ a & c ^ b & c;
|
|
36036
|
-
const t2 = S0 + maj >>> 0;
|
|
36037
|
-
k = g2;
|
|
36038
|
-
g2 = f6;
|
|
36039
|
-
f6 = e;
|
|
36040
|
-
e = d + t1 >>> 0;
|
|
36041
|
-
d = c;
|
|
36042
|
-
c = b;
|
|
36043
|
-
b = a;
|
|
36044
|
-
a = t1 + t2 >>> 0;
|
|
36045
|
-
}
|
|
36046
|
-
h2[0] = h2[0] + a >>> 0;
|
|
36047
|
-
h2[1] = h2[1] + b >>> 0;
|
|
36048
|
-
h2[2] = h2[2] + c >>> 0;
|
|
36049
|
-
h2[3] = h2[3] + d >>> 0;
|
|
36050
|
-
h2[4] = h2[4] + e >>> 0;
|
|
36051
|
-
h2[5] = h2[5] + f6 >>> 0;
|
|
36052
|
-
h2[6] = h2[6] + g2 >>> 0;
|
|
36053
|
-
h2[7] = h2[7] + k >>> 0;
|
|
36054
|
-
}
|
|
36055
|
-
function pad64(data) {
|
|
36056
|
-
const padded = new Uint8Array(Math.ceil((data.length + 9) / 64) * 64);
|
|
36057
|
-
padded.set(data);
|
|
36058
|
-
padded[data.length] = 128;
|
|
36059
|
-
const bits = data.length * 8;
|
|
36060
|
-
const view = new DataView(padded.buffer);
|
|
36061
|
-
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
36062
|
-
view.setUint32(padded.length - 4, bits >>> 0);
|
|
36063
|
-
return view;
|
|
36064
|
-
}
|
|
36065
|
-
function wordsOut(h2) {
|
|
36066
|
-
const out = new Uint8Array(h2.length * 4);
|
|
36067
|
-
const view = new DataView(out.buffer);
|
|
36068
|
-
for (let i2 = 0; i2 < h2.length; i2++) view.setUint32(i2 * 4, h2[i2]);
|
|
36069
|
-
return out;
|
|
36070
|
-
}
|
|
36071
|
-
function sha256(data) {
|
|
36072
|
-
const h2 = new Uint32Array(IV);
|
|
36073
|
-
const view = pad64(data);
|
|
36074
|
-
for (let offset = 0; offset < view.byteLength; offset += 64) compress(h2, view, offset);
|
|
36075
|
-
return wordsOut(h2);
|
|
36076
|
-
}
|
|
36077
|
-
|
|
36078
|
-
// digest/sha1.ts
|
|
36079
|
-
var W2 = new Uint32Array(80);
|
|
36080
|
-
var rotl = (x, n) => x << n | x >>> 32 - n;
|
|
36081
|
-
function compress2(h2, view, offset) {
|
|
36082
|
-
for (let i2 = 0; i2 < 16; i2++) W2[i2] = view.getUint32(offset + i2 * 4);
|
|
36083
|
-
for (let i2 = 16; i2 < 80; i2++) W2[i2] = rotl(W2[i2 - 3] ^ W2[i2 - 8] ^ W2[i2 - 14] ^ W2[i2 - 16], 1);
|
|
36084
|
-
let a = h2[0], b = h2[1], c = h2[2], d = h2[3], e = h2[4];
|
|
36085
|
-
for (let i2 = 0; i2 < 80; i2++) {
|
|
36086
|
-
let f6;
|
|
36087
|
-
let k;
|
|
36088
|
-
if (i2 < 20) {
|
|
36089
|
-
f6 = b & c | ~b & d;
|
|
36090
|
-
k = 1518500249;
|
|
36091
|
-
} else if (i2 < 40) {
|
|
36092
|
-
f6 = b ^ c ^ d;
|
|
36093
|
-
k = 1859775393;
|
|
36094
|
-
} else if (i2 < 60) {
|
|
36095
|
-
f6 = b & c | b & d | c & d;
|
|
36096
|
-
k = 2400959708;
|
|
36097
|
-
} else {
|
|
36098
|
-
f6 = b ^ c ^ d;
|
|
36099
|
-
k = 3395469782;
|
|
36100
|
-
}
|
|
36101
|
-
const t = rotl(a, 5) + f6 + e + k + W2[i2] >>> 0;
|
|
36102
|
-
e = d;
|
|
36103
|
-
d = c;
|
|
36104
|
-
c = rotl(b, 30) >>> 0;
|
|
36105
|
-
b = a;
|
|
36106
|
-
a = t;
|
|
36107
|
-
}
|
|
36108
|
-
h2[0] = h2[0] + a >>> 0;
|
|
36109
|
-
h2[1] = h2[1] + b >>> 0;
|
|
36110
|
-
h2[2] = h2[2] + c >>> 0;
|
|
36111
|
-
h2[3] = h2[3] + d >>> 0;
|
|
36112
|
-
h2[4] = h2[4] + e >>> 0;
|
|
36113
|
-
}
|
|
36114
|
-
function sha1(data) {
|
|
36115
|
-
const h2 = new Uint32Array([1732584193, 4023233417, 2562383102, 271733878, 3285377520]);
|
|
36116
|
-
const view = pad64(data);
|
|
36117
|
-
for (let offset = 0; offset < view.byteLength; offset += 64) compress2(h2, view, offset);
|
|
36118
|
-
return wordsOut(h2);
|
|
36119
|
-
}
|
|
36120
|
-
|
|
36121
|
-
// digest/sha512.ts
|
|
36122
|
-
var K2 = new Uint32Array([
|
|
36123
|
-
1116352408,
|
|
36124
|
-
3609767458,
|
|
36125
|
-
1899447441,
|
|
36126
|
-
602891725,
|
|
36127
|
-
3049323471,
|
|
36128
|
-
3964484399,
|
|
36129
|
-
3921009573,
|
|
36130
|
-
2173295548,
|
|
36131
|
-
961987163,
|
|
36132
|
-
4081628472,
|
|
36133
|
-
1508970993,
|
|
36134
|
-
3053834265,
|
|
36135
|
-
2453635748,
|
|
36136
|
-
2937671579,
|
|
36137
|
-
2870763221,
|
|
36138
|
-
3664609560,
|
|
36139
|
-
3624381080,
|
|
36140
|
-
2734883394,
|
|
36141
|
-
310598401,
|
|
36142
|
-
1164996542,
|
|
36143
|
-
607225278,
|
|
36144
|
-
1323610764,
|
|
36145
|
-
1426881987,
|
|
36146
|
-
3590304994,
|
|
36147
|
-
1925078388,
|
|
36148
|
-
4068182383,
|
|
36149
|
-
2162078206,
|
|
36150
|
-
991336113,
|
|
36151
|
-
2614888103,
|
|
36152
|
-
633803317,
|
|
36153
|
-
3248222580,
|
|
36154
|
-
3479774868,
|
|
36155
|
-
3835390401,
|
|
36156
|
-
2666613458,
|
|
36157
|
-
4022224774,
|
|
36158
|
-
944711139,
|
|
36159
|
-
264347078,
|
|
36160
|
-
2341262773,
|
|
36161
|
-
604807628,
|
|
36162
|
-
2007800933,
|
|
36163
|
-
770255983,
|
|
36164
|
-
1495990901,
|
|
36165
|
-
1249150122,
|
|
36166
|
-
1856431235,
|
|
36167
|
-
1555081692,
|
|
36168
|
-
3175218132,
|
|
36169
|
-
1996064986,
|
|
36170
|
-
2198950837,
|
|
36171
|
-
2554220882,
|
|
36172
|
-
3999719339,
|
|
36173
|
-
2821834349,
|
|
36174
|
-
766784016,
|
|
36175
|
-
2952996808,
|
|
36176
|
-
2566594879,
|
|
36177
|
-
3210313671,
|
|
36178
|
-
3203337956,
|
|
36179
|
-
3336571891,
|
|
36180
|
-
1034457026,
|
|
36181
|
-
3584528711,
|
|
36182
|
-
2466948901,
|
|
36183
|
-
113926993,
|
|
36184
|
-
3758326383,
|
|
36185
|
-
338241895,
|
|
36186
|
-
168717936,
|
|
36187
|
-
666307205,
|
|
36188
|
-
1188179964,
|
|
36189
|
-
773529912,
|
|
36190
|
-
1546045734,
|
|
36191
|
-
1294757372,
|
|
36192
|
-
1522805485,
|
|
36193
|
-
1396182291,
|
|
36194
|
-
2643833823,
|
|
36195
|
-
1695183700,
|
|
36196
|
-
2343527390,
|
|
36197
|
-
1986661051,
|
|
36198
|
-
1014477480,
|
|
36199
|
-
2177026350,
|
|
36200
|
-
1206759142,
|
|
36201
|
-
2456956037,
|
|
36202
|
-
344077627,
|
|
36203
|
-
2730485921,
|
|
36204
|
-
1290863460,
|
|
36205
|
-
2820302411,
|
|
36206
|
-
3158454273,
|
|
36207
|
-
3259730800,
|
|
36208
|
-
3505952657,
|
|
36209
|
-
3345764771,
|
|
36210
|
-
106217008,
|
|
36211
|
-
3516065817,
|
|
36212
|
-
3606008344,
|
|
36213
|
-
3600352804,
|
|
36214
|
-
1432725776,
|
|
36215
|
-
4094571909,
|
|
36216
|
-
1467031594,
|
|
36217
|
-
275423344,
|
|
36218
|
-
851169720,
|
|
36219
|
-
430227734,
|
|
36220
|
-
3100823752,
|
|
36221
|
-
506948616,
|
|
36222
|
-
1363258195,
|
|
36223
|
-
659060556,
|
|
36224
|
-
3750685593,
|
|
36225
|
-
883997877,
|
|
36226
|
-
3785050280,
|
|
36227
|
-
958139571,
|
|
36228
|
-
3318307427,
|
|
36229
|
-
1322822218,
|
|
36230
|
-
3812723403,
|
|
36231
|
-
1537002063,
|
|
36232
|
-
2003034995,
|
|
36233
|
-
1747873779,
|
|
36234
|
-
3602036899,
|
|
36235
|
-
1955562222,
|
|
36236
|
-
1575990012,
|
|
36237
|
-
2024104815,
|
|
36238
|
-
1125592928,
|
|
36239
|
-
2227730452,
|
|
36240
|
-
2716904306,
|
|
36241
|
-
2361852424,
|
|
36242
|
-
442776044,
|
|
36243
|
-
2428436474,
|
|
36244
|
-
593698344,
|
|
36245
|
-
2756734187,
|
|
36246
|
-
3733110249,
|
|
36247
|
-
3204031479,
|
|
36248
|
-
2999351573,
|
|
36249
|
-
3329325298,
|
|
36250
|
-
3815920427,
|
|
36251
|
-
3391569614,
|
|
36252
|
-
3928383900,
|
|
36253
|
-
3515267271,
|
|
36254
|
-
566280711,
|
|
36255
|
-
3940187606,
|
|
36256
|
-
3454069534,
|
|
36257
|
-
4118630271,
|
|
36258
|
-
4000239992,
|
|
36259
|
-
116418474,
|
|
36260
|
-
1914138554,
|
|
36261
|
-
174292421,
|
|
36262
|
-
2731055270,
|
|
36263
|
-
289380356,
|
|
36264
|
-
3203993006,
|
|
36265
|
-
460393269,
|
|
36266
|
-
320620315,
|
|
36267
|
-
685471733,
|
|
36268
|
-
587496836,
|
|
36269
|
-
852142971,
|
|
36270
|
-
1086792851,
|
|
36271
|
-
1017036298,
|
|
36272
|
-
365543100,
|
|
36273
|
-
1126000580,
|
|
36274
|
-
2618297676,
|
|
36275
|
-
1288033470,
|
|
36276
|
-
3409855158,
|
|
36277
|
-
1501505948,
|
|
36278
|
-
4234509866,
|
|
36279
|
-
1607167915,
|
|
36280
|
-
987167468,
|
|
36281
|
-
1816402316,
|
|
36282
|
-
1246189591
|
|
36283
|
-
]);
|
|
36284
|
-
var IV_512 = [
|
|
36285
|
-
1779033703,
|
|
36286
|
-
4089235720,
|
|
36287
|
-
3144134277,
|
|
36288
|
-
2227873595,
|
|
36289
|
-
1013904242,
|
|
36290
|
-
4271175723,
|
|
36291
|
-
2773480762,
|
|
36292
|
-
1595750129,
|
|
36293
|
-
1359893119,
|
|
36294
|
-
2917565137,
|
|
36295
|
-
2600822924,
|
|
36296
|
-
725511199,
|
|
36297
|
-
528734635,
|
|
36298
|
-
4215389547,
|
|
36299
|
-
1541459225,
|
|
36300
|
-
327033209
|
|
36301
|
-
];
|
|
36302
|
-
var IV_384 = [
|
|
36303
|
-
3418070365,
|
|
36304
|
-
3238371032,
|
|
36305
|
-
1654270250,
|
|
36306
|
-
914150663,
|
|
36307
|
-
2438529370,
|
|
36308
|
-
812702999,
|
|
36309
|
-
355462360,
|
|
36310
|
-
4144912697,
|
|
36311
|
-
1731405415,
|
|
36312
|
-
4290775857,
|
|
36313
|
-
2394180231,
|
|
36314
|
-
1750603025,
|
|
36315
|
-
3675008525,
|
|
36316
|
-
1694076839,
|
|
36317
|
-
1203062813,
|
|
36318
|
-
3204075428
|
|
36319
|
-
];
|
|
36320
|
-
var W3 = new Uint32Array(160);
|
|
36321
|
-
function compress3(h2, data, offset) {
|
|
36322
|
-
for (let i2 = 0; i2 < 32; i2++) {
|
|
36323
|
-
const o = offset + i2 * 4;
|
|
36324
|
-
W3[i2] = (data[o] << 24 | data[o + 1] << 16 | data[o + 2] << 8 | data[o + 3]) >>> 0;
|
|
36325
|
-
}
|
|
36326
|
-
for (let i2 = 16; i2 < 80; i2++) {
|
|
36327
|
-
const xh = W3[(i2 - 15) * 2];
|
|
36328
|
-
const xl = W3[(i2 - 15) * 2 + 1];
|
|
36329
|
-
const s0h = (xh >>> 1 | xl << 31) ^ (xh >>> 8 | xl << 24) ^ xh >>> 7;
|
|
36330
|
-
const s0l = (xl >>> 1 | xh << 31) ^ (xl >>> 8 | xh << 24) ^ (xl >>> 7 | xh << 25);
|
|
36331
|
-
const yh = W3[(i2 - 2) * 2];
|
|
36332
|
-
const yl = W3[(i2 - 2) * 2 + 1];
|
|
36333
|
-
const s1h = (yh >>> 19 | yl << 13) ^ (yl >>> 29 | yh << 3) ^ yh >>> 6;
|
|
36334
|
-
const s1l = (yl >>> 19 | yh << 13) ^ (yh >>> 29 | yl << 3) ^ (yl >>> 6 | yh << 26);
|
|
36335
|
-
let lo = (s0l >>> 0) + (s1l >>> 0) + W3[(i2 - 7) * 2 + 1] + W3[(i2 - 16) * 2 + 1];
|
|
36336
|
-
const hi = s0h + s1h + W3[(i2 - 7) * 2] + W3[(i2 - 16) * 2] + Math.floor(lo / 4294967296);
|
|
36337
|
-
lo >>>= 0;
|
|
36338
|
-
W3[i2 * 2] = hi >>> 0;
|
|
36339
|
-
W3[i2 * 2 + 1] = lo;
|
|
36340
|
-
}
|
|
36341
|
-
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];
|
|
36342
|
-
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];
|
|
36343
|
-
for (let i2 = 0; i2 < 80; i2++) {
|
|
36344
|
-
const S1h = (eh >>> 14 | el << 18) ^ (eh >>> 18 | el << 14) ^ (el >>> 9 | eh << 23);
|
|
36345
|
-
const S1l = (el >>> 14 | eh << 18) ^ (el >>> 18 | eh << 14) ^ (eh >>> 9 | el << 23);
|
|
36346
|
-
const chh = eh & fh ^ ~eh & gh;
|
|
36347
|
-
const chl = el & fl ^ ~el & gl;
|
|
36348
|
-
let t1l = (hl >>> 0) + (S1l >>> 0) + (chl >>> 0) + K2[i2 * 2 + 1] + W3[i2 * 2 + 1];
|
|
36349
|
-
const t1h = hh + S1h + chh + K2[i2 * 2] + W3[i2 * 2] + Math.floor(t1l / 4294967296);
|
|
36350
|
-
t1l >>>= 0;
|
|
36351
|
-
const S0h = (ah >>> 28 | al << 4) ^ (al >>> 2 | ah << 30) ^ (al >>> 7 | ah << 25);
|
|
36352
|
-
const S0l = (al >>> 28 | ah << 4) ^ (ah >>> 2 | al << 30) ^ (ah >>> 7 | al << 25);
|
|
36353
|
-
const majh = ah & bh ^ ah & ch ^ bh & ch;
|
|
36354
|
-
const majl = al & bl ^ al & cl ^ bl & cl;
|
|
36355
|
-
let t2l = (S0l >>> 0) + (majl >>> 0);
|
|
36356
|
-
const t2h = S0h + majh + Math.floor(t2l / 4294967296);
|
|
36357
|
-
t2l >>>= 0;
|
|
36358
|
-
hh = gh;
|
|
36359
|
-
hl = gl;
|
|
36360
|
-
gh = fh;
|
|
36361
|
-
gl = fl;
|
|
36362
|
-
fh = eh;
|
|
36363
|
-
fl = el;
|
|
36364
|
-
let nl = (dl >>> 0) + t1l;
|
|
36365
|
-
eh = dh + t1h + Math.floor(nl / 4294967296) >>> 0;
|
|
36366
|
-
el = nl >>> 0;
|
|
36367
|
-
dh = ch;
|
|
36368
|
-
dl = cl;
|
|
36369
|
-
ch = bh;
|
|
36370
|
-
cl = bl;
|
|
36371
|
-
bh = ah;
|
|
36372
|
-
bl = al;
|
|
36373
|
-
nl = t1l + t2l;
|
|
36374
|
-
ah = t1h + t2h + Math.floor(nl / 4294967296) >>> 0;
|
|
36375
|
-
al = nl >>> 0;
|
|
36376
|
-
}
|
|
36377
|
-
const add7 = (i2, xh, xl) => {
|
|
36378
|
-
const lo = (h2[i2 + 1] >>> 0) + (xl >>> 0);
|
|
36379
|
-
h2[i2] = h2[i2] + xh + Math.floor(lo / 4294967296) >>> 0;
|
|
36380
|
-
h2[i2 + 1] = lo >>> 0;
|
|
36381
|
-
};
|
|
36382
|
-
add7(0, ah, al);
|
|
36383
|
-
add7(2, bh, bl);
|
|
36384
|
-
add7(4, ch, cl);
|
|
36385
|
-
add7(6, dh, dl);
|
|
36386
|
-
add7(8, eh, el);
|
|
36387
|
-
add7(10, fh, fl);
|
|
36388
|
-
add7(12, gh, gl);
|
|
36389
|
-
add7(14, hh, hl);
|
|
36390
|
-
}
|
|
36391
|
-
function digest64(data, iv, bytes) {
|
|
36392
|
-
const h2 = new Uint32Array(iv);
|
|
36393
|
-
const padded = new Uint8Array(Math.ceil((data.length + 17) / 128) * 128);
|
|
36394
|
-
padded.set(data);
|
|
36395
|
-
padded[data.length] = 128;
|
|
36396
|
-
const bits = data.length * 8;
|
|
36397
|
-
const view = new DataView(padded.buffer);
|
|
36398
|
-
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
36399
|
-
view.setUint32(padded.length - 4, bits >>> 0);
|
|
36400
|
-
for (let offset = 0; offset < padded.length; offset += 128) compress3(h2, padded, offset);
|
|
36401
|
-
const out = new Uint8Array(bytes);
|
|
36402
|
-
const outView = new DataView(out.buffer);
|
|
36403
|
-
for (let i2 = 0; i2 < bytes / 4; i2++) outView.setUint32(i2 * 4, h2[i2]);
|
|
36404
|
-
return out;
|
|
36405
|
-
}
|
|
36406
|
-
var sha512 = (data) => digest64(data, IV_512, 64);
|
|
36407
|
-
var sha384 = (data) => digest64(data, IV_384, 48);
|
|
36408
|
-
|
|
36409
|
-
// digest/digest.ts
|
|
36410
|
-
var DIGESTS = {
|
|
36411
|
-
"SHA-1": sha1,
|
|
36412
|
-
"SHA-256": sha256,
|
|
36413
|
-
"SHA-384": sha384,
|
|
36414
|
-
"SHA-512": sha512
|
|
36415
|
-
};
|
|
36416
|
-
function digestFunction(name) {
|
|
36417
|
-
const canonical = normalizeDigestAlgorithmName(name);
|
|
36418
|
-
return canonical && canonical in DIGESTS ? DIGESTS[canonical] : void 0;
|
|
36419
|
-
}
|
|
36420
|
-
|
|
36421
|
-
// crypto/key-derivation.ts
|
|
36422
|
-
var BLOCK_KEYS = {
|
|
36423
|
-
verifierHashInput: new Uint8Array([254, 167, 210, 118, 59, 75, 158, 121]),
|
|
36424
|
-
verifierHashValue: new Uint8Array([215, 170, 15, 109, 48, 97, 52, 78]),
|
|
36425
|
-
encryptedKeyValue: new Uint8Array([20, 110, 11, 231, 171, 172, 208, 214]),
|
|
36426
|
-
dataIntegrityHmacKey: new Uint8Array([95, 178, 173, 1, 12, 185, 225, 246]),
|
|
36427
|
-
dataIntegrityHmacValue: new Uint8Array([160, 103, 127, 2, 178, 44, 132, 51])
|
|
36428
|
-
};
|
|
36429
|
-
var MAX_SPIN_COUNT = 1e7;
|
|
36430
|
-
async function spinPassword(password, salt, spinCount, hashAlgorithm) {
|
|
36431
|
-
if (!Number.isInteger(spinCount) || spinCount < 0 || spinCount > MAX_SPIN_COUNT) {
|
|
36432
|
-
throw new Error(`Unsupported encryption spin count: ${spinCount}.`);
|
|
36433
|
-
}
|
|
36434
|
-
const passwordBytes = encodePasswordUtf16LE(password);
|
|
36435
|
-
const digest2 = digestFunction(hashAlgorithm);
|
|
36436
|
-
if (digest2) {
|
|
36437
|
-
let h3 = digest2(concatArrays(salt, passwordBytes));
|
|
36438
|
-
const buffer = new Uint8Array(4 + h3.length);
|
|
36439
|
-
const view = new DataView(buffer.buffer);
|
|
36440
|
-
for (let i2 = 0; i2 < spinCount; i2++) {
|
|
36441
|
-
view.setUint32(0, i2, true);
|
|
36442
|
-
buffer.set(h3, 4);
|
|
36443
|
-
h3 = digest2(buffer);
|
|
36444
|
-
}
|
|
36445
|
-
return h3;
|
|
36446
|
-
}
|
|
36447
|
-
let h2 = await hash(hashAlgorithm, concatArrays(salt, passwordBytes));
|
|
36448
|
-
for (let i2 = 0; i2 < spinCount; i2++) {
|
|
36449
|
-
h2 = await hash(hashAlgorithm, concatArrays(uint32LE(i2), h2));
|
|
36450
|
-
}
|
|
36451
|
-
return h2;
|
|
36452
|
-
}
|
|
36453
|
-
async function extendKey(h2, hashAlgorithm, keyLength) {
|
|
36454
|
-
const pad2 = async (value) => {
|
|
36455
|
-
const input = new Uint8Array(64).fill(value);
|
|
36456
|
-
for (let i2 = 0; i2 < h2.length && i2 < 64; i2++) input[i2] = h2[i2] ^ value;
|
|
36457
|
-
return hash(hashAlgorithm, input);
|
|
36458
|
-
};
|
|
36459
|
-
const x3 = concatArrays(await pad2(54), await pad2(92));
|
|
36460
|
-
return x3.subarray(0, keyLength);
|
|
36461
|
-
}
|
|
36462
|
-
function computeAgileKeyBase(password, salt, spinCount, hashAlgorithm) {
|
|
36463
|
-
return spinPassword(password, salt, spinCount, hashAlgorithm);
|
|
36464
|
-
}
|
|
36465
|
-
async function deriveAgileKeyFromBase(base, hashAlgorithm, blockKey, keyBits, hashSize) {
|
|
36466
|
-
const h2 = await hash(hashAlgorithm, concatArrays(base, blockKey));
|
|
36467
|
-
const keyLength = keyBits / 8;
|
|
36468
|
-
if (hashSize >= keyLength) return h2.subarray(0, keyLength);
|
|
36469
|
-
return extendKey(h2, hashAlgorithm, keyLength);
|
|
36470
|
-
}
|
|
36471
|
-
function computeStandardKeyBase(password, salt) {
|
|
36472
|
-
return spinPassword(password, salt, 5e4, "SHA-1");
|
|
36473
|
-
}
|
|
36474
|
-
async function deriveStandardKeyFromBase(base, keySize, blockNumber = 0) {
|
|
36475
|
-
const h2 = await hash("SHA-1", concatArrays(base, uint32LE(blockNumber)));
|
|
36476
|
-
return extendKey(h2, "SHA-1", keySize / 8);
|
|
36477
|
-
}
|
|
36478
|
-
async function deriveStandardKey(password, salt, keySize, _algIdHash, blockNumber = 0) {
|
|
36479
|
-
const base = await computeStandardKeyBase(password, salt);
|
|
36480
|
-
return deriveStandardKeyFromBase(base, keySize, blockNumber);
|
|
36481
|
-
}
|
|
36482
|
-
async function generateIV(hashAlgorithm, salt, blockKey, blockSize) {
|
|
36483
|
-
const h2 = await hash(hashAlgorithm, concatArrays(salt, blockKey));
|
|
36484
|
-
if (h2.length >= blockSize) return h2.subarray(0, blockSize);
|
|
36485
|
-
const padded = new Uint8Array(blockSize).fill(54);
|
|
36486
|
-
padded.set(h2);
|
|
36487
|
-
return padded;
|
|
36488
|
-
}
|
|
36489
|
-
|
|
36490
|
-
// crypto/decrypt.ts
|
|
36491
|
-
async function verifyAgilePassword(info, password) {
|
|
36492
|
-
const pke = info.passwordKeyEncryptor;
|
|
36493
|
-
const base = await computeAgileKeyBase(password, pke.saltValue, pke.spinCount, pke.hashAlgorithm);
|
|
36494
|
-
const blockKey = (block) => deriveAgileKeyFromBase(base, pke.hashAlgorithm, block, pke.keyBits, pke.hashSize);
|
|
36495
|
-
const verifierHashInput = await aesCbcDecryptRaw(
|
|
36496
|
-
await blockKey(BLOCK_KEYS.verifierHashInput),
|
|
36497
|
-
pke.saltValue,
|
|
36498
|
-
pke.encryptedVerifierHashInput
|
|
36499
|
-
);
|
|
36500
|
-
const verifierHashValue = await aesCbcDecryptRaw(
|
|
36501
|
-
await blockKey(BLOCK_KEYS.verifierHashValue),
|
|
36502
|
-
pke.saltValue,
|
|
36503
|
-
pke.encryptedVerifierHashValue
|
|
36504
|
-
);
|
|
36505
|
-
const computedHash = await hash(pke.hashAlgorithm, verifierHashInput.subarray(0, pke.saltSize));
|
|
36506
|
-
if (computedHash.length < pke.hashSize || verifierHashValue.length < pke.hashSize) return null;
|
|
36507
|
-
let difference = 0;
|
|
36508
|
-
for (let i2 = 0; i2 < pke.hashSize; i2++) difference |= verifierHashValue[i2] ^ computedHash[i2];
|
|
36509
|
-
if (difference !== 0) return null;
|
|
36510
|
-
const decryptedKey = await aesCbcDecryptRaw(
|
|
36511
|
-
await blockKey(BLOCK_KEYS.encryptedKeyValue),
|
|
36512
|
-
pke.saltValue,
|
|
36513
|
-
pke.encryptedKeyValue
|
|
36514
|
-
);
|
|
36515
|
-
return decryptedKey.subarray(0, info.keyData.keyBits / 8);
|
|
36516
|
-
}
|
|
36517
|
-
async function verifyStandardPassword(info, password) {
|
|
36518
|
-
const key = await deriveStandardKey(
|
|
36519
|
-
password,
|
|
36520
|
-
info.verifier.salt,
|
|
36521
|
-
info.header.keySize,
|
|
36522
|
-
info.header.algIdHash
|
|
36523
|
-
);
|
|
36524
|
-
const decryptedVerifier = await aesEcbDecrypt(key, info.verifier.encryptedVerifier);
|
|
36525
|
-
const decryptedHash = await aesEcbDecrypt(key, info.verifier.encryptedVerifierHash);
|
|
36526
|
-
const computedHash = await hash("SHA-1", decryptedVerifier);
|
|
36527
|
-
const hashSize = info.verifier.verifierHashSize;
|
|
36528
|
-
let match = true;
|
|
36529
|
-
for (let i2 = 0; i2 < Math.min(hashSize, 20); i2++) {
|
|
36530
|
-
if (computedHash[i2] !== decryptedHash[i2]) {
|
|
36531
|
-
match = false;
|
|
36532
|
-
break;
|
|
36533
|
-
}
|
|
36534
|
-
}
|
|
36535
|
-
return match ? key : null;
|
|
36536
|
-
}
|
|
36537
|
-
async function verifyAgileDataIntegrity(info, key, encryptedPackage) {
|
|
36538
|
-
const keyData = info.keyData;
|
|
36539
|
-
if (!info.dataIntegrity) {
|
|
36540
|
-
return;
|
|
36541
|
-
}
|
|
36542
|
-
const hmacKeyIV = await generateIV(
|
|
36543
|
-
keyData.hashAlgorithm,
|
|
36544
|
-
keyData.saltValue,
|
|
36545
|
-
BLOCK_KEYS.dataIntegrityHmacKey,
|
|
36546
|
-
keyData.blockSize
|
|
36547
|
-
);
|
|
36548
|
-
const decryptedHmacKey = await aesCbcDecryptRaw(
|
|
36549
|
-
key,
|
|
36550
|
-
hmacKeyIV,
|
|
36551
|
-
info.dataIntegrity.encryptedHmacKey
|
|
36552
|
-
);
|
|
36553
|
-
const hmacKey = decryptedHmacKey.subarray(0, keyData.hashSize);
|
|
36554
|
-
const hmacValueIV = await generateIV(
|
|
36555
|
-
keyData.hashAlgorithm,
|
|
36556
|
-
keyData.saltValue,
|
|
36557
|
-
BLOCK_KEYS.dataIntegrityHmacValue,
|
|
36558
|
-
keyData.blockSize
|
|
36559
|
-
);
|
|
36560
|
-
const decryptedHmacValue = await aesCbcDecryptRaw(
|
|
36561
|
-
key,
|
|
36562
|
-
hmacValueIV,
|
|
36563
|
-
info.dataIntegrity.encryptedHmacValue
|
|
36564
|
-
);
|
|
36565
|
-
const expectedHmac = decryptedHmacValue.subarray(0, keyData.hashSize);
|
|
36566
|
-
const computedHmac = await hmac(keyData.hashAlgorithm, hmacKey, encryptedPackage);
|
|
36567
|
-
let match = true;
|
|
36568
|
-
if (computedHmac.length < keyData.hashSize) {
|
|
36569
|
-
match = false;
|
|
36570
|
-
} else {
|
|
36571
|
-
for (let i2 = 0; i2 < keyData.hashSize; i2++) {
|
|
36572
|
-
if (computedHmac[i2] !== expectedHmac[i2]) {
|
|
36573
|
-
match = false;
|
|
36574
|
-
break;
|
|
36575
|
-
}
|
|
36576
|
-
}
|
|
36577
|
-
}
|
|
36578
|
-
if (!match) {
|
|
36579
|
-
throw new DataIntegrityError(
|
|
36580
|
-
"Data integrity check failed. The encrypted file may be corrupted or tampered with."
|
|
36581
|
-
);
|
|
36582
|
-
}
|
|
36583
|
-
}
|
|
36584
|
-
async function decryptAgilePackage(encryptedPackage, key, info) {
|
|
36585
|
-
const keyData = info.keyData;
|
|
36586
|
-
const sizeView = new DataView(encryptedPackage.buffer, encryptedPackage.byteOffset, 8);
|
|
36587
|
-
const originalSize = sizeView.getUint32(0, true) + sizeView.getUint32(4, true) * 4294967296;
|
|
36588
|
-
const encryptedData = encryptedPackage.subarray(8);
|
|
36589
|
-
const segmentSize = 4096;
|
|
36590
|
-
const result = new Uint8Array(originalSize);
|
|
36591
|
-
let resultOffset = 0;
|
|
36592
|
-
const numSegments = Math.ceil(encryptedData.length / segmentSize);
|
|
36593
|
-
for (let segment = 0; segment < numSegments; segment++) {
|
|
36594
|
-
const segmentStart = segment * segmentSize;
|
|
36595
|
-
const segmentEnd = Math.min(segmentStart + segmentSize, encryptedData.length);
|
|
36596
|
-
const segmentData = encryptedData.subarray(segmentStart, segmentEnd);
|
|
36597
|
-
const blockKeyBytes = uint32LE(segment);
|
|
36598
|
-
const segmentIV = await generateIV(
|
|
36599
|
-
keyData.hashAlgorithm,
|
|
36600
|
-
keyData.saltValue,
|
|
36601
|
-
blockKeyBytes,
|
|
36602
|
-
keyData.blockSize
|
|
36603
|
-
);
|
|
36604
|
-
const decrypted = await aesCbcDecryptRaw(key, segmentIV, segmentData);
|
|
36605
|
-
const bytesToCopy = Math.min(decrypted.length, originalSize - resultOffset);
|
|
36606
|
-
result.set(decrypted.subarray(0, bytesToCopy), resultOffset);
|
|
36607
|
-
resultOffset += bytesToCopy;
|
|
36608
|
-
}
|
|
36609
|
-
return result.buffer;
|
|
36610
|
-
}
|
|
36611
|
-
async function decryptStandardPackage(encryptedPackage, key) {
|
|
36612
|
-
const sizeView = new DataView(encryptedPackage.buffer, encryptedPackage.byteOffset, 8);
|
|
36613
|
-
const originalSize = sizeView.getUint32(0, true);
|
|
36614
|
-
const encryptedData = encryptedPackage.subarray(8);
|
|
36615
|
-
const decrypted = await aesEcbDecrypt(key, encryptedData);
|
|
36616
|
-
return decrypted.slice(0, originalSize).buffer;
|
|
36617
|
-
}
|
|
36618
|
-
|
|
36619
|
-
// crypto/encryption-info-write.ts
|
|
36620
|
-
function buildAgileEncryptionInfoXml(keyData, pke, dataIntegrity) {
|
|
36621
|
-
const xmlNs = "http://schemas.microsoft.com/office/2006/encryption";
|
|
36622
|
-
const pNs = "http://schemas.microsoft.com/office/2006/keyEncryptor/password";
|
|
36623
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
|
|
36624
|
-
<encryption xmlns="${xmlNs}" xmlns:p="${pNs}"><keyData saltSize="${keyData.saltSize}" blockSize="${keyData.blockSize}" keyBits="${keyData.keyBits}" hashSize="${keyData.hashSize}" cipherAlgorithm="${keyData.cipherAlgorithm}" cipherChaining="${keyData.cipherChaining}" hashAlgorithm="${keyData.hashAlgorithm}" saltValue="${base64Encode(keyData.saltValue)}"/><dataIntegrity encryptedHmacKey="${base64Encode(dataIntegrity.encryptedHmacKey)}" encryptedHmacValue="${base64Encode(dataIntegrity.encryptedHmacValue)}"/><keyEncryptors><keyEncryptor uri="http://schemas.microsoft.com/office/2006/keyEncryptor/password"><p:encryptedKey spinCount="${pke.spinCount}" saltSize="${pke.saltSize}" blockSize="${pke.blockSize}" keyBits="${pke.keyBits}" hashSize="${pke.hashSize}" cipherAlgorithm="${pke.cipherAlgorithm}" cipherChaining="${pke.cipherChaining}" hashAlgorithm="${pke.hashAlgorithm}" saltValue="${base64Encode(pke.saltValue)}" encryptedVerifierHashInput="${base64Encode(pke.encryptedVerifierHashInput)}" encryptedVerifierHashValue="${base64Encode(pke.encryptedVerifierHashValue)}" encryptedKeyValue="${base64Encode(pke.encryptedKeyValue)}"/></keyEncryptor></keyEncryptors></encryption>`;
|
|
36625
|
-
}
|
|
36626
|
-
function buildEncryptionInfoStream(xmlString) {
|
|
36627
|
-
const xmlBytes = new TextEncoder().encode(xmlString);
|
|
36628
|
-
const result = new Uint8Array(8 + xmlBytes.length);
|
|
36629
|
-
const view = new DataView(result.buffer);
|
|
36630
|
-
view.setUint16(0, 4, true);
|
|
36631
|
-
view.setUint16(2, 4, true);
|
|
36632
|
-
view.setUint32(4, 64, true);
|
|
36633
|
-
result.set(xmlBytes, 8);
|
|
36634
|
-
return result;
|
|
36635
|
-
}
|
|
36636
|
-
var STANDARD_ALG_IDS = {
|
|
36637
|
-
128: 26126,
|
|
36638
|
-
// CALG_AES_128
|
|
36639
|
-
192: 26127,
|
|
36640
|
-
// CALG_AES_192
|
|
36641
|
-
256: 26128
|
|
36642
|
-
// CALG_AES_256
|
|
36643
|
-
};
|
|
36644
|
-
var STANDARD_ALG_ID_HASH_SHA1 = 32772;
|
|
36645
|
-
var STANDARD_PROVIDER_TYPE_RSA_AES = 24;
|
|
36646
|
-
var STANDARD_CSP_NAME = "Microsoft Enhanced RSA and AES Cryptographic Provider";
|
|
36647
|
-
var STANDARD_FLAGS = 36;
|
|
36648
|
-
function buildStandardEncryptionInfoStream(keyBits, salt, encryptedVerifier, encryptedVerifierHash) {
|
|
36649
|
-
const algId = STANDARD_ALG_IDS[keyBits];
|
|
36650
|
-
if (!algId) {
|
|
36651
|
-
throw new Error(
|
|
36652
|
-
`Unsupported standard encryption key size: ${keyBits} bits. Use 128, 192, or 256.`
|
|
36653
|
-
);
|
|
36654
|
-
}
|
|
36655
|
-
const cspNameBytes = new Uint8Array((STANDARD_CSP_NAME.length + 1) * 2);
|
|
36656
|
-
for (let i2 = 0; i2 < STANDARD_CSP_NAME.length; i2++) {
|
|
36657
|
-
const code = STANDARD_CSP_NAME.charCodeAt(i2);
|
|
36658
|
-
cspNameBytes[i2 * 2] = code & 255;
|
|
36659
|
-
cspNameBytes[i2 * 2 + 1] = code >> 8 & 255;
|
|
36660
|
-
}
|
|
36661
|
-
const headerFixedSize = 32;
|
|
36662
|
-
const headerSize = headerFixedSize + cspNameBytes.length;
|
|
36663
|
-
const verifierSize = 4 + 16 + 16 + 4 + 32;
|
|
36664
|
-
const totalSize = 12 + headerSize + verifierSize;
|
|
36665
|
-
const data = new Uint8Array(totalSize);
|
|
36666
|
-
const view = new DataView(data.buffer);
|
|
36667
|
-
view.setUint16(0, 4, true);
|
|
36668
|
-
view.setUint16(2, 2, true);
|
|
36669
|
-
view.setUint32(4, STANDARD_FLAGS, true);
|
|
36670
|
-
view.setUint32(8, headerSize, true);
|
|
36671
|
-
const h2 = 12;
|
|
36672
|
-
view.setUint32(h2, STANDARD_FLAGS, true);
|
|
36673
|
-
view.setUint32(h2 + 4, 0, true);
|
|
36674
|
-
view.setUint32(h2 + 8, algId, true);
|
|
36675
|
-
view.setUint32(h2 + 12, STANDARD_ALG_ID_HASH_SHA1, true);
|
|
36676
|
-
view.setUint32(h2 + 16, keyBits, true);
|
|
36677
|
-
view.setUint32(h2 + 20, STANDARD_PROVIDER_TYPE_RSA_AES, true);
|
|
36678
|
-
view.setUint32(h2 + 24, 0, true);
|
|
36679
|
-
view.setUint32(h2 + 28, 0, true);
|
|
36680
|
-
data.set(cspNameBytes, h2 + 32);
|
|
36681
|
-
const v = 12 + headerSize;
|
|
36682
|
-
view.setUint32(v, 16, true);
|
|
36683
|
-
data.set(salt.subarray(0, 16), v + 4);
|
|
36684
|
-
data.set(encryptedVerifier.subarray(0, 16), v + 20);
|
|
36685
|
-
view.setUint32(v + 36, 20, true);
|
|
36686
|
-
data.set(encryptedVerifierHash.subarray(0, 32), v + 40);
|
|
36687
|
-
return data;
|
|
36688
|
-
}
|
|
36689
|
-
|
|
36690
|
-
// crypto/encrypt.ts
|
|
36691
|
-
var SEGMENT_SIZE = 4096;
|
|
36692
|
-
function container(encryptionInfo, encryptedPackage) {
|
|
36693
|
-
const streams2 = /* @__PURE__ */ new Map();
|
|
36694
|
-
streams2.set("EncryptionInfo", encryptionInfo);
|
|
36695
|
-
streams2.set("EncryptedPackage", encryptedPackage);
|
|
36696
|
-
return new Uint8Array(buildOle2(streams2));
|
|
36697
|
-
}
|
|
36698
|
-
function randomBytes2(size) {
|
|
36699
|
-
const bytes = new Uint8Array(size);
|
|
36700
|
-
getCrypto().getRandomValues(bytes);
|
|
36701
|
-
return bytes;
|
|
36702
|
-
}
|
|
36703
|
-
function padTo(data, blockSize) {
|
|
36704
|
-
const padded = new Uint8Array(Math.ceil(data.length / blockSize) * blockSize);
|
|
36705
|
-
padded.set(data);
|
|
36706
|
-
return padded;
|
|
36707
|
-
}
|
|
36708
|
-
function withSizePrefix(size, body) {
|
|
36709
|
-
const out = new Uint8Array(8 + body.length);
|
|
36710
|
-
const view = new DataView(out.buffer, 0, 8);
|
|
36711
|
-
view.setUint32(0, size % 4294967296, true);
|
|
36712
|
-
view.setUint32(4, Math.floor(size / 4294967296), true);
|
|
36713
|
-
out.set(body, 8);
|
|
36714
|
-
return out;
|
|
36715
|
-
}
|
|
36716
|
-
async function encryptAgilePackage(packageData, key, info) {
|
|
36717
|
-
const { hashAlgorithm, saltValue, blockSize } = info.keyData;
|
|
36718
|
-
const padded = padTo(packageData, SEGMENT_SIZE);
|
|
36719
|
-
const encrypted = withSizePrefix(packageData.length, padded);
|
|
36720
|
-
for (let start = 0; start < padded.length; start += SEGMENT_SIZE) {
|
|
36721
|
-
const iv = await generateIV(
|
|
36722
|
-
hashAlgorithm,
|
|
36723
|
-
saltValue,
|
|
36724
|
-
uint32LE(start / SEGMENT_SIZE),
|
|
36725
|
-
blockSize
|
|
36726
|
-
);
|
|
36727
|
-
const segment = padded.subarray(start, start + SEGMENT_SIZE);
|
|
36728
|
-
encrypted.set(await aesCbcEncryptNoPad(key, iv, segment), 8 + start);
|
|
36729
|
-
}
|
|
36730
|
-
return encrypted;
|
|
36731
|
-
}
|
|
36732
|
-
async function encryptStandardPackage(packageData, key) {
|
|
36733
|
-
const encryptedData = await aesEcbEncrypt(key, packageData);
|
|
36734
|
-
return withSizePrefix(packageData.length, encryptedData);
|
|
36735
|
-
}
|
|
36736
|
-
async function encryptAgile(packageData, password, options = {}) {
|
|
36737
|
-
const keyBits = options.algorithm === "AES128" ? 128 : 256;
|
|
36738
|
-
const hashAlgorithm = "SHA-512";
|
|
36739
|
-
const hashSize = 64;
|
|
36740
|
-
const blockSize = 16;
|
|
36741
|
-
const spinCount = options.spinCount ?? 1e5;
|
|
36742
|
-
const keyDataSalt = randomBytes2(16);
|
|
36743
|
-
const pkeSalt = randomBytes2(16);
|
|
36744
|
-
const documentKey = randomBytes2(keyBits / 8);
|
|
36745
|
-
const verifierHashInput = randomBytes2(16);
|
|
36746
|
-
const verifierHash = await hash(hashAlgorithm, verifierHashInput);
|
|
36747
|
-
const base = await computeAgileKeyBase(password, pkeSalt, spinCount, hashAlgorithm);
|
|
36748
|
-
const encryptUnder = async (block, data) => {
|
|
36749
|
-
const key = await deriveAgileKeyFromBase(base, hashAlgorithm, block, keyBits, hashSize);
|
|
36750
|
-
return aesCbcEncryptNoPad(key, pkeSalt, padTo(data, blockSize));
|
|
36751
|
-
};
|
|
36752
|
-
const passwordKeyEncryptor = {
|
|
36753
|
-
saltSize: 16,
|
|
36754
|
-
blockSize,
|
|
36755
|
-
keyBits,
|
|
36756
|
-
hashSize,
|
|
36757
|
-
cipherAlgorithm: "AES",
|
|
36758
|
-
cipherChaining: "ChainingModeCBC",
|
|
36759
|
-
hashAlgorithm,
|
|
36760
|
-
saltValue: pkeSalt,
|
|
36761
|
-
spinCount,
|
|
36762
|
-
encryptedVerifierHashInput: await encryptUnder(BLOCK_KEYS.verifierHashInput, verifierHashInput),
|
|
36763
|
-
encryptedVerifierHashValue: await encryptUnder(BLOCK_KEYS.verifierHashValue, verifierHash),
|
|
36764
|
-
encryptedKeyValue: await encryptUnder(BLOCK_KEYS.encryptedKeyValue, documentKey)
|
|
36765
|
-
};
|
|
36766
|
-
const keyData = {
|
|
36767
|
-
saltSize: 16,
|
|
36768
|
-
blockSize,
|
|
36769
|
-
keyBits,
|
|
36770
|
-
hashSize,
|
|
36771
|
-
cipherAlgorithm: "AES",
|
|
36772
|
-
cipherChaining: "ChainingModeCBC",
|
|
36773
|
-
hashAlgorithm,
|
|
36774
|
-
saltValue: keyDataSalt
|
|
36775
|
-
};
|
|
36776
|
-
const info = {
|
|
36777
|
-
keyData};
|
|
36778
|
-
const encryptedPackage = await encryptAgilePackage(packageData, documentKey, info);
|
|
36779
|
-
const hmacKey = randomBytes2(hashSize);
|
|
36780
|
-
const hmacValue = await hmac(hashAlgorithm, hmacKey, encryptedPackage);
|
|
36781
|
-
const encryptIntegrity = async (block, data) => {
|
|
36782
|
-
const iv = await generateIV(hashAlgorithm, keyDataSalt, block, blockSize);
|
|
36783
|
-
return aesCbcEncryptNoPad(documentKey, iv, padTo(data, blockSize));
|
|
36784
|
-
};
|
|
36785
|
-
const dataIntegrity = {
|
|
36786
|
-
encryptedHmacKey: await encryptIntegrity(BLOCK_KEYS.dataIntegrityHmacKey, hmacKey),
|
|
36787
|
-
encryptedHmacValue: await encryptIntegrity(BLOCK_KEYS.dataIntegrityHmacValue, hmacValue)
|
|
36788
|
-
};
|
|
36789
|
-
const xml = buildAgileEncryptionInfoXml(keyData, passwordKeyEncryptor, dataIntegrity);
|
|
36790
|
-
return container(buildEncryptionInfoStream(xml), encryptedPackage);
|
|
36791
|
-
}
|
|
36792
|
-
async function encryptStandard(packageData, password, options = {}) {
|
|
36793
|
-
const keyBits = options.algorithm === "AES128" ? 128 : 256;
|
|
36794
|
-
const salt = randomBytes2(16);
|
|
36795
|
-
const key = await deriveStandardKey(password, salt, keyBits);
|
|
36796
|
-
const verifier = randomBytes2(16);
|
|
36797
|
-
const paddedVerifierHash = new Uint8Array(32);
|
|
36798
|
-
paddedVerifierHash.set((await hash("SHA-1", verifier)).subarray(0, 20));
|
|
36799
|
-
const encryptionInfo = buildStandardEncryptionInfoStream(
|
|
36800
|
-
keyBits,
|
|
36801
|
-
salt,
|
|
36802
|
-
await aesEcbEncrypt(key, verifier),
|
|
36803
|
-
await aesEcbEncrypt(key, paddedVerifierHash)
|
|
36804
|
-
);
|
|
36805
|
-
return container(encryptionInfo, await encryptStandardPackage(packageData, key));
|
|
36806
|
-
}
|
|
36807
|
-
|
|
36808
|
-
// crypto/encryption-info.ts
|
|
36809
|
-
var RC4_ALG_ID = 26625;
|
|
36810
|
-
function parseEncryptionInfo(data) {
|
|
36811
|
-
if (data.byteLength < 8) throw new Error("The EncryptionInfo stream is truncated.");
|
|
36812
|
-
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
36813
|
-
const versionMajor = view.getUint16(0, true);
|
|
36814
|
-
const versionMinor = view.getUint16(2, true);
|
|
36815
|
-
if (versionMajor === 4 && versionMinor === 4) return parseAgileEncryptionInfo(data);
|
|
36816
|
-
if ((versionMajor === 2 || versionMajor === 3 || versionMajor === 4) && versionMinor === 2) {
|
|
36817
|
-
return parseStandardEncryptionInfo(data);
|
|
36818
|
-
}
|
|
36819
|
-
throw new Error(
|
|
36820
|
-
`Unsupported encryption version: ${versionMajor}.${versionMinor}. Only Standard (2.2-4.2) and Agile (4.4) encryption are supported.`
|
|
36821
|
-
);
|
|
36822
|
-
}
|
|
36823
|
-
function parseStandardEncryptionInfo(data) {
|
|
36824
|
-
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
36825
|
-
const versionMajor = view.getUint16(0, true);
|
|
36826
|
-
const versionMinor = view.getUint16(2, true);
|
|
36827
|
-
const flags = view.getUint32(4, true);
|
|
36828
|
-
const headerSize = view.getUint32(8, true);
|
|
36829
|
-
const headerOffset = 12;
|
|
36830
|
-
const hFlags = view.getUint32(headerOffset, true);
|
|
36831
|
-
const algId = view.getUint32(headerOffset + 8, true);
|
|
36832
|
-
const algIdHash = view.getUint32(headerOffset + 12, true);
|
|
36833
|
-
const keySize = view.getUint32(headerOffset + 16, true);
|
|
36834
|
-
const providerType = view.getUint32(headerOffset + 20, true);
|
|
36835
|
-
let cspName = "";
|
|
36836
|
-
const cspEnd = headerOffset + headerSize;
|
|
36837
|
-
for (let i2 = headerOffset + 32; i2 < cspEnd - 1; i2 += 2) {
|
|
36838
|
-
const ch = view.getUint16(i2, true);
|
|
36839
|
-
if (ch === 0) break;
|
|
36840
|
-
cspName += String.fromCharCode(ch);
|
|
36841
|
-
}
|
|
36842
|
-
const verifierOffset = 12 + headerSize;
|
|
36843
|
-
const saltSize = view.getUint32(verifierOffset, true);
|
|
36844
|
-
const salt = new Uint8Array(data.buffer, data.byteOffset + verifierOffset + 4, 16);
|
|
36845
|
-
const encryptedVerifier = new Uint8Array(data.buffer, data.byteOffset + verifierOffset + 20, 16);
|
|
36846
|
-
const verifierHashSize = view.getUint32(verifierOffset + 36, true);
|
|
36847
|
-
const encryptedVerifierHashLength = algId === RC4_ALG_ID ? verifierHashSize : Math.ceil(verifierHashSize / 16) * 16;
|
|
36848
|
-
const encryptedVerifierHash = new Uint8Array(
|
|
36849
|
-
data.buffer,
|
|
36850
|
-
data.byteOffset + verifierOffset + 40,
|
|
36851
|
-
encryptedVerifierHashLength
|
|
36852
|
-
);
|
|
36853
|
-
return {
|
|
36854
|
-
version: { major: versionMajor, minor: versionMinor },
|
|
36855
|
-
isAgile: false,
|
|
36856
|
-
isStandard: true,
|
|
36857
|
-
flags,
|
|
36858
|
-
headerSize,
|
|
36859
|
-
header: { flags: hFlags, algId, algIdHash, keySize, providerType, cspName },
|
|
36860
|
-
verifier: {
|
|
36861
|
-
saltSize,
|
|
36862
|
-
salt: new Uint8Array(salt),
|
|
36863
|
-
encryptedVerifier: new Uint8Array(encryptedVerifier),
|
|
36864
|
-
verifierHashSize,
|
|
36865
|
-
encryptedVerifierHash: new Uint8Array(encryptedVerifierHash)
|
|
36866
|
-
}
|
|
36867
|
-
};
|
|
36868
|
-
}
|
|
36869
|
-
function tagAttribute(xml, tag, attr) {
|
|
36870
|
-
const tagMatch = xml.match(new RegExp(`<[^>]*${tag}[^>]*>`, "i"));
|
|
36871
|
-
if (!tagMatch) return "";
|
|
36872
|
-
const attrMatch = tagMatch[0].match(new RegExp(`\\b${attr}="([^"]*)"`, "i"));
|
|
36873
|
-
return attrMatch?.[1] ?? "";
|
|
36874
|
-
}
|
|
36875
|
-
function parseAgileEncryptionInfo(data) {
|
|
36876
|
-
const xml = new TextDecoder("utf-8").decode(data.subarray(8));
|
|
36877
|
-
const keyData = (attr) => tagAttribute(xml, "keyData", attr);
|
|
36878
|
-
const integrity = (attr) => tagAttribute(xml, "dataIntegrity", attr);
|
|
36879
|
-
const pke = (attr) => tagAttribute(xml, "encryptedKey", attr);
|
|
36880
|
-
const int = (value) => parseInt(value, 10);
|
|
36881
|
-
const encryptedHmacKey = integrity("encryptedHmacKey");
|
|
36882
|
-
return {
|
|
36883
|
-
version: { major: 4, minor: 4 },
|
|
36884
|
-
isAgile: true,
|
|
36885
|
-
keyData: {
|
|
36886
|
-
saltSize: int(keyData("saltSize")),
|
|
36887
|
-
blockSize: int(keyData("blockSize")),
|
|
36888
|
-
keyBits: int(keyData("keyBits")),
|
|
36889
|
-
hashSize: int(keyData("hashSize")),
|
|
36890
|
-
cipherAlgorithm: keyData("cipherAlgorithm"),
|
|
36891
|
-
cipherChaining: keyData("cipherChaining"),
|
|
36892
|
-
hashAlgorithm: keyData("hashAlgorithm"),
|
|
36893
|
-
saltValue: base64Decode(keyData("saltValue"))
|
|
36894
|
-
},
|
|
36895
|
-
...encryptedHmacKey ? {
|
|
36896
|
-
dataIntegrity: {
|
|
36897
|
-
encryptedHmacKey: base64Decode(encryptedHmacKey),
|
|
36898
|
-
encryptedHmacValue: base64Decode(integrity("encryptedHmacValue"))
|
|
36899
|
-
}
|
|
36900
|
-
} : {},
|
|
36901
|
-
passwordKeyEncryptor: {
|
|
36902
|
-
saltSize: int(pke("saltSize")),
|
|
36903
|
-
blockSize: int(pke("blockSize")),
|
|
36904
|
-
keyBits: int(pke("keyBits")),
|
|
36905
|
-
hashSize: int(pke("hashSize")),
|
|
36906
|
-
cipherAlgorithm: pke("cipherAlgorithm"),
|
|
36907
|
-
cipherChaining: pke("cipherChaining"),
|
|
36908
|
-
hashAlgorithm: pke("hashAlgorithm"),
|
|
36909
|
-
saltValue: base64Decode(pke("saltValue")),
|
|
36910
|
-
spinCount: int(pke("spinCount")),
|
|
36911
|
-
encryptedVerifierHashInput: base64Decode(pke("encryptedVerifierHashInput")),
|
|
36912
|
-
encryptedVerifierHashValue: base64Decode(pke("encryptedVerifierHashValue")),
|
|
36913
|
-
encryptedKeyValue: base64Decode(pke("encryptedKeyValue"))
|
|
36914
|
-
}
|
|
36915
|
-
};
|
|
36916
|
-
}
|
|
36917
|
-
|
|
36918
|
-
// crypto/index.ts
|
|
36919
|
-
var isStandard = (info) => "isStandard" in info && info.isStandard;
|
|
36920
|
-
function streams(bytes) {
|
|
36921
|
-
const opened = openEncryptedPackage(bytes);
|
|
36922
|
-
if (opened) return { info: opened.encryptionInfo, data: opened.encryptedPackage };
|
|
36923
|
-
const file = parseOle2(toArrayBuffer(bytes));
|
|
36924
|
-
if (!file.getStream("EncryptionInfo")) {
|
|
36925
|
-
throw new Error(
|
|
36926
|
-
"EncryptionInfo stream not found. The file may not be an encrypted OOXML package."
|
|
36927
|
-
);
|
|
36928
|
-
}
|
|
36929
|
-
throw new Error("EncryptedPackage stream not found. The file may be corrupted.");
|
|
36930
|
-
}
|
|
36931
|
-
async function decryptOoxmlPackage(input, password) {
|
|
36932
|
-
const { info: infoStream, data } = streams(toBytes(input));
|
|
36933
|
-
const info = parseEncryptionInfo(infoStream);
|
|
36934
|
-
if (isStandard(info)) {
|
|
36935
|
-
const key2 = await verifyStandardPassword(info, password);
|
|
36936
|
-
if (!key2) throw new IncorrectPasswordError();
|
|
36937
|
-
return new Uint8Array(await decryptStandardPackage(data, key2));
|
|
36938
|
-
}
|
|
36939
|
-
const key = await verifyAgilePassword(info, password);
|
|
36940
|
-
if (!key) throw new IncorrectPasswordError();
|
|
36941
|
-
await verifyAgileDataIntegrity(info, key, data);
|
|
36942
|
-
return new Uint8Array(await decryptAgilePackage(data, key, info));
|
|
36943
|
-
}
|
|
36944
|
-
function encryptOoxmlPackage(input, password, options = {}) {
|
|
36945
|
-
const bytes = toBytes(input);
|
|
36946
|
-
return options.encryptionScheme === "standard" ? encryptStandard(bytes, password, options) : encryptAgile(bytes, password, options);
|
|
36947
|
-
}
|
|
36948
|
-
async function verifyOoxmlPackagePassword(input, password) {
|
|
36949
|
-
try {
|
|
36950
|
-
const opened = openEncryptedPackage(input);
|
|
36951
|
-
if (!opened) return false;
|
|
36952
|
-
const info = parseEncryptionInfo(opened.encryptionInfo);
|
|
36953
|
-
const key = isStandard(info) ? await verifyStandardPassword(info, password) : await verifyAgilePassword(info, password);
|
|
36954
|
-
return key !== null;
|
|
36955
|
-
} catch {
|
|
36956
|
-
return false;
|
|
36957
|
-
}
|
|
36958
|
-
}
|
|
36959
|
-
|
|
36960
|
-
// pptx/core/utils/ooxml-crypto.ts
|
|
36961
|
-
async function decryptPptx(encryptedBuffer, password) {
|
|
36962
|
-
return (await decryptOoxmlPackage(encryptedBuffer, password)).buffer;
|
|
36963
|
-
}
|
|
36964
|
-
async function encryptPptx(pptxBuffer, password, options) {
|
|
36965
|
-
return (await encryptOoxmlPackage(pptxBuffer, password, options)).buffer;
|
|
36966
|
-
}
|
|
36967
|
-
function verifyPassword(encryptedBuffer, password) {
|
|
36968
|
-
return verifyOoxmlPackagePassword(encryptedBuffer, password);
|
|
36969
|
-
}
|
|
36970
|
-
|
|
36971
|
-
// pptx/core/utils/digests/algorithm-names.ts
|
|
36972
|
-
var CANONICAL_BY_LOOKUP_KEY2 = {
|
|
36973
|
-
SHA1: "SHA-1",
|
|
36974
|
-
SHA256: "SHA-256",
|
|
36975
|
-
SHA384: "SHA-384",
|
|
36976
|
-
SHA512: "SHA-512",
|
|
36977
|
-
MD2: "MD2",
|
|
36978
|
-
MD4: "MD4",
|
|
36979
|
-
MD5: "MD5",
|
|
36980
|
-
RIPEMD128: "RIPEMD-128",
|
|
36981
|
-
RIPEMD160: "RIPEMD-160",
|
|
36982
|
-
WHIRLPOOL: "WHIRLPOOL"
|
|
36983
|
-
};
|
|
36984
|
-
function normalizeDigestAlgorithmName2(name) {
|
|
36985
|
-
const key = name.toUpperCase().replace(/[-_\s]/g, "");
|
|
36986
|
-
return CANONICAL_BY_LOOKUP_KEY2[key];
|
|
36987
|
-
}
|
|
36988
|
-
var WEB_CRYPTO_ALGORITHMS = /* @__PURE__ */ new Set([
|
|
36989
|
-
"SHA-1",
|
|
36990
|
-
"SHA-256",
|
|
36991
|
-
"SHA-384",
|
|
36992
|
-
"SHA-512"
|
|
36993
|
-
]);
|
|
36994
|
-
|
|
36995
|
-
// pptx/core/utils/digests/md2.ts
|
|
35941
|
+
// digest/md2.ts
|
|
36996
35942
|
var S = [
|
|
36997
35943
|
41,
|
|
36998
35944
|
46,
|
|
@@ -37259,17 +36205,17 @@ function transform(state, checksum, block) {
|
|
|
37259
36205
|
x[32 + k] = state[k] ^ block[k];
|
|
37260
36206
|
}
|
|
37261
36207
|
let t = 0;
|
|
37262
|
-
for (let
|
|
36208
|
+
for (let round2 = 0; round2 < 18; round2++) {
|
|
37263
36209
|
for (let k = 0; k < 48; k++) {
|
|
37264
|
-
x[k]
|
|
36210
|
+
x[k] = x[k] ^ S[t];
|
|
37265
36211
|
t = x[k];
|
|
37266
36212
|
}
|
|
37267
|
-
t = t +
|
|
36213
|
+
t = t + round2 & 255;
|
|
37268
36214
|
}
|
|
37269
36215
|
state.set(x.subarray(0, 16));
|
|
37270
36216
|
t = checksum[15];
|
|
37271
36217
|
for (let k = 0; k < 16; k++) {
|
|
37272
|
-
checksum[k]
|
|
36218
|
+
checksum[k] = checksum[k] ^ S[block[k] ^ t];
|
|
37273
36219
|
t = checksum[k];
|
|
37274
36220
|
}
|
|
37275
36221
|
}
|
|
@@ -37287,44 +36233,33 @@ function md2(message) {
|
|
|
37287
36233
|
return state;
|
|
37288
36234
|
}
|
|
37289
36235
|
|
|
37290
|
-
//
|
|
36236
|
+
// digest/bit-ops.ts
|
|
37291
36237
|
function rotl32(x, n) {
|
|
37292
36238
|
return (x << n | x >>> 32 - n) >>> 0;
|
|
37293
36239
|
}
|
|
37294
36240
|
function add32(...values) {
|
|
37295
36241
|
let sum = 0;
|
|
37296
|
-
for (const value of values)
|
|
37297
|
-
sum = sum + value >>> 0;
|
|
37298
|
-
}
|
|
36242
|
+
for (const value of values) sum = sum + value >>> 0;
|
|
37299
36243
|
return sum;
|
|
37300
36244
|
}
|
|
37301
36245
|
function padMd4Style(message) {
|
|
37302
|
-
const bitLength = BigInt(message.length) * 8n;
|
|
37303
36246
|
const paddedLength = message.length + 9 + 63 & -64;
|
|
37304
36247
|
const padded = new Uint8Array(paddedLength);
|
|
37305
36248
|
padded.set(message);
|
|
37306
36249
|
padded[message.length] = 128;
|
|
37307
|
-
new DataView(padded.buffer).setBigUint64(paddedLength - 8,
|
|
36250
|
+
new DataView(padded.buffer).setBigUint64(paddedLength - 8, BigInt(message.length) * 8n, true);
|
|
37308
36251
|
return padded;
|
|
37309
36252
|
}
|
|
37310
|
-
function applyRotatingRound(r, ops, f6, x) {
|
|
36253
|
+
function applyRotatingRound(r, ops, f6, x, feedback = false) {
|
|
37311
36254
|
let target = 0;
|
|
37312
36255
|
for (const [k, s, addConst] of ops) {
|
|
37313
36256
|
const i1 = target + 1 & 3;
|
|
37314
|
-
const
|
|
37315
|
-
const
|
|
37316
|
-
|
|
37317
|
-
|
|
37318
|
-
|
|
37319
|
-
|
|
37320
|
-
function applyRotatingRoundWithFeedback(r, ops, f6, x) {
|
|
37321
|
-
let target = 0;
|
|
37322
|
-
for (const [k, s, addConst] of ops) {
|
|
37323
|
-
const i1 = target + 1 & 3;
|
|
37324
|
-
const i2 = target + 2 & 3;
|
|
37325
|
-
const i3 = target + 3 & 3;
|
|
37326
|
-
const rotated = rotl32(add32(r[target], f6(r[i1], r[i2], r[i3]), x[k], addConst), s);
|
|
37327
|
-
r[target] = add32(r[i1], rotated);
|
|
36257
|
+
const next = r[i1];
|
|
36258
|
+
const rotated = rotl32(
|
|
36259
|
+
add32(r[target], f6(next, r[target + 2 & 3], r[target + 3 & 3]), x[k], addConst),
|
|
36260
|
+
s
|
|
36261
|
+
);
|
|
36262
|
+
r[target] = feedback ? add32(next, rotated) : rotated;
|
|
37328
36263
|
target = target + 3 & 3;
|
|
37329
36264
|
}
|
|
37330
36265
|
}
|
|
@@ -37332,102 +36267,45 @@ function mdStyleDigest(message, initialState, transform6) {
|
|
|
37332
36267
|
const padded = padMd4Style(message);
|
|
37333
36268
|
const view = new DataView(padded.buffer);
|
|
37334
36269
|
const state = [...initialState];
|
|
37335
|
-
const
|
|
37336
|
-
for (let
|
|
37337
|
-
for (let i2 = 0; i2 < 16; i2++)
|
|
37338
|
-
|
|
37339
|
-
}
|
|
37340
|
-
transform6(state, words);
|
|
36270
|
+
const words2 = new Array(16).fill(0);
|
|
36271
|
+
for (let offset = 0; offset < padded.length; offset += 64) {
|
|
36272
|
+
for (let i2 = 0; i2 < 16; i2++) words2[i2] = view.getUint32(offset + i2 * 4, true);
|
|
36273
|
+
transform6(state, words2);
|
|
37341
36274
|
}
|
|
37342
36275
|
const out = new Uint8Array(state.length * 4);
|
|
37343
36276
|
const outView = new DataView(out.buffer);
|
|
37344
|
-
for (let i2 = 0; i2 < state.length; i2++)
|
|
37345
|
-
outView.setUint32(i2 * 4, state[i2], true);
|
|
37346
|
-
}
|
|
36277
|
+
for (let i2 = 0; i2 < state.length; i2++) outView.setUint32(i2 * 4, state[i2], true);
|
|
37347
36278
|
return out;
|
|
37348
36279
|
}
|
|
37349
36280
|
|
|
37350
|
-
//
|
|
36281
|
+
// digest/md4.ts
|
|
37351
36282
|
var INITIAL_STATE = [1732584193, 4023233417, 2562383102, 271733878];
|
|
37352
|
-
|
|
37353
|
-
return x & y | ~x & z;
|
|
37354
|
-
}
|
|
37355
|
-
function f2(x, y, z) {
|
|
37356
|
-
return x & y | x & z | y & z;
|
|
37357
|
-
}
|
|
37358
|
-
function f3(x, y, z) {
|
|
37359
|
-
return x ^ y ^ z;
|
|
37360
|
-
}
|
|
37361
|
-
var K22 = 1518500249;
|
|
36283
|
+
var K2 = 1518500249;
|
|
37362
36284
|
var K3 = 1859775393;
|
|
37363
|
-
var
|
|
37364
|
-
|
|
37365
|
-
|
|
37366
|
-
|
|
37367
|
-
[
|
|
37368
|
-
|
|
37369
|
-
|
|
37370
|
-
|
|
37371
|
-
|
|
37372
|
-
|
|
37373
|
-
|
|
37374
|
-
|
|
37375
|
-
[11, 19, 0],
|
|
37376
|
-
[12, 3, 0],
|
|
37377
|
-
[13, 7, 0],
|
|
37378
|
-
[14, 11, 0],
|
|
37379
|
-
[15, 19, 0]
|
|
37380
|
-
];
|
|
37381
|
-
var ROUND2 = [
|
|
37382
|
-
[0, 3, K22],
|
|
37383
|
-
[4, 5, K22],
|
|
37384
|
-
[8, 9, K22],
|
|
37385
|
-
[12, 13, K22],
|
|
37386
|
-
[1, 3, K22],
|
|
37387
|
-
[5, 5, K22],
|
|
37388
|
-
[9, 9, K22],
|
|
37389
|
-
[13, 13, K22],
|
|
37390
|
-
[2, 3, K22],
|
|
37391
|
-
[6, 5, K22],
|
|
37392
|
-
[10, 9, K22],
|
|
37393
|
-
[14, 13, K22],
|
|
37394
|
-
[3, 3, K22],
|
|
37395
|
-
[7, 5, K22],
|
|
37396
|
-
[11, 9, K22],
|
|
37397
|
-
[15, 13, K22]
|
|
37398
|
-
];
|
|
37399
|
-
var ROUND3 = [
|
|
37400
|
-
[0, 3, K3],
|
|
37401
|
-
[8, 9, K3],
|
|
37402
|
-
[4, 11, K3],
|
|
37403
|
-
[12, 15, K3],
|
|
37404
|
-
[2, 3, K3],
|
|
37405
|
-
[10, 9, K3],
|
|
37406
|
-
[6, 11, K3],
|
|
37407
|
-
[14, 15, K3],
|
|
37408
|
-
[1, 3, K3],
|
|
37409
|
-
[9, 9, K3],
|
|
37410
|
-
[5, 11, K3],
|
|
37411
|
-
[13, 15, K3],
|
|
37412
|
-
[3, 3, K3],
|
|
37413
|
-
[11, 9, K3],
|
|
37414
|
-
[7, 11, K3],
|
|
37415
|
-
[15, 15, K3]
|
|
37416
|
-
];
|
|
36285
|
+
var f1 = (x, y, z) => x & y | ~x & z;
|
|
36286
|
+
var f2 = (x, y, z) => x & y | x & z | y & z;
|
|
36287
|
+
var f3 = (x, y, z) => x ^ y ^ z;
|
|
36288
|
+
function round(order, shifts, k) {
|
|
36289
|
+
return order.map((word, i2) => [word, shifts[i2 % 4], k]);
|
|
36290
|
+
}
|
|
36291
|
+
var SEQUENTIAL = Array.from({ length: 16 }, (_, i2) => i2);
|
|
36292
|
+
var COLUMNS = Array.from({ length: 16 }, (_, i2) => i2 % 4 * 4 + (i2 >> 2));
|
|
36293
|
+
var BIT_REVERSED = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15];
|
|
36294
|
+
var ROUND1 = round(SEQUENTIAL, [3, 7, 11, 19], 0);
|
|
36295
|
+
var ROUND2 = round(COLUMNS, [3, 5, 9, 13], K2);
|
|
36296
|
+
var ROUND3 = round(BIT_REVERSED, [3, 9, 11, 15], K3);
|
|
37417
36297
|
function transform2(state, x) {
|
|
37418
36298
|
const r = [...state];
|
|
37419
36299
|
applyRotatingRound(r, ROUND1, f1, x);
|
|
37420
36300
|
applyRotatingRound(r, ROUND2, f2, x);
|
|
37421
36301
|
applyRotatingRound(r, ROUND3, f3, x);
|
|
37422
|
-
for (let i2 = 0; i2 < 4; i2++)
|
|
37423
|
-
state[i2] = add32(state[i2], r[i2]);
|
|
37424
|
-
}
|
|
36302
|
+
for (let i2 = 0; i2 < 4; i2++) state[i2] = add32(state[i2], r[i2]);
|
|
37425
36303
|
}
|
|
37426
36304
|
function md4(message) {
|
|
37427
36305
|
return mdStyleDigest(message, INITIAL_STATE, transform2);
|
|
37428
36306
|
}
|
|
37429
36307
|
|
|
37430
|
-
//
|
|
36308
|
+
// digest/md5.ts
|
|
37431
36309
|
var INITIAL_STATE2 = [1732584193, 4023233417, 2562383102, 271733878];
|
|
37432
36310
|
function f(x, y, z) {
|
|
37433
36311
|
return x & y | ~x & z;
|
|
@@ -37458,19 +36336,19 @@ var WORD_INDEX = [
|
|
|
37458
36336
|
(idx) => 7 * idx % 16
|
|
37459
36337
|
];
|
|
37460
36338
|
var ROUND_FNS = [f, g, h, i];
|
|
37461
|
-
function buildOps(
|
|
37462
|
-
const shifts = SHIFTS[
|
|
37463
|
-
const wordIndex = WORD_INDEX[
|
|
36339
|
+
function buildOps(round2) {
|
|
36340
|
+
const shifts = SHIFTS[round2];
|
|
36341
|
+
const wordIndex = WORD_INDEX[round2];
|
|
37464
36342
|
return Array.from({ length: 16 }, (_, idx) => {
|
|
37465
|
-
const opNumber =
|
|
36343
|
+
const opNumber = round2 * 16 + idx;
|
|
37466
36344
|
return [wordIndex(idx), shifts[idx % 4], T[opNumber]];
|
|
37467
36345
|
});
|
|
37468
36346
|
}
|
|
37469
36347
|
var ROUNDS = [0, 1, 2, 3].map(buildOps);
|
|
37470
36348
|
function transform3(state, x) {
|
|
37471
36349
|
const r = [...state];
|
|
37472
|
-
for (let
|
|
37473
|
-
|
|
36350
|
+
for (let round2 = 0; round2 < 4; round2++) {
|
|
36351
|
+
applyRotatingRound(r, ROUNDS[round2], ROUND_FNS[round2], x, true);
|
|
37474
36352
|
}
|
|
37475
36353
|
for (let idx = 0; idx < 4; idx++) {
|
|
37476
36354
|
state[idx] = add32(state[idx], r[idx]);
|
|
@@ -37480,7 +36358,7 @@ function md5(message) {
|
|
|
37480
36358
|
return mdStyleDigest(message, INITIAL_STATE2, transform3);
|
|
37481
36359
|
}
|
|
37482
36360
|
|
|
37483
|
-
//
|
|
36361
|
+
// digest/ripemd-functions.ts
|
|
37484
36362
|
function f12(x, y, z) {
|
|
37485
36363
|
return x ^ y ^ z;
|
|
37486
36364
|
}
|
|
@@ -37497,7 +36375,7 @@ function f5(x, y, z) {
|
|
|
37497
36375
|
return x ^ (y | ~z);
|
|
37498
36376
|
}
|
|
37499
36377
|
|
|
37500
|
-
//
|
|
36378
|
+
// digest/ripemd128.ts
|
|
37501
36379
|
var INITIAL_STATE3 = [1732584193, 4023233417, 2562383102, 271733878];
|
|
37502
36380
|
var LEFT_ROUNDS = [
|
|
37503
36381
|
[
|
|
@@ -37652,9 +36530,9 @@ var RIGHT_FNS = [f4, f32, f22, f12];
|
|
|
37652
36530
|
function transform4(state, x) {
|
|
37653
36531
|
const left = [...state];
|
|
37654
36532
|
const right = [...state];
|
|
37655
|
-
for (let
|
|
37656
|
-
applyRotatingRound(left, LEFT_ROUNDS[
|
|
37657
|
-
applyRotatingRound(right, RIGHT_ROUNDS[
|
|
36533
|
+
for (let round2 = 0; round2 < 4; round2++) {
|
|
36534
|
+
applyRotatingRound(left, LEFT_ROUNDS[round2], LEFT_FNS[round2], x);
|
|
36535
|
+
applyRotatingRound(right, RIGHT_ROUNDS[round2], RIGHT_FNS[round2], x);
|
|
37658
36536
|
}
|
|
37659
36537
|
const orig = state;
|
|
37660
36538
|
const newState = [
|
|
@@ -37671,7 +36549,7 @@ function ripemd128(message) {
|
|
|
37671
36549
|
return mdStyleDigest(message, INITIAL_STATE3, transform4);
|
|
37672
36550
|
}
|
|
37673
36551
|
|
|
37674
|
-
//
|
|
36552
|
+
// digest/ripemd160.ts
|
|
37675
36553
|
var INITIAL_STATE4 = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
|
|
37676
36554
|
var LEFT_ROUNDS2 = [
|
|
37677
36555
|
[
|
|
@@ -37765,143 +36643,610 @@ var LEFT_ROUNDS2 = [
|
|
|
37765
36643
|
[13, 6, 2840853838]
|
|
37766
36644
|
]
|
|
37767
36645
|
];
|
|
37768
|
-
var RIGHT_ROUNDS2 = [
|
|
37769
|
-
[
|
|
37770
|
-
[5, 8, 1352829926],
|
|
37771
|
-
[14, 9, 1352829926],
|
|
37772
|
-
[7, 9, 1352829926],
|
|
37773
|
-
[0, 11, 1352829926],
|
|
37774
|
-
[9, 13, 1352829926],
|
|
37775
|
-
[2, 15, 1352829926],
|
|
37776
|
-
[11, 15, 1352829926],
|
|
37777
|
-
[4, 5, 1352829926],
|
|
37778
|
-
[13, 7, 1352829926],
|
|
37779
|
-
[6, 7, 1352829926],
|
|
37780
|
-
[15, 8, 1352829926],
|
|
37781
|
-
[8, 11, 1352829926],
|
|
37782
|
-
[1, 14, 1352829926],
|
|
37783
|
-
[10, 14, 1352829926],
|
|
37784
|
-
[3, 12, 1352829926],
|
|
37785
|
-
[12, 6, 1352829926]
|
|
37786
|
-
],
|
|
37787
|
-
[
|
|
37788
|
-
[6, 9, 1548603684],
|
|
37789
|
-
[11, 13, 1548603684],
|
|
37790
|
-
[3, 15, 1548603684],
|
|
37791
|
-
[7, 7, 1548603684],
|
|
37792
|
-
[0, 12, 1548603684],
|
|
37793
|
-
[13, 8, 1548603684],
|
|
37794
|
-
[5, 9, 1548603684],
|
|
37795
|
-
[10, 11, 1548603684],
|
|
37796
|
-
[14, 7, 1548603684],
|
|
37797
|
-
[15, 7, 1548603684],
|
|
37798
|
-
[8, 12, 1548603684],
|
|
37799
|
-
[12, 7, 1548603684],
|
|
37800
|
-
[4, 6, 1548603684],
|
|
37801
|
-
[9, 15, 1548603684],
|
|
37802
|
-
[1, 13, 1548603684],
|
|
37803
|
-
[2, 11, 1548603684]
|
|
37804
|
-
],
|
|
37805
|
-
[
|
|
37806
|
-
[15, 9, 1836072691],
|
|
37807
|
-
[5, 7, 1836072691],
|
|
37808
|
-
[1, 15, 1836072691],
|
|
37809
|
-
[3, 11, 1836072691],
|
|
37810
|
-
[7, 8, 1836072691],
|
|
37811
|
-
[14, 6, 1836072691],
|
|
37812
|
-
[6, 6, 1836072691],
|
|
37813
|
-
[9, 14, 1836072691],
|
|
37814
|
-
[11, 12, 1836072691],
|
|
37815
|
-
[8, 13, 1836072691],
|
|
37816
|
-
[12, 5, 1836072691],
|
|
37817
|
-
[2, 14, 1836072691],
|
|
37818
|
-
[10, 13, 1836072691],
|
|
37819
|
-
[0, 13, 1836072691],
|
|
37820
|
-
[4, 7, 1836072691],
|
|
37821
|
-
[13, 5, 1836072691]
|
|
37822
|
-
],
|
|
37823
|
-
[
|
|
37824
|
-
[8, 15, 2053994217],
|
|
37825
|
-
[6, 5, 2053994217],
|
|
37826
|
-
[4, 8, 2053994217],
|
|
37827
|
-
[1, 11, 2053994217],
|
|
37828
|
-
[3, 14, 2053994217],
|
|
37829
|
-
[11, 14, 2053994217],
|
|
37830
|
-
[15, 6, 2053994217],
|
|
37831
|
-
[0, 14, 2053994217],
|
|
37832
|
-
[5, 6, 2053994217],
|
|
37833
|
-
[12, 9, 2053994217],
|
|
37834
|
-
[2, 12, 2053994217],
|
|
37835
|
-
[13, 9, 2053994217],
|
|
37836
|
-
[9, 12, 2053994217],
|
|
37837
|
-
[7, 5, 2053994217],
|
|
37838
|
-
[10, 15, 2053994217],
|
|
37839
|
-
[14, 8, 2053994217]
|
|
37840
|
-
],
|
|
37841
|
-
[
|
|
37842
|
-
[12, 8, 0],
|
|
37843
|
-
[15, 5, 0],
|
|
37844
|
-
[10, 12, 0],
|
|
37845
|
-
[4, 9, 0],
|
|
37846
|
-
[1, 12, 0],
|
|
37847
|
-
[5, 5, 0],
|
|
37848
|
-
[8, 14, 0],
|
|
37849
|
-
[7, 6, 0],
|
|
37850
|
-
[6, 8, 0],
|
|
37851
|
-
[2, 13, 0],
|
|
37852
|
-
[13, 6, 0],
|
|
37853
|
-
[14, 5, 0],
|
|
37854
|
-
[0, 15, 0],
|
|
37855
|
-
[3, 13, 0],
|
|
37856
|
-
[9, 11, 0],
|
|
37857
|
-
[11, 11, 0]
|
|
37858
|
-
]
|
|
36646
|
+
var RIGHT_ROUNDS2 = [
|
|
36647
|
+
[
|
|
36648
|
+
[5, 8, 1352829926],
|
|
36649
|
+
[14, 9, 1352829926],
|
|
36650
|
+
[7, 9, 1352829926],
|
|
36651
|
+
[0, 11, 1352829926],
|
|
36652
|
+
[9, 13, 1352829926],
|
|
36653
|
+
[2, 15, 1352829926],
|
|
36654
|
+
[11, 15, 1352829926],
|
|
36655
|
+
[4, 5, 1352829926],
|
|
36656
|
+
[13, 7, 1352829926],
|
|
36657
|
+
[6, 7, 1352829926],
|
|
36658
|
+
[15, 8, 1352829926],
|
|
36659
|
+
[8, 11, 1352829926],
|
|
36660
|
+
[1, 14, 1352829926],
|
|
36661
|
+
[10, 14, 1352829926],
|
|
36662
|
+
[3, 12, 1352829926],
|
|
36663
|
+
[12, 6, 1352829926]
|
|
36664
|
+
],
|
|
36665
|
+
[
|
|
36666
|
+
[6, 9, 1548603684],
|
|
36667
|
+
[11, 13, 1548603684],
|
|
36668
|
+
[3, 15, 1548603684],
|
|
36669
|
+
[7, 7, 1548603684],
|
|
36670
|
+
[0, 12, 1548603684],
|
|
36671
|
+
[13, 8, 1548603684],
|
|
36672
|
+
[5, 9, 1548603684],
|
|
36673
|
+
[10, 11, 1548603684],
|
|
36674
|
+
[14, 7, 1548603684],
|
|
36675
|
+
[15, 7, 1548603684],
|
|
36676
|
+
[8, 12, 1548603684],
|
|
36677
|
+
[12, 7, 1548603684],
|
|
36678
|
+
[4, 6, 1548603684],
|
|
36679
|
+
[9, 15, 1548603684],
|
|
36680
|
+
[1, 13, 1548603684],
|
|
36681
|
+
[2, 11, 1548603684]
|
|
36682
|
+
],
|
|
36683
|
+
[
|
|
36684
|
+
[15, 9, 1836072691],
|
|
36685
|
+
[5, 7, 1836072691],
|
|
36686
|
+
[1, 15, 1836072691],
|
|
36687
|
+
[3, 11, 1836072691],
|
|
36688
|
+
[7, 8, 1836072691],
|
|
36689
|
+
[14, 6, 1836072691],
|
|
36690
|
+
[6, 6, 1836072691],
|
|
36691
|
+
[9, 14, 1836072691],
|
|
36692
|
+
[11, 12, 1836072691],
|
|
36693
|
+
[8, 13, 1836072691],
|
|
36694
|
+
[12, 5, 1836072691],
|
|
36695
|
+
[2, 14, 1836072691],
|
|
36696
|
+
[10, 13, 1836072691],
|
|
36697
|
+
[0, 13, 1836072691],
|
|
36698
|
+
[4, 7, 1836072691],
|
|
36699
|
+
[13, 5, 1836072691]
|
|
36700
|
+
],
|
|
36701
|
+
[
|
|
36702
|
+
[8, 15, 2053994217],
|
|
36703
|
+
[6, 5, 2053994217],
|
|
36704
|
+
[4, 8, 2053994217],
|
|
36705
|
+
[1, 11, 2053994217],
|
|
36706
|
+
[3, 14, 2053994217],
|
|
36707
|
+
[11, 14, 2053994217],
|
|
36708
|
+
[15, 6, 2053994217],
|
|
36709
|
+
[0, 14, 2053994217],
|
|
36710
|
+
[5, 6, 2053994217],
|
|
36711
|
+
[12, 9, 2053994217],
|
|
36712
|
+
[2, 12, 2053994217],
|
|
36713
|
+
[13, 9, 2053994217],
|
|
36714
|
+
[9, 12, 2053994217],
|
|
36715
|
+
[7, 5, 2053994217],
|
|
36716
|
+
[10, 15, 2053994217],
|
|
36717
|
+
[14, 8, 2053994217]
|
|
36718
|
+
],
|
|
36719
|
+
[
|
|
36720
|
+
[12, 8, 0],
|
|
36721
|
+
[15, 5, 0],
|
|
36722
|
+
[10, 12, 0],
|
|
36723
|
+
[4, 9, 0],
|
|
36724
|
+
[1, 12, 0],
|
|
36725
|
+
[5, 5, 0],
|
|
36726
|
+
[8, 14, 0],
|
|
36727
|
+
[7, 6, 0],
|
|
36728
|
+
[6, 8, 0],
|
|
36729
|
+
[2, 13, 0],
|
|
36730
|
+
[13, 6, 0],
|
|
36731
|
+
[14, 5, 0],
|
|
36732
|
+
[0, 15, 0],
|
|
36733
|
+
[3, 13, 0],
|
|
36734
|
+
[9, 11, 0],
|
|
36735
|
+
[11, 11, 0]
|
|
36736
|
+
]
|
|
36737
|
+
];
|
|
36738
|
+
var LEFT_FNS2 = [f12, f22, f32, f4, f5];
|
|
36739
|
+
var RIGHT_FNS2 = [f5, f4, f32, f22, f12];
|
|
36740
|
+
function applyLane(r, ops, f6, x, startTarget) {
|
|
36741
|
+
let target = startTarget;
|
|
36742
|
+
for (const [k, s, addConst] of ops) {
|
|
36743
|
+
const i1 = (target + 1) % 5;
|
|
36744
|
+
const i2 = (target + 2) % 5;
|
|
36745
|
+
const i3 = (target + 3) % 5;
|
|
36746
|
+
const i4 = (target + 4) % 5;
|
|
36747
|
+
const sum = r[target] + f6(r[i1], r[i2], r[i3]) + x[k] + addConst >>> 0;
|
|
36748
|
+
const newTarget = (sum << s | sum >>> 32 - s) + r[i4] >>> 0;
|
|
36749
|
+
const c = r[i2];
|
|
36750
|
+
r[i2] = (c << 10 | c >>> 22) >>> 0;
|
|
36751
|
+
r[target] = newTarget;
|
|
36752
|
+
target = (target + 4) % 5;
|
|
36753
|
+
}
|
|
36754
|
+
return target;
|
|
36755
|
+
}
|
|
36756
|
+
function transform5(state, x) {
|
|
36757
|
+
const left = [...state];
|
|
36758
|
+
const right = [...state];
|
|
36759
|
+
let leftTarget = 0;
|
|
36760
|
+
let rightTarget = 0;
|
|
36761
|
+
for (let round2 = 0; round2 < 5; round2++) {
|
|
36762
|
+
leftTarget = applyLane(left, LEFT_ROUNDS2[round2], LEFT_FNS2[round2], x, leftTarget);
|
|
36763
|
+
rightTarget = applyLane(right, RIGHT_ROUNDS2[round2], RIGHT_FNS2[round2], x, rightTarget);
|
|
36764
|
+
}
|
|
36765
|
+
const orig = state;
|
|
36766
|
+
const newState = [
|
|
36767
|
+
add32(right[3], left[2], orig[1]),
|
|
36768
|
+
add32(orig[2], left[3], right[4]),
|
|
36769
|
+
add32(orig[3], left[4], right[0]),
|
|
36770
|
+
add32(orig[4], left[0], right[1]),
|
|
36771
|
+
add32(orig[0], left[1], right[2])
|
|
36772
|
+
];
|
|
36773
|
+
for (let i2 = 0; i2 < 5; i2++) {
|
|
36774
|
+
state[i2] = newState[i2];
|
|
36775
|
+
}
|
|
36776
|
+
}
|
|
36777
|
+
function ripemd160(message) {
|
|
36778
|
+
return mdStyleDigest(message, INITIAL_STATE4, transform5);
|
|
36779
|
+
}
|
|
36780
|
+
|
|
36781
|
+
// digest/sha256.ts
|
|
36782
|
+
var K = new Uint32Array([
|
|
36783
|
+
1116352408,
|
|
36784
|
+
1899447441,
|
|
36785
|
+
3049323471,
|
|
36786
|
+
3921009573,
|
|
36787
|
+
961987163,
|
|
36788
|
+
1508970993,
|
|
36789
|
+
2453635748,
|
|
36790
|
+
2870763221,
|
|
36791
|
+
3624381080,
|
|
36792
|
+
310598401,
|
|
36793
|
+
607225278,
|
|
36794
|
+
1426881987,
|
|
36795
|
+
1925078388,
|
|
36796
|
+
2162078206,
|
|
36797
|
+
2614888103,
|
|
36798
|
+
3248222580,
|
|
36799
|
+
3835390401,
|
|
36800
|
+
4022224774,
|
|
36801
|
+
264347078,
|
|
36802
|
+
604807628,
|
|
36803
|
+
770255983,
|
|
36804
|
+
1249150122,
|
|
36805
|
+
1555081692,
|
|
36806
|
+
1996064986,
|
|
36807
|
+
2554220882,
|
|
36808
|
+
2821834349,
|
|
36809
|
+
2952996808,
|
|
36810
|
+
3210313671,
|
|
36811
|
+
3336571891,
|
|
36812
|
+
3584528711,
|
|
36813
|
+
113926993,
|
|
36814
|
+
338241895,
|
|
36815
|
+
666307205,
|
|
36816
|
+
773529912,
|
|
36817
|
+
1294757372,
|
|
36818
|
+
1396182291,
|
|
36819
|
+
1695183700,
|
|
36820
|
+
1986661051,
|
|
36821
|
+
2177026350,
|
|
36822
|
+
2456956037,
|
|
36823
|
+
2730485921,
|
|
36824
|
+
2820302411,
|
|
36825
|
+
3259730800,
|
|
36826
|
+
3345764771,
|
|
36827
|
+
3516065817,
|
|
36828
|
+
3600352804,
|
|
36829
|
+
4094571909,
|
|
36830
|
+
275423344,
|
|
36831
|
+
430227734,
|
|
36832
|
+
506948616,
|
|
36833
|
+
659060556,
|
|
36834
|
+
883997877,
|
|
36835
|
+
958139571,
|
|
36836
|
+
1322822218,
|
|
36837
|
+
1537002063,
|
|
36838
|
+
1747873779,
|
|
36839
|
+
1955562222,
|
|
36840
|
+
2024104815,
|
|
36841
|
+
2227730452,
|
|
36842
|
+
2361852424,
|
|
36843
|
+
2428436474,
|
|
36844
|
+
2756734187,
|
|
36845
|
+
3204031479,
|
|
36846
|
+
3329325298
|
|
36847
|
+
]);
|
|
36848
|
+
var IV = [
|
|
36849
|
+
1779033703,
|
|
36850
|
+
3144134277,
|
|
36851
|
+
1013904242,
|
|
36852
|
+
2773480762,
|
|
36853
|
+
1359893119,
|
|
36854
|
+
2600822924,
|
|
36855
|
+
528734635,
|
|
36856
|
+
1541459225
|
|
36857
|
+
];
|
|
36858
|
+
var W = new Uint32Array(64);
|
|
36859
|
+
var rotr = (x, n) => x >>> n | x << 32 - n;
|
|
36860
|
+
function compress(h2, view, offset) {
|
|
36861
|
+
for (let i2 = 0; i2 < 16; i2++) W[i2] = view.getUint32(offset + i2 * 4);
|
|
36862
|
+
for (let i2 = 16; i2 < 64; i2++) {
|
|
36863
|
+
const a2 = W[i2 - 15];
|
|
36864
|
+
const b2 = W[i2 - 2];
|
|
36865
|
+
const s0 = rotr(a2, 7) ^ rotr(a2, 18) ^ a2 >>> 3;
|
|
36866
|
+
const s1 = rotr(b2, 17) ^ rotr(b2, 19) ^ b2 >>> 10;
|
|
36867
|
+
W[i2] = W[i2 - 16] + s0 + W[i2 - 7] + s1 >>> 0;
|
|
36868
|
+
}
|
|
36869
|
+
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];
|
|
36870
|
+
for (let i2 = 0; i2 < 64; i2++) {
|
|
36871
|
+
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
36872
|
+
const ch = e & f6 ^ ~e & g2;
|
|
36873
|
+
const t1 = k + S1 + ch + K[i2] + W[i2] >>> 0;
|
|
36874
|
+
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
36875
|
+
const maj = a & b ^ a & c ^ b & c;
|
|
36876
|
+
const t2 = S0 + maj >>> 0;
|
|
36877
|
+
k = g2;
|
|
36878
|
+
g2 = f6;
|
|
36879
|
+
f6 = e;
|
|
36880
|
+
e = d + t1 >>> 0;
|
|
36881
|
+
d = c;
|
|
36882
|
+
c = b;
|
|
36883
|
+
b = a;
|
|
36884
|
+
a = t1 + t2 >>> 0;
|
|
36885
|
+
}
|
|
36886
|
+
h2[0] = h2[0] + a >>> 0;
|
|
36887
|
+
h2[1] = h2[1] + b >>> 0;
|
|
36888
|
+
h2[2] = h2[2] + c >>> 0;
|
|
36889
|
+
h2[3] = h2[3] + d >>> 0;
|
|
36890
|
+
h2[4] = h2[4] + e >>> 0;
|
|
36891
|
+
h2[5] = h2[5] + f6 >>> 0;
|
|
36892
|
+
h2[6] = h2[6] + g2 >>> 0;
|
|
36893
|
+
h2[7] = h2[7] + k >>> 0;
|
|
36894
|
+
}
|
|
36895
|
+
function pad64(data) {
|
|
36896
|
+
const padded = new Uint8Array(Math.ceil((data.length + 9) / 64) * 64);
|
|
36897
|
+
padded.set(data);
|
|
36898
|
+
padded[data.length] = 128;
|
|
36899
|
+
const bits = data.length * 8;
|
|
36900
|
+
const view = new DataView(padded.buffer);
|
|
36901
|
+
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
36902
|
+
view.setUint32(padded.length - 4, bits >>> 0);
|
|
36903
|
+
return view;
|
|
36904
|
+
}
|
|
36905
|
+
function wordsOut(h2) {
|
|
36906
|
+
const out = new Uint8Array(h2.length * 4);
|
|
36907
|
+
const view = new DataView(out.buffer);
|
|
36908
|
+
for (let i2 = 0; i2 < h2.length; i2++) view.setUint32(i2 * 4, h2[i2]);
|
|
36909
|
+
return out;
|
|
36910
|
+
}
|
|
36911
|
+
function sha256(data) {
|
|
36912
|
+
const h2 = new Uint32Array(IV);
|
|
36913
|
+
const view = pad64(data);
|
|
36914
|
+
for (let offset = 0; offset < view.byteLength; offset += 64) compress(h2, view, offset);
|
|
36915
|
+
return wordsOut(h2);
|
|
36916
|
+
}
|
|
36917
|
+
|
|
36918
|
+
// digest/sha1.ts
|
|
36919
|
+
var W2 = new Uint32Array(80);
|
|
36920
|
+
var rotl = (x, n) => x << n | x >>> 32 - n;
|
|
36921
|
+
function compress2(h2, view, offset) {
|
|
36922
|
+
for (let i2 = 0; i2 < 16; i2++) W2[i2] = view.getUint32(offset + i2 * 4);
|
|
36923
|
+
for (let i2 = 16; i2 < 80; i2++) W2[i2] = rotl(W2[i2 - 3] ^ W2[i2 - 8] ^ W2[i2 - 14] ^ W2[i2 - 16], 1);
|
|
36924
|
+
let a = h2[0], b = h2[1], c = h2[2], d = h2[3], e = h2[4];
|
|
36925
|
+
for (let i2 = 0; i2 < 80; i2++) {
|
|
36926
|
+
let f6;
|
|
36927
|
+
let k;
|
|
36928
|
+
if (i2 < 20) {
|
|
36929
|
+
f6 = b & c | ~b & d;
|
|
36930
|
+
k = 1518500249;
|
|
36931
|
+
} else if (i2 < 40) {
|
|
36932
|
+
f6 = b ^ c ^ d;
|
|
36933
|
+
k = 1859775393;
|
|
36934
|
+
} else if (i2 < 60) {
|
|
36935
|
+
f6 = b & c | b & d | c & d;
|
|
36936
|
+
k = 2400959708;
|
|
36937
|
+
} else {
|
|
36938
|
+
f6 = b ^ c ^ d;
|
|
36939
|
+
k = 3395469782;
|
|
36940
|
+
}
|
|
36941
|
+
const t = rotl(a, 5) + f6 + e + k + W2[i2] >>> 0;
|
|
36942
|
+
e = d;
|
|
36943
|
+
d = c;
|
|
36944
|
+
c = rotl(b, 30) >>> 0;
|
|
36945
|
+
b = a;
|
|
36946
|
+
a = t;
|
|
36947
|
+
}
|
|
36948
|
+
h2[0] = h2[0] + a >>> 0;
|
|
36949
|
+
h2[1] = h2[1] + b >>> 0;
|
|
36950
|
+
h2[2] = h2[2] + c >>> 0;
|
|
36951
|
+
h2[3] = h2[3] + d >>> 0;
|
|
36952
|
+
h2[4] = h2[4] + e >>> 0;
|
|
36953
|
+
}
|
|
36954
|
+
function sha1(data) {
|
|
36955
|
+
const h2 = new Uint32Array([1732584193, 4023233417, 2562383102, 271733878, 3285377520]);
|
|
36956
|
+
const view = pad64(data);
|
|
36957
|
+
for (let offset = 0; offset < view.byteLength; offset += 64) compress2(h2, view, offset);
|
|
36958
|
+
return wordsOut(h2);
|
|
36959
|
+
}
|
|
36960
|
+
|
|
36961
|
+
// digest/sha512.ts
|
|
36962
|
+
var K4 = new Uint32Array([
|
|
36963
|
+
1116352408,
|
|
36964
|
+
3609767458,
|
|
36965
|
+
1899447441,
|
|
36966
|
+
602891725,
|
|
36967
|
+
3049323471,
|
|
36968
|
+
3964484399,
|
|
36969
|
+
3921009573,
|
|
36970
|
+
2173295548,
|
|
36971
|
+
961987163,
|
|
36972
|
+
4081628472,
|
|
36973
|
+
1508970993,
|
|
36974
|
+
3053834265,
|
|
36975
|
+
2453635748,
|
|
36976
|
+
2937671579,
|
|
36977
|
+
2870763221,
|
|
36978
|
+
3664609560,
|
|
36979
|
+
3624381080,
|
|
36980
|
+
2734883394,
|
|
36981
|
+
310598401,
|
|
36982
|
+
1164996542,
|
|
36983
|
+
607225278,
|
|
36984
|
+
1323610764,
|
|
36985
|
+
1426881987,
|
|
36986
|
+
3590304994,
|
|
36987
|
+
1925078388,
|
|
36988
|
+
4068182383,
|
|
36989
|
+
2162078206,
|
|
36990
|
+
991336113,
|
|
36991
|
+
2614888103,
|
|
36992
|
+
633803317,
|
|
36993
|
+
3248222580,
|
|
36994
|
+
3479774868,
|
|
36995
|
+
3835390401,
|
|
36996
|
+
2666613458,
|
|
36997
|
+
4022224774,
|
|
36998
|
+
944711139,
|
|
36999
|
+
264347078,
|
|
37000
|
+
2341262773,
|
|
37001
|
+
604807628,
|
|
37002
|
+
2007800933,
|
|
37003
|
+
770255983,
|
|
37004
|
+
1495990901,
|
|
37005
|
+
1249150122,
|
|
37006
|
+
1856431235,
|
|
37007
|
+
1555081692,
|
|
37008
|
+
3175218132,
|
|
37009
|
+
1996064986,
|
|
37010
|
+
2198950837,
|
|
37011
|
+
2554220882,
|
|
37012
|
+
3999719339,
|
|
37013
|
+
2821834349,
|
|
37014
|
+
766784016,
|
|
37015
|
+
2952996808,
|
|
37016
|
+
2566594879,
|
|
37017
|
+
3210313671,
|
|
37018
|
+
3203337956,
|
|
37019
|
+
3336571891,
|
|
37020
|
+
1034457026,
|
|
37021
|
+
3584528711,
|
|
37022
|
+
2466948901,
|
|
37023
|
+
113926993,
|
|
37024
|
+
3758326383,
|
|
37025
|
+
338241895,
|
|
37026
|
+
168717936,
|
|
37027
|
+
666307205,
|
|
37028
|
+
1188179964,
|
|
37029
|
+
773529912,
|
|
37030
|
+
1546045734,
|
|
37031
|
+
1294757372,
|
|
37032
|
+
1522805485,
|
|
37033
|
+
1396182291,
|
|
37034
|
+
2643833823,
|
|
37035
|
+
1695183700,
|
|
37036
|
+
2343527390,
|
|
37037
|
+
1986661051,
|
|
37038
|
+
1014477480,
|
|
37039
|
+
2177026350,
|
|
37040
|
+
1206759142,
|
|
37041
|
+
2456956037,
|
|
37042
|
+
344077627,
|
|
37043
|
+
2730485921,
|
|
37044
|
+
1290863460,
|
|
37045
|
+
2820302411,
|
|
37046
|
+
3158454273,
|
|
37047
|
+
3259730800,
|
|
37048
|
+
3505952657,
|
|
37049
|
+
3345764771,
|
|
37050
|
+
106217008,
|
|
37051
|
+
3516065817,
|
|
37052
|
+
3606008344,
|
|
37053
|
+
3600352804,
|
|
37054
|
+
1432725776,
|
|
37055
|
+
4094571909,
|
|
37056
|
+
1467031594,
|
|
37057
|
+
275423344,
|
|
37058
|
+
851169720,
|
|
37059
|
+
430227734,
|
|
37060
|
+
3100823752,
|
|
37061
|
+
506948616,
|
|
37062
|
+
1363258195,
|
|
37063
|
+
659060556,
|
|
37064
|
+
3750685593,
|
|
37065
|
+
883997877,
|
|
37066
|
+
3785050280,
|
|
37067
|
+
958139571,
|
|
37068
|
+
3318307427,
|
|
37069
|
+
1322822218,
|
|
37070
|
+
3812723403,
|
|
37071
|
+
1537002063,
|
|
37072
|
+
2003034995,
|
|
37073
|
+
1747873779,
|
|
37074
|
+
3602036899,
|
|
37075
|
+
1955562222,
|
|
37076
|
+
1575990012,
|
|
37077
|
+
2024104815,
|
|
37078
|
+
1125592928,
|
|
37079
|
+
2227730452,
|
|
37080
|
+
2716904306,
|
|
37081
|
+
2361852424,
|
|
37082
|
+
442776044,
|
|
37083
|
+
2428436474,
|
|
37084
|
+
593698344,
|
|
37085
|
+
2756734187,
|
|
37086
|
+
3733110249,
|
|
37087
|
+
3204031479,
|
|
37088
|
+
2999351573,
|
|
37089
|
+
3329325298,
|
|
37090
|
+
3815920427,
|
|
37091
|
+
3391569614,
|
|
37092
|
+
3928383900,
|
|
37093
|
+
3515267271,
|
|
37094
|
+
566280711,
|
|
37095
|
+
3940187606,
|
|
37096
|
+
3454069534,
|
|
37097
|
+
4118630271,
|
|
37098
|
+
4000239992,
|
|
37099
|
+
116418474,
|
|
37100
|
+
1914138554,
|
|
37101
|
+
174292421,
|
|
37102
|
+
2731055270,
|
|
37103
|
+
289380356,
|
|
37104
|
+
3203993006,
|
|
37105
|
+
460393269,
|
|
37106
|
+
320620315,
|
|
37107
|
+
685471733,
|
|
37108
|
+
587496836,
|
|
37109
|
+
852142971,
|
|
37110
|
+
1086792851,
|
|
37111
|
+
1017036298,
|
|
37112
|
+
365543100,
|
|
37113
|
+
1126000580,
|
|
37114
|
+
2618297676,
|
|
37115
|
+
1288033470,
|
|
37116
|
+
3409855158,
|
|
37117
|
+
1501505948,
|
|
37118
|
+
4234509866,
|
|
37119
|
+
1607167915,
|
|
37120
|
+
987167468,
|
|
37121
|
+
1816402316,
|
|
37122
|
+
1246189591
|
|
37123
|
+
]);
|
|
37124
|
+
var IV_512 = [
|
|
37125
|
+
1779033703,
|
|
37126
|
+
4089235720,
|
|
37127
|
+
3144134277,
|
|
37128
|
+
2227873595,
|
|
37129
|
+
1013904242,
|
|
37130
|
+
4271175723,
|
|
37131
|
+
2773480762,
|
|
37132
|
+
1595750129,
|
|
37133
|
+
1359893119,
|
|
37134
|
+
2917565137,
|
|
37135
|
+
2600822924,
|
|
37136
|
+
725511199,
|
|
37137
|
+
528734635,
|
|
37138
|
+
4215389547,
|
|
37139
|
+
1541459225,
|
|
37140
|
+
327033209
|
|
37141
|
+
];
|
|
37142
|
+
var IV_384 = [
|
|
37143
|
+
3418070365,
|
|
37144
|
+
3238371032,
|
|
37145
|
+
1654270250,
|
|
37146
|
+
914150663,
|
|
37147
|
+
2438529370,
|
|
37148
|
+
812702999,
|
|
37149
|
+
355462360,
|
|
37150
|
+
4144912697,
|
|
37151
|
+
1731405415,
|
|
37152
|
+
4290775857,
|
|
37153
|
+
2394180231,
|
|
37154
|
+
1750603025,
|
|
37155
|
+
3675008525,
|
|
37156
|
+
1694076839,
|
|
37157
|
+
1203062813,
|
|
37158
|
+
3204075428
|
|
37859
37159
|
];
|
|
37860
|
-
var
|
|
37861
|
-
|
|
37862
|
-
|
|
37863
|
-
|
|
37864
|
-
|
|
37865
|
-
const i1 = (target + 1) % 5;
|
|
37866
|
-
const i2 = (target + 2) % 5;
|
|
37867
|
-
const i3 = (target + 3) % 5;
|
|
37868
|
-
const i4 = (target + 4) % 5;
|
|
37869
|
-
const newTarget = add32(
|
|
37870
|
-
rotl32(add32(r[target], f6(r[i1], r[i2], r[i3]), x[k], addConst), s),
|
|
37871
|
-
r[i4]
|
|
37872
|
-
);
|
|
37873
|
-
r[i2] = rotl32(r[i2], 10);
|
|
37874
|
-
r[target] = newTarget;
|
|
37875
|
-
target = (target + 4) % 5;
|
|
37160
|
+
var W3 = new Uint32Array(160);
|
|
37161
|
+
function compress3(h2, data, offset) {
|
|
37162
|
+
for (let i2 = 0; i2 < 32; i2++) {
|
|
37163
|
+
const o = offset + i2 * 4;
|
|
37164
|
+
W3[i2] = (data[o] << 24 | data[o + 1] << 16 | data[o + 2] << 8 | data[o + 3]) >>> 0;
|
|
37876
37165
|
}
|
|
37877
|
-
|
|
37878
|
-
|
|
37879
|
-
|
|
37880
|
-
|
|
37881
|
-
|
|
37882
|
-
|
|
37883
|
-
|
|
37884
|
-
|
|
37885
|
-
|
|
37886
|
-
|
|
37166
|
+
for (let i2 = 16; i2 < 80; i2++) {
|
|
37167
|
+
const xh = W3[(i2 - 15) * 2];
|
|
37168
|
+
const xl = W3[(i2 - 15) * 2 + 1];
|
|
37169
|
+
const s0h = (xh >>> 1 | xl << 31) ^ (xh >>> 8 | xl << 24) ^ xh >>> 7;
|
|
37170
|
+
const s0l = (xl >>> 1 | xh << 31) ^ (xl >>> 8 | xh << 24) ^ (xl >>> 7 | xh << 25);
|
|
37171
|
+
const yh = W3[(i2 - 2) * 2];
|
|
37172
|
+
const yl = W3[(i2 - 2) * 2 + 1];
|
|
37173
|
+
const s1h = (yh >>> 19 | yl << 13) ^ (yl >>> 29 | yh << 3) ^ yh >>> 6;
|
|
37174
|
+
const s1l = (yl >>> 19 | yh << 13) ^ (yh >>> 29 | yl << 3) ^ (yl >>> 6 | yh << 26);
|
|
37175
|
+
let lo = (s0l >>> 0) + (s1l >>> 0) + W3[(i2 - 7) * 2 + 1] + W3[(i2 - 16) * 2 + 1];
|
|
37176
|
+
const hi = s0h + s1h + W3[(i2 - 7) * 2] + W3[(i2 - 16) * 2] + Math.floor(lo / 4294967296);
|
|
37177
|
+
lo >>>= 0;
|
|
37178
|
+
W3[i2 * 2] = hi >>> 0;
|
|
37179
|
+
W3[i2 * 2 + 1] = lo;
|
|
37887
37180
|
}
|
|
37888
|
-
|
|
37889
|
-
|
|
37890
|
-
|
|
37891
|
-
|
|
37892
|
-
|
|
37893
|
-
|
|
37894
|
-
|
|
37895
|
-
|
|
37896
|
-
|
|
37897
|
-
|
|
37181
|
+
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];
|
|
37182
|
+
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];
|
|
37183
|
+
for (let i2 = 0; i2 < 80; i2++) {
|
|
37184
|
+
const S1h = (eh >>> 14 | el << 18) ^ (eh >>> 18 | el << 14) ^ (el >>> 9 | eh << 23);
|
|
37185
|
+
const S1l = (el >>> 14 | eh << 18) ^ (el >>> 18 | eh << 14) ^ (eh >>> 9 | el << 23);
|
|
37186
|
+
const chh = eh & fh ^ ~eh & gh;
|
|
37187
|
+
const chl = el & fl ^ ~el & gl;
|
|
37188
|
+
let t1l = (hl >>> 0) + (S1l >>> 0) + (chl >>> 0) + K4[i2 * 2 + 1] + W3[i2 * 2 + 1];
|
|
37189
|
+
const t1h = hh + S1h + chh + K4[i2 * 2] + W3[i2 * 2] + Math.floor(t1l / 4294967296);
|
|
37190
|
+
t1l >>>= 0;
|
|
37191
|
+
const S0h = (ah >>> 28 | al << 4) ^ (al >>> 2 | ah << 30) ^ (al >>> 7 | ah << 25);
|
|
37192
|
+
const S0l = (al >>> 28 | ah << 4) ^ (ah >>> 2 | al << 30) ^ (ah >>> 7 | al << 25);
|
|
37193
|
+
const majh = ah & bh ^ ah & ch ^ bh & ch;
|
|
37194
|
+
const majl = al & bl ^ al & cl ^ bl & cl;
|
|
37195
|
+
let t2l = (S0l >>> 0) + (majl >>> 0);
|
|
37196
|
+
const t2h = S0h + majh + Math.floor(t2l / 4294967296);
|
|
37197
|
+
t2l >>>= 0;
|
|
37198
|
+
hh = gh;
|
|
37199
|
+
hl = gl;
|
|
37200
|
+
gh = fh;
|
|
37201
|
+
gl = fl;
|
|
37202
|
+
fh = eh;
|
|
37203
|
+
fl = el;
|
|
37204
|
+
let nl = (dl >>> 0) + t1l;
|
|
37205
|
+
eh = dh + t1h + Math.floor(nl / 4294967296) >>> 0;
|
|
37206
|
+
el = nl >>> 0;
|
|
37207
|
+
dh = ch;
|
|
37208
|
+
dl = cl;
|
|
37209
|
+
ch = bh;
|
|
37210
|
+
cl = bl;
|
|
37211
|
+
bh = ah;
|
|
37212
|
+
bl = al;
|
|
37213
|
+
nl = t1l + t2l;
|
|
37214
|
+
ah = t1h + t2h + Math.floor(nl / 4294967296) >>> 0;
|
|
37215
|
+
al = nl >>> 0;
|
|
37898
37216
|
}
|
|
37217
|
+
const add7 = (i2, xh, xl) => {
|
|
37218
|
+
const lo = (h2[i2 + 1] >>> 0) + (xl >>> 0);
|
|
37219
|
+
h2[i2] = h2[i2] + xh + Math.floor(lo / 4294967296) >>> 0;
|
|
37220
|
+
h2[i2 + 1] = lo >>> 0;
|
|
37221
|
+
};
|
|
37222
|
+
add7(0, ah, al);
|
|
37223
|
+
add7(2, bh, bl);
|
|
37224
|
+
add7(4, ch, cl);
|
|
37225
|
+
add7(6, dh, dl);
|
|
37226
|
+
add7(8, eh, el);
|
|
37227
|
+
add7(10, fh, fl);
|
|
37228
|
+
add7(12, gh, gl);
|
|
37229
|
+
add7(14, hh, hl);
|
|
37899
37230
|
}
|
|
37900
|
-
function
|
|
37901
|
-
|
|
37231
|
+
function digest64(data, iv, bytes) {
|
|
37232
|
+
const h2 = new Uint32Array(iv);
|
|
37233
|
+
const padded = new Uint8Array(Math.ceil((data.length + 17) / 128) * 128);
|
|
37234
|
+
padded.set(data);
|
|
37235
|
+
padded[data.length] = 128;
|
|
37236
|
+
const bits = data.length * 8;
|
|
37237
|
+
const view = new DataView(padded.buffer);
|
|
37238
|
+
view.setUint32(padded.length - 8, Math.floor(bits / 4294967296));
|
|
37239
|
+
view.setUint32(padded.length - 4, bits >>> 0);
|
|
37240
|
+
for (let offset = 0; offset < padded.length; offset += 128) compress3(h2, padded, offset);
|
|
37241
|
+
const out = new Uint8Array(bytes);
|
|
37242
|
+
const outView = new DataView(out.buffer);
|
|
37243
|
+
for (let i2 = 0; i2 < bytes / 4; i2++) outView.setUint32(i2 * 4, h2[i2]);
|
|
37244
|
+
return out;
|
|
37902
37245
|
}
|
|
37246
|
+
var sha512 = (data) => digest64(data, IV_512, 64);
|
|
37247
|
+
var sha384 = (data) => digest64(data, IV_384, 48);
|
|
37903
37248
|
|
|
37904
|
-
//
|
|
37249
|
+
// digest/whirlpool-sbox.ts
|
|
37905
37250
|
var TABLE0 = [
|
|
37906
37251
|
0x18186018c07830d8n,
|
|
37907
37252
|
0x23238c2305af4626n,
|
|
@@ -38161,151 +37506,711 @@ var TABLE0 = [
|
|
|
38161
37506
|
0x8686228644a411c2n
|
|
38162
37507
|
];
|
|
38163
37508
|
|
|
38164
|
-
//
|
|
37509
|
+
// digest/whirlpool-table.ts
|
|
38165
37510
|
var WORD_MASK = (1n << 64n) - 1n;
|
|
37511
|
+
var LOW_MASK = 0xffffffffn;
|
|
38166
37512
|
function rotateBytesRight(value, bytes) {
|
|
38167
37513
|
const bits = BigInt(bytes) * 8n;
|
|
38168
37514
|
return (value >> bits | value << 64n - bits) & WORD_MASK;
|
|
38169
37515
|
}
|
|
38170
|
-
var
|
|
38171
|
-
|
|
38172
|
-
|
|
38173
|
-
)
|
|
38174
|
-
|
|
38175
|
-
|
|
38176
|
-
|
|
38177
|
-
|
|
38178
|
-
|
|
38179
|
-
|
|
38180
|
-
|
|
38181
|
-
|
|
38182
|
-
|
|
38183
|
-
|
|
38184
|
-
|
|
38185
|
-
|
|
38186
|
-
|
|
38187
|
-
|
|
38188
|
-
|
|
38189
|
-
|
|
38190
|
-
|
|
38191
|
-
|
|
38192
|
-
|
|
38193
|
-
|
|
38194
|
-
|
|
38195
|
-
|
|
38196
|
-
|
|
38197
|
-
|
|
37516
|
+
var TABLES_HI = new Uint32Array(8 * 256);
|
|
37517
|
+
var TABLES_LO = new Uint32Array(8 * 256);
|
|
37518
|
+
for (let t = 0; t < 8; t++) {
|
|
37519
|
+
for (let x = 0; x < 256; x++) {
|
|
37520
|
+
const value = t === 0 ? TABLE0[x] : rotateBytesRight(TABLE0[x], t);
|
|
37521
|
+
TABLES_HI[t * 256 + x] = Number(value >> 32n);
|
|
37522
|
+
TABLES_LO[t * 256 + x] = Number(value & LOW_MASK);
|
|
37523
|
+
}
|
|
37524
|
+
}
|
|
37525
|
+
var ROUND_CONSTANTS = [
|
|
37526
|
+
0x1823c6e887b8014fn,
|
|
37527
|
+
0x36a6d2f5796f9152n,
|
|
37528
|
+
0x60bc9b8ea30c7b35n,
|
|
37529
|
+
0x1de0d7c22e4bfe57n,
|
|
37530
|
+
0x157737e59ff04adan,
|
|
37531
|
+
0x58c9290ab1a06b85n,
|
|
37532
|
+
0xbd5d10f4cb3e0567n,
|
|
37533
|
+
0xe427418ba77d95d8n,
|
|
37534
|
+
0xfbee7c66dd17479en,
|
|
37535
|
+
0xca2dbf07ad5a8333n
|
|
37536
|
+
];
|
|
37537
|
+
var ROUND_CONSTANTS_HI = Uint32Array.from(ROUND_CONSTANTS, (c) => Number(c >> 32n));
|
|
37538
|
+
var ROUND_CONSTANTS_LO = Uint32Array.from(ROUND_CONSTANTS, (c) => Number(c & LOW_MASK));
|
|
37539
|
+
|
|
37540
|
+
// digest/whirlpool.ts
|
|
37541
|
+
var TABLES_HI2 = TABLES_HI;
|
|
37542
|
+
var TABLES_LO2 = TABLES_LO;
|
|
37543
|
+
var ROUND_CONSTANTS_HI2 = ROUND_CONSTANTS_HI;
|
|
37544
|
+
var ROUND_CONSTANTS_LO2 = ROUND_CONSTANTS_LO;
|
|
37545
|
+
var BLOCK_BYTES = 64;
|
|
37546
|
+
var WORDS = 8;
|
|
37547
|
+
var ROUNDS2 = 10;
|
|
37548
|
+
var words = () => ({ hi: new Uint32Array(WORDS), lo: new Uint32Array(WORDS) });
|
|
37549
|
+
function op(src, column, out) {
|
|
37550
|
+
const { hi: h2, lo: l } = src;
|
|
37551
|
+
const b0 = h2[column] >>> 24;
|
|
37552
|
+
const b1 = h2[column + 7 & 7] >>> 16 & 255;
|
|
37553
|
+
const b2 = h2[column + 6 & 7] >>> 8 & 255;
|
|
37554
|
+
const b3 = h2[column + 5 & 7] & 255;
|
|
37555
|
+
const b4 = l[column + 4 & 7] >>> 24;
|
|
37556
|
+
const b5 = l[column + 3 & 7] >>> 16 & 255;
|
|
37557
|
+
const b6 = l[column + 2 & 7] >>> 8 & 255;
|
|
37558
|
+
const b7 = l[column + 1 & 7] & 255;
|
|
37559
|
+
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];
|
|
37560
|
+
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];
|
|
37561
|
+
}
|
|
37562
|
+
var scratch = { key: words(), state: words(), initial: words(), nextKey: words(), next: words() };
|
|
37563
|
+
function processBlock(hash2, block) {
|
|
37564
|
+
const { key, state, initial, nextKey, next } = scratch;
|
|
37565
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
37566
|
+
initial.hi[i2] = block.hi[i2] ^ hash2.hi[i2];
|
|
37567
|
+
initial.lo[i2] = block.lo[i2] ^ hash2.lo[i2];
|
|
37568
|
+
}
|
|
37569
|
+
key.hi.set(hash2.hi);
|
|
37570
|
+
key.lo.set(hash2.lo);
|
|
37571
|
+
state.hi.set(initial.hi);
|
|
37572
|
+
state.lo.set(initial.lo);
|
|
37573
|
+
for (let round2 = 0; round2 < ROUNDS2; round2++) {
|
|
37574
|
+
for (let j = 0; j < WORDS; j++) op(key, j, nextKey);
|
|
37575
|
+
nextKey.hi[0] = nextKey.hi[0] ^ ROUND_CONSTANTS_HI2[round2];
|
|
37576
|
+
nextKey.lo[0] = nextKey.lo[0] ^ ROUND_CONSTANTS_LO2[round2];
|
|
37577
|
+
for (let j = 0; j < WORDS; j++) {
|
|
37578
|
+
op(state, j, next);
|
|
37579
|
+
next.hi[j] = next.hi[j] ^ nextKey.hi[j];
|
|
37580
|
+
next.lo[j] = next.lo[j] ^ nextKey.lo[j];
|
|
37581
|
+
}
|
|
37582
|
+
key.hi.set(nextKey.hi);
|
|
37583
|
+
key.lo.set(nextKey.lo);
|
|
37584
|
+
state.hi.set(next.hi);
|
|
37585
|
+
state.lo.set(next.lo);
|
|
37586
|
+
}
|
|
37587
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
37588
|
+
hash2.hi[i2] = initial.hi[i2] ^ state.hi[i2];
|
|
37589
|
+
hash2.lo[i2] = initial.lo[i2] ^ state.lo[i2];
|
|
37590
|
+
}
|
|
37591
|
+
}
|
|
37592
|
+
function pad(message) {
|
|
37593
|
+
let total = message.length + 1;
|
|
37594
|
+
while (total % BLOCK_BYTES !== 32) {
|
|
37595
|
+
total++;
|
|
37596
|
+
}
|
|
37597
|
+
total += 32;
|
|
37598
|
+
const padded = new Uint8Array(total);
|
|
37599
|
+
padded.set(message);
|
|
37600
|
+
padded[message.length] = 128;
|
|
37601
|
+
new DataView(padded.buffer).setBigUint64(total - 8, BigInt(message.length) * 8n, false);
|
|
37602
|
+
return padded;
|
|
37603
|
+
}
|
|
37604
|
+
function whirlpool(message) {
|
|
37605
|
+
const padded = pad(message);
|
|
37606
|
+
const view = new DataView(padded.buffer);
|
|
37607
|
+
const hash2 = words();
|
|
37608
|
+
const block = words();
|
|
37609
|
+
for (let offset = 0; offset < padded.length; offset += BLOCK_BYTES) {
|
|
37610
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
37611
|
+
block.hi[i2] = view.getUint32(offset + i2 * 8, false);
|
|
37612
|
+
block.lo[i2] = view.getUint32(offset + i2 * 8 + 4, false);
|
|
37613
|
+
}
|
|
37614
|
+
processBlock(hash2, block);
|
|
37615
|
+
}
|
|
37616
|
+
const out = new Uint8Array(BLOCK_BYTES);
|
|
37617
|
+
const outView = new DataView(out.buffer);
|
|
37618
|
+
for (let i2 = 0; i2 < WORDS; i2++) {
|
|
37619
|
+
outView.setUint32(i2 * 8, hash2.hi[i2], false);
|
|
37620
|
+
outView.setUint32(i2 * 8 + 4, hash2.lo[i2], false);
|
|
37621
|
+
}
|
|
37622
|
+
return out;
|
|
37623
|
+
}
|
|
37624
|
+
|
|
37625
|
+
// digest/digest.ts
|
|
37626
|
+
var DIGESTS = {
|
|
37627
|
+
"SHA-1": sha1,
|
|
37628
|
+
"SHA-256": sha256,
|
|
37629
|
+
"SHA-384": sha384,
|
|
37630
|
+
"SHA-512": sha512,
|
|
37631
|
+
MD2: md2,
|
|
37632
|
+
MD4: md4,
|
|
37633
|
+
MD5: md5,
|
|
37634
|
+
"RIPEMD-128": ripemd128,
|
|
37635
|
+
"RIPEMD-160": ripemd160,
|
|
37636
|
+
WHIRLPOOL: whirlpool
|
|
37637
|
+
};
|
|
37638
|
+
function digestFunction(name) {
|
|
37639
|
+
const canonical = normalizeDigestAlgorithmName(name);
|
|
37640
|
+
return canonical && DIGESTS[canonical];
|
|
37641
|
+
}
|
|
37642
|
+
|
|
37643
|
+
// crypto/key-derivation.ts
|
|
37644
|
+
var BLOCK_KEYS = {
|
|
37645
|
+
verifierHashInput: new Uint8Array([254, 167, 210, 118, 59, 75, 158, 121]),
|
|
37646
|
+
verifierHashValue: new Uint8Array([215, 170, 15, 109, 48, 97, 52, 78]),
|
|
37647
|
+
encryptedKeyValue: new Uint8Array([20, 110, 11, 231, 171, 172, 208, 214]),
|
|
37648
|
+
dataIntegrityHmacKey: new Uint8Array([95, 178, 173, 1, 12, 185, 225, 246]),
|
|
37649
|
+
dataIntegrityHmacValue: new Uint8Array([160, 103, 127, 2, 178, 44, 132, 51])
|
|
37650
|
+
};
|
|
37651
|
+
var MAX_SPIN_COUNT = 1e7;
|
|
37652
|
+
async function spinPassword(password, salt, spinCount, hashAlgorithm) {
|
|
37653
|
+
if (!Number.isInteger(spinCount) || spinCount < 0 || spinCount > MAX_SPIN_COUNT) {
|
|
37654
|
+
throw new Error(`Unsupported encryption spin count: ${spinCount}.`);
|
|
37655
|
+
}
|
|
37656
|
+
const passwordBytes = encodePasswordUtf16LE(password);
|
|
37657
|
+
const digest = digestFunction(hashAlgorithm);
|
|
37658
|
+
if (digest) {
|
|
37659
|
+
let h3 = digest(concatArrays(salt, passwordBytes));
|
|
37660
|
+
const buffer = new Uint8Array(4 + h3.length);
|
|
37661
|
+
const view = new DataView(buffer.buffer);
|
|
37662
|
+
for (let i2 = 0; i2 < spinCount; i2++) {
|
|
37663
|
+
view.setUint32(0, i2, true);
|
|
37664
|
+
buffer.set(h3, 4);
|
|
37665
|
+
h3 = digest(buffer);
|
|
37666
|
+
}
|
|
37667
|
+
return h3;
|
|
37668
|
+
}
|
|
37669
|
+
let h2 = await hash(hashAlgorithm, concatArrays(salt, passwordBytes));
|
|
37670
|
+
for (let i2 = 0; i2 < spinCount; i2++) {
|
|
37671
|
+
h2 = await hash(hashAlgorithm, concatArrays(uint32LE(i2), h2));
|
|
37672
|
+
}
|
|
37673
|
+
return h2;
|
|
37674
|
+
}
|
|
37675
|
+
async function extendKey(h2, hashAlgorithm, keyLength) {
|
|
37676
|
+
const pad2 = async (value) => {
|
|
37677
|
+
const input = new Uint8Array(64).fill(value);
|
|
37678
|
+
for (let i2 = 0; i2 < h2.length && i2 < 64; i2++) input[i2] = h2[i2] ^ value;
|
|
37679
|
+
return hash(hashAlgorithm, input);
|
|
37680
|
+
};
|
|
37681
|
+
const x3 = concatArrays(await pad2(54), await pad2(92));
|
|
37682
|
+
return x3.subarray(0, keyLength);
|
|
37683
|
+
}
|
|
37684
|
+
function computeAgileKeyBase(password, salt, spinCount, hashAlgorithm) {
|
|
37685
|
+
return spinPassword(password, salt, spinCount, hashAlgorithm);
|
|
37686
|
+
}
|
|
37687
|
+
async function deriveAgileKeyFromBase(base, hashAlgorithm, blockKey, keyBits, hashSize) {
|
|
37688
|
+
const h2 = await hash(hashAlgorithm, concatArrays(base, blockKey));
|
|
37689
|
+
const keyLength = keyBits / 8;
|
|
37690
|
+
if (hashSize >= keyLength) return h2.subarray(0, keyLength);
|
|
37691
|
+
return extendKey(h2, hashAlgorithm, keyLength);
|
|
37692
|
+
}
|
|
37693
|
+
function computeStandardKeyBase(password, salt) {
|
|
37694
|
+
return spinPassword(password, salt, 5e4, "SHA-1");
|
|
37695
|
+
}
|
|
37696
|
+
async function deriveStandardKeyFromBase(base, keySize, blockNumber = 0) {
|
|
37697
|
+
const h2 = await hash("SHA-1", concatArrays(base, uint32LE(blockNumber)));
|
|
37698
|
+
return extendKey(h2, "SHA-1", keySize / 8);
|
|
37699
|
+
}
|
|
37700
|
+
async function deriveStandardKey(password, salt, keySize, _algIdHash, blockNumber = 0) {
|
|
37701
|
+
const base = await computeStandardKeyBase(password, salt);
|
|
37702
|
+
return deriveStandardKeyFromBase(base, keySize, blockNumber);
|
|
37703
|
+
}
|
|
37704
|
+
async function generateIV(hashAlgorithm, salt, blockKey, blockSize) {
|
|
37705
|
+
const h2 = await hash(hashAlgorithm, concatArrays(salt, blockKey));
|
|
37706
|
+
if (h2.length >= blockSize) return h2.subarray(0, blockSize);
|
|
37707
|
+
const padded = new Uint8Array(blockSize).fill(54);
|
|
37708
|
+
padded.set(h2);
|
|
37709
|
+
return padded;
|
|
37710
|
+
}
|
|
37711
|
+
|
|
37712
|
+
// crypto/decrypt.ts
|
|
37713
|
+
async function verifyAgilePassword(info, password) {
|
|
37714
|
+
const pke = info.passwordKeyEncryptor;
|
|
37715
|
+
const base = await computeAgileKeyBase(password, pke.saltValue, pke.spinCount, pke.hashAlgorithm);
|
|
37716
|
+
const blockKey = (block) => deriveAgileKeyFromBase(base, pke.hashAlgorithm, block, pke.keyBits, pke.hashSize);
|
|
37717
|
+
const verifierHashInput = await aesCbcDecryptRaw(
|
|
37718
|
+
await blockKey(BLOCK_KEYS.verifierHashInput),
|
|
37719
|
+
pke.saltValue,
|
|
37720
|
+
pke.encryptedVerifierHashInput
|
|
37721
|
+
);
|
|
37722
|
+
const verifierHashValue = await aesCbcDecryptRaw(
|
|
37723
|
+
await blockKey(BLOCK_KEYS.verifierHashValue),
|
|
37724
|
+
pke.saltValue,
|
|
37725
|
+
pke.encryptedVerifierHashValue
|
|
37726
|
+
);
|
|
37727
|
+
const computedHash = await hash(pke.hashAlgorithm, verifierHashInput.subarray(0, pke.saltSize));
|
|
37728
|
+
if (computedHash.length < pke.hashSize || verifierHashValue.length < pke.hashSize) return null;
|
|
37729
|
+
let difference = 0;
|
|
37730
|
+
for (let i2 = 0; i2 < pke.hashSize; i2++) difference |= verifierHashValue[i2] ^ computedHash[i2];
|
|
37731
|
+
if (difference !== 0) return null;
|
|
37732
|
+
const decryptedKey = await aesCbcDecryptRaw(
|
|
37733
|
+
await blockKey(BLOCK_KEYS.encryptedKeyValue),
|
|
37734
|
+
pke.saltValue,
|
|
37735
|
+
pke.encryptedKeyValue
|
|
37736
|
+
);
|
|
37737
|
+
return decryptedKey.subarray(0, info.keyData.keyBits / 8);
|
|
37738
|
+
}
|
|
37739
|
+
async function verifyStandardPassword(info, password) {
|
|
37740
|
+
const key = await deriveStandardKey(
|
|
37741
|
+
password,
|
|
37742
|
+
info.verifier.salt,
|
|
37743
|
+
info.header.keySize,
|
|
37744
|
+
info.header.algIdHash
|
|
37745
|
+
);
|
|
37746
|
+
const decryptedVerifier = await aesEcbDecrypt(key, info.verifier.encryptedVerifier);
|
|
37747
|
+
const decryptedHash = await aesEcbDecrypt(key, info.verifier.encryptedVerifierHash);
|
|
37748
|
+
const computedHash = await hash("SHA-1", decryptedVerifier);
|
|
37749
|
+
const hashSize = info.verifier.verifierHashSize;
|
|
37750
|
+
let match = true;
|
|
37751
|
+
for (let i2 = 0; i2 < Math.min(hashSize, 20); i2++) {
|
|
37752
|
+
if (computedHash[i2] !== decryptedHash[i2]) {
|
|
37753
|
+
match = false;
|
|
37754
|
+
break;
|
|
37755
|
+
}
|
|
38198
37756
|
}
|
|
38199
|
-
return
|
|
37757
|
+
return match ? key : null;
|
|
38200
37758
|
}
|
|
38201
|
-
function
|
|
38202
|
-
const
|
|
38203
|
-
|
|
38204
|
-
|
|
38205
|
-
|
|
38206
|
-
|
|
38207
|
-
|
|
38208
|
-
|
|
38209
|
-
|
|
38210
|
-
|
|
38211
|
-
|
|
38212
|
-
|
|
37759
|
+
async function verifyAgileDataIntegrity(info, key, encryptedPackage) {
|
|
37760
|
+
const keyData = info.keyData;
|
|
37761
|
+
if (!info.dataIntegrity) {
|
|
37762
|
+
return;
|
|
37763
|
+
}
|
|
37764
|
+
const hmacKeyIV = await generateIV(
|
|
37765
|
+
keyData.hashAlgorithm,
|
|
37766
|
+
keyData.saltValue,
|
|
37767
|
+
BLOCK_KEYS.dataIntegrityHmacKey,
|
|
37768
|
+
keyData.blockSize
|
|
37769
|
+
);
|
|
37770
|
+
const decryptedHmacKey = await aesCbcDecryptRaw(
|
|
37771
|
+
key,
|
|
37772
|
+
hmacKeyIV,
|
|
37773
|
+
info.dataIntegrity.encryptedHmacKey
|
|
37774
|
+
);
|
|
37775
|
+
const hmacKey = decryptedHmacKey.subarray(0, keyData.hashSize);
|
|
37776
|
+
const hmacValueIV = await generateIV(
|
|
37777
|
+
keyData.hashAlgorithm,
|
|
37778
|
+
keyData.saltValue,
|
|
37779
|
+
BLOCK_KEYS.dataIntegrityHmacValue,
|
|
37780
|
+
keyData.blockSize
|
|
37781
|
+
);
|
|
37782
|
+
const decryptedHmacValue = await aesCbcDecryptRaw(
|
|
37783
|
+
key,
|
|
37784
|
+
hmacValueIV,
|
|
37785
|
+
info.dataIntegrity.encryptedHmacValue
|
|
37786
|
+
);
|
|
37787
|
+
const expectedHmac = decryptedHmacValue.subarray(0, keyData.hashSize);
|
|
37788
|
+
const computedHmac = await hmac(keyData.hashAlgorithm, hmacKey, encryptedPackage);
|
|
37789
|
+
let match = true;
|
|
37790
|
+
if (computedHmac.length < keyData.hashSize) {
|
|
37791
|
+
match = false;
|
|
37792
|
+
} else {
|
|
37793
|
+
for (let i2 = 0; i2 < keyData.hashSize; i2++) {
|
|
37794
|
+
if (computedHmac[i2] !== expectedHmac[i2]) {
|
|
37795
|
+
match = false;
|
|
37796
|
+
break;
|
|
37797
|
+
}
|
|
38213
37798
|
}
|
|
38214
|
-
key = nextKey;
|
|
38215
|
-
state = nextState;
|
|
38216
37799
|
}
|
|
38217
|
-
|
|
38218
|
-
|
|
37800
|
+
if (!match) {
|
|
37801
|
+
throw new DataIntegrityError(
|
|
37802
|
+
"Data integrity check failed. The encrypted file may be corrupted or tampered with."
|
|
37803
|
+
);
|
|
38219
37804
|
}
|
|
38220
37805
|
}
|
|
38221
|
-
function
|
|
38222
|
-
|
|
38223
|
-
|
|
38224
|
-
|
|
37806
|
+
async function decryptAgilePackage(encryptedPackage, key, info) {
|
|
37807
|
+
const keyData = info.keyData;
|
|
37808
|
+
const sizeView = new DataView(encryptedPackage.buffer, encryptedPackage.byteOffset, 8);
|
|
37809
|
+
const originalSize = sizeView.getUint32(0, true) + sizeView.getUint32(4, true) * 4294967296;
|
|
37810
|
+
const encryptedData = encryptedPackage.subarray(8);
|
|
37811
|
+
const segmentSize = 4096;
|
|
37812
|
+
const result = new Uint8Array(originalSize);
|
|
37813
|
+
let resultOffset = 0;
|
|
37814
|
+
const numSegments = Math.ceil(encryptedData.length / segmentSize);
|
|
37815
|
+
for (let segment = 0; segment < numSegments; segment++) {
|
|
37816
|
+
const segmentStart = segment * segmentSize;
|
|
37817
|
+
const segmentEnd = Math.min(segmentStart + segmentSize, encryptedData.length);
|
|
37818
|
+
const segmentData = encryptedData.subarray(segmentStart, segmentEnd);
|
|
37819
|
+
const blockKeyBytes = uint32LE(segment);
|
|
37820
|
+
const segmentIV = await generateIV(
|
|
37821
|
+
keyData.hashAlgorithm,
|
|
37822
|
+
keyData.saltValue,
|
|
37823
|
+
blockKeyBytes,
|
|
37824
|
+
keyData.blockSize
|
|
37825
|
+
);
|
|
37826
|
+
const decrypted = await aesCbcDecryptRaw(key, segmentIV, segmentData);
|
|
37827
|
+
const bytesToCopy = Math.min(decrypted.length, originalSize - resultOffset);
|
|
37828
|
+
result.set(decrypted.subarray(0, bytesToCopy), resultOffset);
|
|
37829
|
+
resultOffset += bytesToCopy;
|
|
38225
37830
|
}
|
|
38226
|
-
|
|
38227
|
-
const padded = new Uint8Array(total);
|
|
38228
|
-
padded.set(message);
|
|
38229
|
-
padded[message.length] = 128;
|
|
38230
|
-
new DataView(padded.buffer).setBigUint64(total - 8, BigInt(message.length) * 8n, false);
|
|
38231
|
-
return padded;
|
|
37831
|
+
return result.buffer;
|
|
38232
37832
|
}
|
|
38233
|
-
function
|
|
38234
|
-
const
|
|
38235
|
-
const
|
|
38236
|
-
const
|
|
38237
|
-
const
|
|
38238
|
-
|
|
38239
|
-
|
|
38240
|
-
|
|
38241
|
-
|
|
38242
|
-
|
|
37833
|
+
async function decryptStandardPackage(encryptedPackage, key) {
|
|
37834
|
+
const sizeView = new DataView(encryptedPackage.buffer, encryptedPackage.byteOffset, 8);
|
|
37835
|
+
const originalSize = sizeView.getUint32(0, true);
|
|
37836
|
+
const encryptedData = encryptedPackage.subarray(8);
|
|
37837
|
+
const decrypted = await aesEcbDecrypt(key, encryptedData);
|
|
37838
|
+
return decrypted.slice(0, originalSize).buffer;
|
|
37839
|
+
}
|
|
37840
|
+
|
|
37841
|
+
// crypto/encryption-info-write.ts
|
|
37842
|
+
function buildAgileEncryptionInfoXml(keyData, pke, dataIntegrity) {
|
|
37843
|
+
const xmlNs = "http://schemas.microsoft.com/office/2006/encryption";
|
|
37844
|
+
const pNs = "http://schemas.microsoft.com/office/2006/keyEncryptor/password";
|
|
37845
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
|
|
37846
|
+
<encryption xmlns="${xmlNs}" xmlns:p="${pNs}"><keyData saltSize="${keyData.saltSize}" blockSize="${keyData.blockSize}" keyBits="${keyData.keyBits}" hashSize="${keyData.hashSize}" cipherAlgorithm="${keyData.cipherAlgorithm}" cipherChaining="${keyData.cipherChaining}" hashAlgorithm="${keyData.hashAlgorithm}" saltValue="${base64Encode(keyData.saltValue)}"/><dataIntegrity encryptedHmacKey="${base64Encode(dataIntegrity.encryptedHmacKey)}" encryptedHmacValue="${base64Encode(dataIntegrity.encryptedHmacValue)}"/><keyEncryptors><keyEncryptor uri="http://schemas.microsoft.com/office/2006/keyEncryptor/password"><p:encryptedKey spinCount="${pke.spinCount}" saltSize="${pke.saltSize}" blockSize="${pke.blockSize}" keyBits="${pke.keyBits}" hashSize="${pke.hashSize}" cipherAlgorithm="${pke.cipherAlgorithm}" cipherChaining="${pke.cipherChaining}" hashAlgorithm="${pke.hashAlgorithm}" saltValue="${base64Encode(pke.saltValue)}" encryptedVerifierHashInput="${base64Encode(pke.encryptedVerifierHashInput)}" encryptedVerifierHashValue="${base64Encode(pke.encryptedVerifierHashValue)}" encryptedKeyValue="${base64Encode(pke.encryptedKeyValue)}"/></keyEncryptor></keyEncryptors></encryption>`;
|
|
37847
|
+
}
|
|
37848
|
+
function buildEncryptionInfoStream(xmlString) {
|
|
37849
|
+
const xmlBytes = new TextEncoder().encode(xmlString);
|
|
37850
|
+
const result = new Uint8Array(8 + xmlBytes.length);
|
|
37851
|
+
const view = new DataView(result.buffer);
|
|
37852
|
+
view.setUint16(0, 4, true);
|
|
37853
|
+
view.setUint16(2, 4, true);
|
|
37854
|
+
view.setUint32(4, 64, true);
|
|
37855
|
+
result.set(xmlBytes, 8);
|
|
37856
|
+
return result;
|
|
37857
|
+
}
|
|
37858
|
+
var STANDARD_ALG_IDS = {
|
|
37859
|
+
128: 26126,
|
|
37860
|
+
// CALG_AES_128
|
|
37861
|
+
192: 26127,
|
|
37862
|
+
// CALG_AES_192
|
|
37863
|
+
256: 26128
|
|
37864
|
+
// CALG_AES_256
|
|
37865
|
+
};
|
|
37866
|
+
var STANDARD_ALG_ID_HASH_SHA1 = 32772;
|
|
37867
|
+
var STANDARD_PROVIDER_TYPE_RSA_AES = 24;
|
|
37868
|
+
var STANDARD_CSP_NAME = "Microsoft Enhanced RSA and AES Cryptographic Provider";
|
|
37869
|
+
var STANDARD_FLAGS = 36;
|
|
37870
|
+
function buildStandardEncryptionInfoStream(keyBits, salt, encryptedVerifier, encryptedVerifierHash) {
|
|
37871
|
+
const algId = STANDARD_ALG_IDS[keyBits];
|
|
37872
|
+
if (!algId) {
|
|
37873
|
+
throw new Error(
|
|
37874
|
+
`Unsupported standard encryption key size: ${keyBits} bits. Use 128, 192, or 256.`
|
|
37875
|
+
);
|
|
38243
37876
|
}
|
|
38244
|
-
const
|
|
38245
|
-
|
|
38246
|
-
|
|
38247
|
-
|
|
37877
|
+
const cspNameBytes = new Uint8Array((STANDARD_CSP_NAME.length + 1) * 2);
|
|
37878
|
+
for (let i2 = 0; i2 < STANDARD_CSP_NAME.length; i2++) {
|
|
37879
|
+
const code = STANDARD_CSP_NAME.charCodeAt(i2);
|
|
37880
|
+
cspNameBytes[i2 * 2] = code & 255;
|
|
37881
|
+
cspNameBytes[i2 * 2 + 1] = code >> 8 & 255;
|
|
38248
37882
|
}
|
|
38249
|
-
|
|
37883
|
+
const headerFixedSize = 32;
|
|
37884
|
+
const headerSize = headerFixedSize + cspNameBytes.length;
|
|
37885
|
+
const verifierSize = 4 + 16 + 16 + 4 + 32;
|
|
37886
|
+
const totalSize = 12 + headerSize + verifierSize;
|
|
37887
|
+
const data = new Uint8Array(totalSize);
|
|
37888
|
+
const view = new DataView(data.buffer);
|
|
37889
|
+
view.setUint16(0, 4, true);
|
|
37890
|
+
view.setUint16(2, 2, true);
|
|
37891
|
+
view.setUint32(4, STANDARD_FLAGS, true);
|
|
37892
|
+
view.setUint32(8, headerSize, true);
|
|
37893
|
+
const h2 = 12;
|
|
37894
|
+
view.setUint32(h2, STANDARD_FLAGS, true);
|
|
37895
|
+
view.setUint32(h2 + 4, 0, true);
|
|
37896
|
+
view.setUint32(h2 + 8, algId, true);
|
|
37897
|
+
view.setUint32(h2 + 12, STANDARD_ALG_ID_HASH_SHA1, true);
|
|
37898
|
+
view.setUint32(h2 + 16, keyBits, true);
|
|
37899
|
+
view.setUint32(h2 + 20, STANDARD_PROVIDER_TYPE_RSA_AES, true);
|
|
37900
|
+
view.setUint32(h2 + 24, 0, true);
|
|
37901
|
+
view.setUint32(h2 + 28, 0, true);
|
|
37902
|
+
data.set(cspNameBytes, h2 + 32);
|
|
37903
|
+
const v = 12 + headerSize;
|
|
37904
|
+
view.setUint32(v, 16, true);
|
|
37905
|
+
data.set(salt.subarray(0, 16), v + 4);
|
|
37906
|
+
data.set(encryptedVerifier.subarray(0, 16), v + 20);
|
|
37907
|
+
view.setUint32(v + 36, 20, true);
|
|
37908
|
+
data.set(encryptedVerifierHash.subarray(0, 32), v + 40);
|
|
37909
|
+
return data;
|
|
38250
37910
|
}
|
|
38251
37911
|
|
|
38252
|
-
//
|
|
38253
|
-
var
|
|
38254
|
-
|
|
38255
|
-
|
|
38256
|
-
|
|
38257
|
-
"
|
|
38258
|
-
|
|
38259
|
-
|
|
38260
|
-
|
|
38261
|
-
|
|
38262
|
-
|
|
38263
|
-
|
|
37912
|
+
// crypto/encrypt.ts
|
|
37913
|
+
var SEGMENT_SIZE = 4096;
|
|
37914
|
+
function container(encryptionInfo, encryptedPackage) {
|
|
37915
|
+
const streams2 = /* @__PURE__ */ new Map();
|
|
37916
|
+
streams2.set("EncryptionInfo", encryptionInfo);
|
|
37917
|
+
streams2.set("EncryptedPackage", encryptedPackage);
|
|
37918
|
+
return new Uint8Array(buildOle2(streams2));
|
|
37919
|
+
}
|
|
37920
|
+
function randomBytes2(size) {
|
|
37921
|
+
const bytes = new Uint8Array(size);
|
|
37922
|
+
getCrypto().getRandomValues(bytes);
|
|
37923
|
+
return bytes;
|
|
37924
|
+
}
|
|
37925
|
+
function padTo(data, blockSize) {
|
|
37926
|
+
const padded = new Uint8Array(Math.ceil(data.length / blockSize) * blockSize);
|
|
37927
|
+
padded.set(data);
|
|
37928
|
+
return padded;
|
|
37929
|
+
}
|
|
37930
|
+
function withSizePrefix(size, body) {
|
|
37931
|
+
const out = new Uint8Array(8 + body.length);
|
|
37932
|
+
const view = new DataView(out.buffer, 0, 8);
|
|
37933
|
+
view.setUint32(0, size % 4294967296, true);
|
|
37934
|
+
view.setUint32(4, Math.floor(size / 4294967296), true);
|
|
37935
|
+
out.set(body, 8);
|
|
37936
|
+
return out;
|
|
37937
|
+
}
|
|
37938
|
+
async function encryptAgilePackage(packageData, key, info) {
|
|
37939
|
+
const { hashAlgorithm, saltValue, blockSize } = info.keyData;
|
|
37940
|
+
const padded = padTo(packageData, SEGMENT_SIZE);
|
|
37941
|
+
const encrypted = withSizePrefix(packageData.length, padded);
|
|
37942
|
+
for (let start = 0; start < padded.length; start += SEGMENT_SIZE) {
|
|
37943
|
+
const iv = await generateIV(
|
|
37944
|
+
hashAlgorithm,
|
|
37945
|
+
saltValue,
|
|
37946
|
+
uint32LE(start / SEGMENT_SIZE),
|
|
37947
|
+
blockSize
|
|
37948
|
+
);
|
|
37949
|
+
const segment = padded.subarray(start, start + SEGMENT_SIZE);
|
|
37950
|
+
encrypted.set(await aesCbcEncryptNoPad(key, iv, segment), 8 + start);
|
|
38264
37951
|
}
|
|
38265
|
-
|
|
37952
|
+
return encrypted;
|
|
37953
|
+
}
|
|
37954
|
+
async function encryptStandardPackage(packageData, key) {
|
|
37955
|
+
const encryptedData = await aesEcbEncrypt(key, packageData);
|
|
37956
|
+
return withSizePrefix(packageData.length, encryptedData);
|
|
37957
|
+
}
|
|
37958
|
+
async function encryptAgile(packageData, password, options = {}) {
|
|
37959
|
+
const keyBits = options.algorithm === "AES128" ? 128 : 256;
|
|
37960
|
+
const hashAlgorithm = "SHA-512";
|
|
37961
|
+
const hashSize = 64;
|
|
37962
|
+
const blockSize = 16;
|
|
37963
|
+
const spinCount = options.spinCount ?? 1e5;
|
|
37964
|
+
const keyDataSalt = randomBytes2(16);
|
|
37965
|
+
const pkeSalt = randomBytes2(16);
|
|
37966
|
+
const documentKey = randomBytes2(keyBits / 8);
|
|
37967
|
+
const verifierHashInput = randomBytes2(16);
|
|
37968
|
+
const verifierHash = await hash(hashAlgorithm, verifierHashInput);
|
|
37969
|
+
const base = await computeAgileKeyBase(password, pkeSalt, spinCount, hashAlgorithm);
|
|
37970
|
+
const encryptUnder = async (block, data) => {
|
|
37971
|
+
const key = await deriveAgileKeyFromBase(base, hashAlgorithm, block, keyBits, hashSize);
|
|
37972
|
+
return aesCbcEncryptNoPad(key, pkeSalt, padTo(data, blockSize));
|
|
37973
|
+
};
|
|
37974
|
+
const passwordKeyEncryptor = {
|
|
37975
|
+
saltSize: 16,
|
|
37976
|
+
blockSize,
|
|
37977
|
+
keyBits,
|
|
37978
|
+
hashSize,
|
|
37979
|
+
cipherAlgorithm: "AES",
|
|
37980
|
+
cipherChaining: "ChainingModeCBC",
|
|
37981
|
+
hashAlgorithm,
|
|
37982
|
+
saltValue: pkeSalt,
|
|
37983
|
+
spinCount,
|
|
37984
|
+
encryptedVerifierHashInput: await encryptUnder(BLOCK_KEYS.verifierHashInput, verifierHashInput),
|
|
37985
|
+
encryptedVerifierHashValue: await encryptUnder(BLOCK_KEYS.verifierHashValue, verifierHash),
|
|
37986
|
+
encryptedKeyValue: await encryptUnder(BLOCK_KEYS.encryptedKeyValue, documentKey)
|
|
37987
|
+
};
|
|
37988
|
+
const keyData = {
|
|
37989
|
+
saltSize: 16,
|
|
37990
|
+
blockSize,
|
|
37991
|
+
keyBits,
|
|
37992
|
+
hashSize,
|
|
37993
|
+
cipherAlgorithm: "AES",
|
|
37994
|
+
cipherChaining: "ChainingModeCBC",
|
|
37995
|
+
hashAlgorithm,
|
|
37996
|
+
saltValue: keyDataSalt
|
|
37997
|
+
};
|
|
37998
|
+
const info = {
|
|
37999
|
+
keyData};
|
|
38000
|
+
const encryptedPackage = await encryptAgilePackage(packageData, documentKey, info);
|
|
38001
|
+
const hmacKey = randomBytes2(hashSize);
|
|
38002
|
+
const hmacValue = await hmac(hashAlgorithm, hmacKey, encryptedPackage);
|
|
38003
|
+
const encryptIntegrity = async (block, data) => {
|
|
38004
|
+
const iv = await generateIV(hashAlgorithm, keyDataSalt, block, blockSize);
|
|
38005
|
+
return aesCbcEncryptNoPad(documentKey, iv, padTo(data, blockSize));
|
|
38006
|
+
};
|
|
38007
|
+
const dataIntegrity = {
|
|
38008
|
+
encryptedHmacKey: await encryptIntegrity(BLOCK_KEYS.dataIntegrityHmacKey, hmacKey),
|
|
38009
|
+
encryptedHmacValue: await encryptIntegrity(BLOCK_KEYS.dataIntegrityHmacValue, hmacValue)
|
|
38010
|
+
};
|
|
38011
|
+
const xml = buildAgileEncryptionInfoXml(keyData, passwordKeyEncryptor, dataIntegrity);
|
|
38012
|
+
return container(buildEncryptionInfoStream(xml), encryptedPackage);
|
|
38013
|
+
}
|
|
38014
|
+
async function encryptStandard(packageData, password, options = {}) {
|
|
38015
|
+
const keyBits = options.algorithm === "AES128" ? 128 : 256;
|
|
38016
|
+
const salt = randomBytes2(16);
|
|
38017
|
+
const key = await deriveStandardKey(password, salt, keyBits);
|
|
38018
|
+
const verifier = randomBytes2(16);
|
|
38019
|
+
const paddedVerifierHash = new Uint8Array(32);
|
|
38020
|
+
paddedVerifierHash.set((await hash("SHA-1", verifier)).subarray(0, 20));
|
|
38021
|
+
const encryptionInfo = buildStandardEncryptionInfoStream(
|
|
38022
|
+
keyBits,
|
|
38023
|
+
salt,
|
|
38024
|
+
await aesEcbEncrypt(key, verifier),
|
|
38025
|
+
await aesEcbEncrypt(key, paddedVerifierHash)
|
|
38026
|
+
);
|
|
38027
|
+
return container(encryptionInfo, await encryptStandardPackage(packageData, key));
|
|
38266
38028
|
}
|
|
38267
|
-
|
|
38268
|
-
|
|
38269
|
-
|
|
38270
|
-
|
|
38029
|
+
|
|
38030
|
+
// crypto/encryption-info.ts
|
|
38031
|
+
var RC4_ALG_ID = 26625;
|
|
38032
|
+
function parseEncryptionInfo(data) {
|
|
38033
|
+
if (data.byteLength < 8) throw new Error("The EncryptionInfo stream is truncated.");
|
|
38034
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
38035
|
+
const versionMajor = view.getUint16(0, true);
|
|
38036
|
+
const versionMinor = view.getUint16(2, true);
|
|
38037
|
+
if (versionMajor === 4 && versionMinor === 4) return parseAgileEncryptionInfo(data);
|
|
38038
|
+
if ((versionMajor === 2 || versionMajor === 3 || versionMajor === 4) && versionMinor === 2) {
|
|
38039
|
+
return parseStandardEncryptionInfo(data);
|
|
38271
38040
|
}
|
|
38272
|
-
|
|
38273
|
-
|
|
38274
|
-
|
|
38275
|
-
|
|
38041
|
+
throw new Error(
|
|
38042
|
+
`Unsupported encryption version: ${versionMajor}.${versionMinor}. Only Standard (2.2-4.2) and Agile (4.4) encryption are supported.`
|
|
38043
|
+
);
|
|
38044
|
+
}
|
|
38045
|
+
function parseStandardEncryptionInfo(data) {
|
|
38046
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
38047
|
+
const versionMajor = view.getUint16(0, true);
|
|
38048
|
+
const versionMinor = view.getUint16(2, true);
|
|
38049
|
+
const flags = view.getUint32(4, true);
|
|
38050
|
+
const headerSize = view.getUint32(8, true);
|
|
38051
|
+
const headerOffset = 12;
|
|
38052
|
+
const hFlags = view.getUint32(headerOffset, true);
|
|
38053
|
+
const algId = view.getUint32(headerOffset + 8, true);
|
|
38054
|
+
const algIdHash = view.getUint32(headerOffset + 12, true);
|
|
38055
|
+
const keySize = view.getUint32(headerOffset + 16, true);
|
|
38056
|
+
const providerType = view.getUint32(headerOffset + 20, true);
|
|
38057
|
+
let cspName = "";
|
|
38058
|
+
const cspEnd = headerOffset + headerSize;
|
|
38059
|
+
for (let i2 = headerOffset + 32; i2 < cspEnd - 1; i2 += 2) {
|
|
38060
|
+
const ch = view.getUint16(i2, true);
|
|
38061
|
+
if (ch === 0) break;
|
|
38062
|
+
cspName += String.fromCharCode(ch);
|
|
38276
38063
|
}
|
|
38277
|
-
|
|
38064
|
+
const verifierOffset = 12 + headerSize;
|
|
38065
|
+
const saltSize = view.getUint32(verifierOffset, true);
|
|
38066
|
+
const salt = new Uint8Array(data.buffer, data.byteOffset + verifierOffset + 4, 16);
|
|
38067
|
+
const encryptedVerifier = new Uint8Array(data.buffer, data.byteOffset + verifierOffset + 20, 16);
|
|
38068
|
+
const verifierHashSize = view.getUint32(verifierOffset + 36, true);
|
|
38069
|
+
const encryptedVerifierHashLength = algId === RC4_ALG_ID ? verifierHashSize : Math.ceil(verifierHashSize / 16) * 16;
|
|
38070
|
+
const encryptedVerifierHash = new Uint8Array(
|
|
38071
|
+
data.buffer,
|
|
38072
|
+
data.byteOffset + verifierOffset + 40,
|
|
38073
|
+
encryptedVerifierHashLength
|
|
38074
|
+
);
|
|
38075
|
+
return {
|
|
38076
|
+
version: { major: versionMajor, minor: versionMinor },
|
|
38077
|
+
isAgile: false,
|
|
38078
|
+
isStandard: true,
|
|
38079
|
+
flags,
|
|
38080
|
+
headerSize,
|
|
38081
|
+
header: { flags: hFlags, algId, algIdHash, keySize, providerType, cspName },
|
|
38082
|
+
verifier: {
|
|
38083
|
+
saltSize,
|
|
38084
|
+
salt: new Uint8Array(salt),
|
|
38085
|
+
encryptedVerifier: new Uint8Array(encryptedVerifier),
|
|
38086
|
+
verifierHashSize,
|
|
38087
|
+
encryptedVerifierHash: new Uint8Array(encryptedVerifierHash)
|
|
38088
|
+
}
|
|
38089
|
+
};
|
|
38090
|
+
}
|
|
38091
|
+
function tagAttribute(xml, tag, attr) {
|
|
38092
|
+
const tagMatch = xml.match(new RegExp(`<[^>]*${tag}[^>]*>`, "i"));
|
|
38093
|
+
if (!tagMatch) return "";
|
|
38094
|
+
const attrMatch = tagMatch[0].match(new RegExp(`\\b${attr}="([^"]*)"`, "i"));
|
|
38095
|
+
return attrMatch?.[1] ?? "";
|
|
38096
|
+
}
|
|
38097
|
+
function parseAgileEncryptionInfo(data) {
|
|
38098
|
+
const xml = new TextDecoder("utf-8").decode(data.subarray(8));
|
|
38099
|
+
const keyData = (attr) => tagAttribute(xml, "keyData", attr);
|
|
38100
|
+
const integrity = (attr) => tagAttribute(xml, "dataIntegrity", attr);
|
|
38101
|
+
const pke = (attr) => tagAttribute(xml, "encryptedKey", attr);
|
|
38102
|
+
const int = (value) => parseInt(value, 10);
|
|
38103
|
+
const encryptedHmacKey = integrity("encryptedHmacKey");
|
|
38104
|
+
return {
|
|
38105
|
+
version: { major: 4, minor: 4 },
|
|
38106
|
+
isAgile: true,
|
|
38107
|
+
keyData: {
|
|
38108
|
+
saltSize: int(keyData("saltSize")),
|
|
38109
|
+
blockSize: int(keyData("blockSize")),
|
|
38110
|
+
keyBits: int(keyData("keyBits")),
|
|
38111
|
+
hashSize: int(keyData("hashSize")),
|
|
38112
|
+
cipherAlgorithm: keyData("cipherAlgorithm"),
|
|
38113
|
+
cipherChaining: keyData("cipherChaining"),
|
|
38114
|
+
hashAlgorithm: keyData("hashAlgorithm"),
|
|
38115
|
+
saltValue: base64Decode(keyData("saltValue"))
|
|
38116
|
+
},
|
|
38117
|
+
...encryptedHmacKey ? {
|
|
38118
|
+
dataIntegrity: {
|
|
38119
|
+
encryptedHmacKey: base64Decode(encryptedHmacKey),
|
|
38120
|
+
encryptedHmacValue: base64Decode(integrity("encryptedHmacValue"))
|
|
38121
|
+
}
|
|
38122
|
+
} : {},
|
|
38123
|
+
passwordKeyEncryptor: {
|
|
38124
|
+
saltSize: int(pke("saltSize")),
|
|
38125
|
+
blockSize: int(pke("blockSize")),
|
|
38126
|
+
keyBits: int(pke("keyBits")),
|
|
38127
|
+
hashSize: int(pke("hashSize")),
|
|
38128
|
+
cipherAlgorithm: pke("cipherAlgorithm"),
|
|
38129
|
+
cipherChaining: pke("cipherChaining"),
|
|
38130
|
+
hashAlgorithm: pke("hashAlgorithm"),
|
|
38131
|
+
saltValue: base64Decode(pke("saltValue")),
|
|
38132
|
+
spinCount: int(pke("spinCount")),
|
|
38133
|
+
encryptedVerifierHashInput: base64Decode(pke("encryptedVerifierHashInput")),
|
|
38134
|
+
encryptedVerifierHashValue: base64Decode(pke("encryptedVerifierHashValue")),
|
|
38135
|
+
encryptedKeyValue: base64Decode(pke("encryptedKeyValue"))
|
|
38136
|
+
}
|
|
38137
|
+
};
|
|
38278
38138
|
}
|
|
38279
38139
|
|
|
38280
|
-
//
|
|
38281
|
-
|
|
38282
|
-
|
|
38283
|
-
|
|
38284
|
-
|
|
38285
|
-
|
|
38286
|
-
|
|
38140
|
+
// crypto/index.ts
|
|
38141
|
+
var isStandard = (info) => "isStandard" in info && info.isStandard;
|
|
38142
|
+
function streams(bytes) {
|
|
38143
|
+
const opened = openEncryptedPackage(bytes);
|
|
38144
|
+
if (opened) return { info: opened.encryptionInfo, data: opened.encryptedPackage };
|
|
38145
|
+
const file = parseOle2(toArrayBuffer(bytes));
|
|
38146
|
+
if (!file.getStream("EncryptionInfo")) {
|
|
38147
|
+
throw new Error(
|
|
38148
|
+
"EncryptionInfo stream not found. The file may not be an encrypted OOXML package."
|
|
38149
|
+
);
|
|
38287
38150
|
}
|
|
38288
|
-
|
|
38151
|
+
throw new Error("EncryptedPackage stream not found. The file may be corrupted.");
|
|
38289
38152
|
}
|
|
38290
|
-
function
|
|
38291
|
-
|
|
38292
|
-
|
|
38293
|
-
|
|
38153
|
+
async function decryptOoxmlPackage(input, password) {
|
|
38154
|
+
const { info: infoStream, data } = streams(toBytes(input));
|
|
38155
|
+
const info = parseEncryptionInfo(infoStream);
|
|
38156
|
+
if (isStandard(info)) {
|
|
38157
|
+
const key2 = await verifyStandardPassword(info, password);
|
|
38158
|
+
if (!key2) throw new IncorrectPasswordError();
|
|
38159
|
+
return new Uint8Array(await decryptStandardPackage(data, key2));
|
|
38294
38160
|
}
|
|
38295
|
-
const
|
|
38296
|
-
|
|
38297
|
-
|
|
38298
|
-
|
|
38299
|
-
|
|
38161
|
+
const key = await verifyAgilePassword(info, password);
|
|
38162
|
+
if (!key) throw new IncorrectPasswordError();
|
|
38163
|
+
await verifyAgileDataIntegrity(info, key, data);
|
|
38164
|
+
return new Uint8Array(await decryptAgilePackage(data, key, info));
|
|
38165
|
+
}
|
|
38166
|
+
function encryptOoxmlPackage(input, password, options = {}) {
|
|
38167
|
+
const bytes = toBytes(input);
|
|
38168
|
+
return options.encryptionScheme === "standard" ? encryptStandard(bytes, password, options) : encryptAgile(bytes, password, options);
|
|
38169
|
+
}
|
|
38170
|
+
async function verifyOoxmlPackagePassword(input, password) {
|
|
38171
|
+
try {
|
|
38172
|
+
const opened = openEncryptedPackage(input);
|
|
38173
|
+
if (!opened) return false;
|
|
38174
|
+
const info = parseEncryptionInfo(opened.encryptionInfo);
|
|
38175
|
+
const key = isStandard(info) ? await verifyStandardPassword(info, password) : await verifyAgilePassword(info, password);
|
|
38176
|
+
return key !== null;
|
|
38177
|
+
} catch {
|
|
38178
|
+
return false;
|
|
38300
38179
|
}
|
|
38301
|
-
return result;
|
|
38302
38180
|
}
|
|
38303
|
-
|
|
38304
|
-
|
|
38305
|
-
|
|
38306
|
-
|
|
38307
|
-
|
|
38181
|
+
|
|
38182
|
+
// pptx/core/utils/ooxml-crypto.ts
|
|
38183
|
+
async function decryptPptx(encryptedBuffer, password) {
|
|
38184
|
+
return (await decryptOoxmlPackage(encryptedBuffer, password)).buffer;
|
|
38185
|
+
}
|
|
38186
|
+
async function encryptPptx(pptxBuffer, password, options) {
|
|
38187
|
+
return (await encryptOoxmlPackage(pptxBuffer, password, options)).buffer;
|
|
38188
|
+
}
|
|
38189
|
+
function verifyPassword(encryptedBuffer, password) {
|
|
38190
|
+
return verifyOoxmlPackagePassword(encryptedBuffer, password);
|
|
38191
|
+
}
|
|
38192
|
+
|
|
38193
|
+
// digest/password-hash.ts
|
|
38194
|
+
function spinPasswordHash(password, salt, spinCount, digest) {
|
|
38195
|
+
const input = new Uint8Array(salt.length + password.length * 2);
|
|
38196
|
+
input.set(salt);
|
|
38197
|
+
for (let i2 = 0; i2 < password.length; i2++) {
|
|
38198
|
+
const code = password.charCodeAt(i2);
|
|
38199
|
+
input[salt.length + i2 * 2] = code & 255;
|
|
38200
|
+
input[salt.length + i2 * 2 + 1] = code >> 8;
|
|
38201
|
+
}
|
|
38202
|
+
let value = digest(input);
|
|
38203
|
+
const buffer = new Uint8Array(value.length + 4);
|
|
38204
|
+
const view = new DataView(buffer.buffer);
|
|
38205
|
+
for (let i2 = 0; i2 < spinCount; i2++) {
|
|
38206
|
+
buffer.set(value);
|
|
38207
|
+
view.setUint32(value.length, i2, true);
|
|
38208
|
+
value = digest(buffer);
|
|
38209
|
+
}
|
|
38210
|
+
return value;
|
|
38308
38211
|
}
|
|
38212
|
+
|
|
38213
|
+
// pptx/core/utils/modify-verifier-codec.ts
|
|
38309
38214
|
function base64Decode2(str) {
|
|
38310
38215
|
const normalized = str.replace(/\s+/g, "");
|
|
38311
38216
|
if (typeof Buffer !== "undefined") {
|
|
@@ -38341,12 +38246,11 @@ function randomSalt() {
|
|
|
38341
38246
|
return salt;
|
|
38342
38247
|
}
|
|
38343
38248
|
async function iteratedHash(algorithm, salt, password, spinCount) {
|
|
38344
|
-
const
|
|
38345
|
-
|
|
38346
|
-
|
|
38347
|
-
h2 = await digest(algorithm, concat(h2, uint32LE2(i2)));
|
|
38249
|
+
const digest = digestFunction(algorithm);
|
|
38250
|
+
if (!digest) {
|
|
38251
|
+
throw new Error(`Unsupported digest algorithm: ${algorithm}`);
|
|
38348
38252
|
}
|
|
38349
|
-
return
|
|
38253
|
+
return spinPasswordHash(password, salt, spinCount, digest);
|
|
38350
38254
|
}
|
|
38351
38255
|
function bytesEqual2(a, b) {
|
|
38352
38256
|
if (a.length !== b.length) {
|
|
@@ -38372,10 +38276,10 @@ var CRYPT_ALGORITHM_SID_NAMES = {
|
|
|
38372
38276
|
};
|
|
38373
38277
|
function resolveModifyVerifierAlgorithmName(verifier) {
|
|
38374
38278
|
if (verifier.algorithmName) {
|
|
38375
|
-
return
|
|
38279
|
+
return normalizeDigestAlgorithmName(verifier.algorithmName);
|
|
38376
38280
|
}
|
|
38377
38281
|
if (verifier.algIdExt) {
|
|
38378
|
-
return
|
|
38282
|
+
return normalizeDigestAlgorithmName(verifier.algIdExt);
|
|
38379
38283
|
}
|
|
38380
38284
|
if (verifier.cryptAlgorithmSid !== void 0) {
|
|
38381
38285
|
return CRYPT_ALGORITHM_SID_NAMES[verifier.cryptAlgorithmSid];
|
|
@@ -38395,7 +38299,7 @@ async function verifyModifyPassword(verifier, password) {
|
|
|
38395
38299
|
}
|
|
38396
38300
|
async function createModifyVerifier(password, options) {
|
|
38397
38301
|
const requestedAlgorithm = options?.algorithmName ?? "SHA-512";
|
|
38398
|
-
const algorithm =
|
|
38302
|
+
const algorithm = normalizeDigestAlgorithmName(requestedAlgorithm);
|
|
38399
38303
|
if (!algorithm) {
|
|
38400
38304
|
throw new Error(`Unsupported modify-verifier hash algorithm: ${requestedAlgorithm}`);
|
|
38401
38305
|
}
|
|
@@ -38413,7 +38317,7 @@ async function createModifyVerifier(password, options) {
|
|
|
38413
38317
|
}
|
|
38414
38318
|
async function createSaltlessModifyVerifierForTesting(password, options) {
|
|
38415
38319
|
const requestedAlgorithm = options?.algorithmName ?? "SHA-512";
|
|
38416
|
-
const algorithm =
|
|
38320
|
+
const algorithm = normalizeDigestAlgorithmName(requestedAlgorithm);
|
|
38417
38321
|
if (!algorithm) {
|
|
38418
38322
|
throw new Error(`Unsupported modify-verifier hash algorithm: ${requestedAlgorithm}`);
|
|
38419
38323
|
}
|
|
@@ -58934,7 +58838,7 @@ function resolveEngineFonts(entries, metrics) {
|
|
|
58934
58838
|
starts.set(entry.node, nodeFontBounds2(entry.node).start);
|
|
58935
58839
|
}
|
|
58936
58840
|
let resolved = /* @__PURE__ */ new Map();
|
|
58937
|
-
for (let
|
|
58841
|
+
for (let round2 = 0; round2 < 4; round2++) {
|
|
58938
58842
|
const previous = resolved;
|
|
58939
58843
|
const refSize = (ref) => previous.get(ref) ?? starts.get(ref);
|
|
58940
58844
|
const sizes = /* @__PURE__ */ new Map();
|
|
@@ -61579,4 +61483,4 @@ async function blobUrlToDataUrl(blobUrl, fallbackMimeType) {
|
|
|
61579
61483
|
}
|
|
61580
61484
|
}
|
|
61581
61485
|
|
|
61582
|
-
export { ALL_ANIMATION_PRESETS, ARABIC_ABJADI_LETTERS, ARABIC_HIJAI_LETTERS, BLIP_FILL_ORDER, CLOUD_CALLOUT_TAIL_COUNT, CLOUD_LOBE_COUNT, COLOR_MAP_ALIAS_KEYS, CONNECTOR_ARROW_OPTIONS, CONNECTOR_GEOMETRY_OPTIONS, DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_CHART_GRADIENT_ANGLE, DEFAULT_COLOR_MAP, DEFAULT_FILL_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_SCHEME_COLOR_MAP, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_COLOR, DEFAULT_TEXT_FONT_SIZE, DGM_XMLNS, DIAGRAM_DRAWING_CONTENT_TYPE, DIAGRAM_DRAWING_REL_TYPE, DataIntegrityError, EFFECT_LST_ORDER, ELEMENT_FIELD_KIND, EMPHASIS_PRESETS, EMPTY_CONSTRAINT_INDEX, EMU_PER_INCH, EMU_PER_PIXEL, EMU_PER_POINT, EMU_PER_PX, ENTRANCE_PRESETS, ENTRY_TYPE_ROOT, EXIT_PRESETS, EncryptedFileError, FONT_SUBSTITUTION_MAP, FreeformPathBuilder, HEBREW_LETTERS, HINDI_CONSONANTS, HINDI_VOWELS, IncorrectPasswordError, MAX_SHAPE_ID, MAX_TABLE_DIMENSION, MIN_ELEMENT_SIZE, MIN_TABLE_DIMENSION, MOTION_PATH_PRESETS, OOXML_ANGLE_UNITS_PER_DEGREE, OOXML_PERCENT_UNITS, Ole2ParseError, P14_DIR_IS_ORIENTATION_TYPE, P14_GUIDE_URI, P14_TRANSITION_TYPES, P15_GUIDE_URI, PANOSE_FAMILY_MAP, PANOSE_MONOSPACE_PROPORTION, PANOSE_SANS_SERIF_STYLES, PANOSE_WEIGHT_MAP, PML_XMLNS, POWERPOINT_PRESENCE_KEY, PPTX_JSON_FILE_EXTENSION, PPTX_JSON_FORMAT, PPTX_JSON_MIME_TYPE, PPTX_JSON_VERSION, PRESENTATION_CHILD_ORDER, PRESENTATION_FIELD_KEYS, PRESENTATION_FIELD_NAMES, PRESET_COLOR_MAP, PRESET_GEOMETRY_ALIASES, PRESET_SHAPE_CATEGORY_LABELS, PRESET_SHAPE_CLIP_PATHS, PRESET_SHAPE_DEFINITIONS, PRESET_SHAPE_GEOMETRY_TABLE, PptxJsonConverter, PptxJsonFormatError, RC4_ALG_ID, RasterCanvas, SHAPE_STYLE_ORDER, SHAPE_TREE_ELEMENT_TAGS, SLIDE_FIELD_KIND, SMART_ART_DEFINITION_PARTS, SP_PR_ORDER2 as SP_PR_ORDER, STROKE_DASH_OPTIONS, STYLE_MATRIX_EFFECT_KEYS, STYLE_MATRIX_FILL_KEYS, STYLE_MATRIX_LINE_KEYS, ST_SHAPE_TYPE_VALUES, SWITCHABLE_LAYOUT_TYPES, SYSTEM_COLOR_MAP, SvgExporter, TC_PR_BORDERS_ORDER, TEXT_AUTONUMBER_SCHEMES, TEXT_ORIENTATION_IDENTITY, THAI_CONSONANTS, THEME_COLOR_SCHEME_KEYS, VML_SHAPE_TAGS, WHITESPACE_PRESERVING_TAGS, XML_PROLOG, addSmartArtNode, addSmartArtNodeAsChild, algorithmParam, alphaLabel, annotateCustomGeometryCommandOrder, annotateSmartArtTextOrder, applyActiveXControlsToSlide, applyBubbleChartOptions, applyCellWritesToWorksheet, applyChartAxisDisplayUnitsToXml, applyChartAxisLabelFormatting, applyChartAxisScaling, applyChartDateAxisUnits, applyChartGradientToSpPr, applyChartLayouts, applyChartManualLayout, applyChartUpDownBars, applyCustomGeometryGuideOverrides, applyCustomLayoutOverrides, applyCustomShows, applyDataLabelsRangeToDLbls, applyDiagramRelationshipIds, applyDrawingLineDash, applyDrawingMediaReference, applyImportedPptxData, applyKinsokuToXml, applyOleDocumentParagraphEdit, applyOleNestedDeckBytes, applyOleNestedDeckElementTextEdit, applyOleSheetCellEdit, applySections, applySeriesDataPointsToXml, applySeriesMarkerToXml, applySeriesPictureOptionsToXml, applySmartArtQuickStyle3d, applySmartArtRoleColors, applyTextBodySp3d, applyThemeOverrideToSlide, applyThemeToData, areNamespacesSupported, arrangeComposite, arrangeConn, arrangeCycle, arrangeHierarchy, arrangeLinear, arrangePyramid, arrangeSnake, arrangeSpacer, arrangeText, avLstForPreset, base64Decode, base64ToBytes, bijectiveLabel, blobUrlToDataUrl, buildActiveXControlNode, buildCalloutLeaderLineSvgPath, buildChartGradFillXml, buildChartMarkerXml, buildChartUniqueIdExtLst, buildClrMapOverrideXml, buildConstraintIndex, buildCustomGeometryPathsFromNodes, buildDefRPrTextProperties, buildEffectDagTreeFromXml, buildFabricatedDiagramDataXml, buildFabricatedDrawingXml, buildFontFamilyString, buildForest, buildGuideListExtension, buildInkMlContent, buildLinkedTextBoxChains, buildNodeGuidMap, buildOle2, buildPointFromParagraphs, buildPointFromRuns, buildPointText, buildPptxJsonDocument, buildPresentationGuidMap, buildSaveTimeCustomGeometryXml, buildSmartArtColorLists, buildSmartArtColorRoleMap, buildSrgbColorChoice, buildThemeColorMap, buildTree, buildTrendlineLabel, bytesToBase64, captureStyleBaseline, catmullRomToBezier, chartColorChoiceValue, chartColorHex, chartDataAddCategory, chartDataAddSeries, chartDataChangeType, chartDataRemoveCategory, chartDataRemoveSeries, chartDataUpdatePoint, chartGradientsEqual, chartGridAddCategory, chartGridAddSeries, chartGridRemoveCategory, chartGridRemoveSeries, chartGridSetCategoryLabel, chartGridSetCellValue, checkBlankSlide, checkComplexTables, checkDuplicateTitles, checkLowContrast, checkMissingAltText, checkMissingSlideTitle, checkPresentation, chevronPoints, chooseAlgType, circleNode, clampByRules, classifyPanose, collectAllText, colorsEqual, colour, combineShapes, computeContrastRatio, computeSmartArtElementsWithoutCache, concatArrays, containsConvertibleStrictNamespaceAttribute, convertMetafileToDataUrl, convertXmlToStrict, createArrayBufferCopy, createBuiltinVariables, createDrawingObjectId, createEditorId, createLineStyleGate, createModifyVerifier, createOfficeGuid, createSaltlessModifyVerifierForTesting, createTemplateConnectorRawXml, createTemplateShapeRawXml, createUniformTextSegments, cropShapeForPresetGeometry, cssDegreesToOoxmlGradientAngle, customGeometryPathsToSvgSubpaths, decodeJsonValue, decodeOle10Native, decodePngDimensions, decodePptxJsonText, decodeXmlEntities, decomposeSmartArt, decryptPptx, demoteSmartArtNode, deobfuscateFont, deriveSlideTitle, deriveSlideTitles, deserializePptxFromJson, detectDigitalSignatures, detectFileFormat, detectFontFormat, detectOleObjectType, detectOlePayloadEditorKind, detectStrictConformance, discoverArrangement, distributeSegmentsAcrossChain, douglasPeucker, effectChild, elementActionToPptxAction, elementHasAction, emu, encodeCompressedPng, encodeJsonValue, encodeOle10Native, encodePasswordUtf16LE, encodePng, encodeXmlAttributeValue, encodeXmlTextValue, encryptPptx, ensureArrayValue, ensureXmlChild, ensureXmlChildOrCreate, ensureXmlChildren, esc, escAttr, escText, estimateMediaDurationMs, estimateTextBoxCapacity, evaluateCustomGeometryPathData, evaluateCustomGeometryPaths, evaluateGeometryPaths, evaluateGuides, evaluatePresetShape, expandRangeAddresses, extractColorChoiceXml, extractGuidFromPartName, extractModel3DTransform, extractStyleReferenceColorXml, fetchUrlToBytes, fillIsPurelyStyleMatrix, filterValidShapeAdjustmentEntries, findChartExtByUri, findChildByLocalName, findCnvPrNode, findConstraint, findCustomShow, findKey6 as findKey, firstParagraphRuns, fitFontSize, flattenChartUserShapes, flattenNodes, formatAutoNumberMarker, formatCommentTimestamp, formatScriptAutoNumber, fragmentShapes, gearPoints, generateFontGuid, getAdjustmentAwareClipPath, getAdjustmentAwareShapeClipPath, getAnimationPresetInfo, getCalloutLeaderLineGeometry, getCalloutTier, getCalloutViewBoxBounds, getCloudCalloutClipPath, getCloudClipPath, getCloudPathForRendering, getCommentMarkerPosition, getConnectorAdjustment, getConnectorPathGeometry, getCssBorderDashStyle, getCustomShowNames, getCustomShowPositionLabel, getElementLabel, getElementOrientationMatrix, getElementTextContent, getElementTransform, getImageMaskStyle, getLinkedTextBoxSegments, getNativeAnimationPresetMetadata, getOleDocumentParagraphs, getOleNestedDeckBytes, getOleNestedDeckDetail, getOleObjectTypeLabel, getOleSheetGrid, getPanoseWeight, getPresetConnectionSites, getPresetShapeClipPath, getPresetTextRect, getPresetsByCategory, getRoundRectRadiusPx, getSectionSlideRange, getShapeClipPath, getShapeClipPathFromPreset, getShapeType, getSignaturePathsToStrip, getSubstituteFontFamily, getSubstituteFonts, getSupportedNamespaces, getSvgStrokeDasharray, getTextCompensationTransform, getZoomElements, getZoomTargetSlideIndexes, gradFill, groupElements, guidToKey, guideEmuToPx, guidePxToEmu, hasDirectSubstitution, hasNonTrivialOverride, hasReference, hasShapeProperties, hasTextProperties, hash, hebrewAlphaLabel, inferOleExtensionFromTarget, inheritCustomGeometryCommandOrder, inheritedPlaceholderFieldType, inkBounds, inkElementToStrokes, inkLengthToPx, inkPointMapper, insertAt2 as insertAt, interpretSmartArtLayout, interpretedLayoutToElements, intersectPolygons, intersectShapes, intersectSvgPaths, isAlternateContentChoiceSupported, isAlternateContentChoiceXmlSupported, isCalloutShape, isConnectorElement, isContentPoint, isDefaultSmartArtLabelScene, isEditableTextElement, isHeaderFooterPlaceholder, isImageLikeElement, isInkElement, isNamespaceSupported, isOle2CompoundFile, isParetoChartData, isPptxJsonText, isShapeElement, isStShapeType, isStrictNamespaceUri, isSummaryZoomSlide, isSwitchableLayoutType, isTemplateElement, isTemplateElementId, isTextElement, isTextOrientationMatrix, isTransitionalNamespaceUri, isXmlNode, isZoomElement, isZoomElement2, itemNode, lookupPresetConnectionSites, lookupPresetShape, lookupPresetTextRectOverride, makeStoreAwareId, md4, mergeAttributeEffectNode, mergeEffectNode, mergeShapes, mergeSmartArtConnectionXml, mergeSmartArtPointXml, mergeStyleParts, mergeThemeColorOverride, mimeTypeForOleFile, multiplyTextOrientationMatrices, navigateCustomShow, newSmartArtGuid, nodeFill, nodeOpacity, nodeStroke, nodeTextStyle, normalizeNamespaceUri, normalizePositiveFixedAngleDegrees, normalizeStShapeType, normalizeStrictXml, normalizeStrokeDashType, numericParam, obfuscateFont, oleBytesToDataUrl, oleObjectTypeToGlyph, ooxmlArcToSvg, ooxmlGradientAngleToCssDegrees, orderedXmlKey, parseActiveXControlsFromSlide, parseAdjustmentValues, parseAlignmentAttr, parseBodyPrBooleanAttrs, parseBubbleChartOptions, parseBulletSizePercent, parseChart3DSurfaces, parseChartAxes, parseChartDataLabelOptions, parseChartDataPointPicture, parseChartDataPointPictureBlipRel, parseChartFormulaRange, parseChartLayouts, parseChartManualLayout, parseChartUniqueId, parseChartUpDownBars, parseChartUserShapesDrawing, parseChartWideTextStyle, parseCustomShows, parseCxChartSeries, parseDataTable, parseDataUrlToBytes, parseDefRPrTextStyle, parseDiagramRelationshipIds, parseDrawingColor, parseDrawingColorChoice, parseDrawingColorOpacity, parseDrawingLineDash, parseDrawingMediaReference, parseEmbeddedXlsx, parseEncryptionInfo, parseGuideDefinitions, parseHexColor, parseImplicitBlipPictureFill, parseInkMlContent, parseKinsoku, parseLineStyle, parseMarker, parseModel3DScene, parseOle2, parseP14DirectChild, parseP14FromExtLst, parsePanoseBytes, parsePanoseString, parseParagraphExtraAttributes, parseParagraphLevel, parseParagraphMargins, parseParagraphRtl, parsePptxJson, parsePptxJsonDocument, parsePresentationDrawingGuides, parsePresentationSmartTags, parseSeriesDataLabels, parseSeriesDataPoints, parseSeriesErrBars, parseSeriesExplosion, parseSeriesTrendlines, parseShapeId, parseShapeProps, parseSignatureXml, parseSlideDrawingGuides, parseSmartArtColorListHexes, parseSmartArtColorStyleLabels, parseSmartArtConnection, parseSmartArtDefinitionHeaderList, parseSmartArtDefinitionMetadata, parseSmartArtPointCustomLayout, parseSmartArtPresLayoutVars, parseSmartArtQuickStyleLabels, parseSmartArtStyleLabelRefs, parseSmartArtTextParagraphs, parseStructuredCustomGeometry, parseTabStops, parseVmlElement, parseVmlElements, polygonNode, polygonsToSvgPath, positiveFixedAngleAttribute, pptxActionToElementAction, pptxDataFromJsonDocument, preservesSpreadsheetXmlWhitespace, preservesXmlWhitespace, presetGeometryForCropShape, prismFamilyFlags, prismFamilyTypeForFlags, prismFamilyTypeOfNode, projectSmartArtNodeText, promoteSmartArtNode, ratioConstraint, reResolveElementColors, reResolveElementFonts, reResolveSlideColors, reResolveSlideFonts, readFileAsDataUrl, readOleDocParagraphs, readOleDocumentParagraphs, readOleNestedDeckDetail, readOleNestedDeckFirstSlideTextLines, readOleSheetGrid, readOleXlsGrid, reapplyAlternateContentToTree, reassignDescendantIds, rectNode, reflowSmartArtLayout, regenerateClonedUniqueId, regenerateSmartArtDrawingShapes, relativeLuminance, relayoutSmartArt, remapElementShapeIds, remapShapeIdReferences, removeSmartArtNode, renderOleDeckPreviewPng, renderOleDocumentPreviewPng, renderOleIconPng, renderOleSheetPreviewPng, reorderObjectKeys, reorderObjectKeysByLocalName, reorderSmartArtNode, reorderSmartArtNodeToIndex, repairPptx, repeatedLabel, replaceFirstText, replaceOleEmbedding, replaceOleFile, resetDecomposeCounter, resetSmartArtEditCounter, resetSpPrFormattingForStyleMatrix, resolveConstraint, resolveConstraintDeclaredBy, resolveCoordinate, resolveCustomGeometryGuideContext, resolveCustomGeometryToken, resolveCustomShowSlideIndices, resolveDisplayedChartTypeName, resolveFlowDirection, resolveLayoutDisplayName, resolveModel3DMimeType, resolveModifyVerifierAlgorithmName, resolveOleEditorKindFromPayload, resolveParagraphAlignment, resolveRatioConstraint, resolveSmartArtEffectIntensity, resolveSmartArtNodeCoherent3DOff, resolveSmartArtNodeStyleRoles, resolveTableCellStyle, resolveTxPrDefRPr, rgb, roleOf, romanNumeral, roundCoordinate, safeResolveZipPath, sampleFirstPixelColorFromBytes, scaleVectorToIntegers, selectAlternateContentBranch, selectArrangedNodes, serializeColorChoice, serializeColorChoiceWithRef, serializePptxToJson, serializeSmartArtDefinitionHeaderList, serializeTabStop, setAutoTitleDeleted, setOleObjectName, setSmartArtNodeStyle, shadowOffsetToDistanceAndDirection, shouldRebuildFromParagraphs, shouldRebuildFromRuns, shouldRenderFallbackLabel, shouldReturnToZoomSlide, smartArtParagraphsText, smartArtQuickStyleHas3d, solidFill, stripParentDirSegments, stripXmlOrderMarkers, stripXmlOrderSuffix, strokeFor, styleContext, styleShadow, styleStroke, subtractPolygons, subtractShapes, subtractSvgPaths, supportsChartGradientFill, svgPathToPolygons, svgToCustomGeometryPaths, switchSmartArtLayout, syncPictureShapeTypeWithCropShape, themeColorSchemesEqual, toArabicAbjadNumeral, toChineseNumeral, toCjkDigitString, toDevanagariDigits, toEa1ChsNumeral, toEa1ChtNumeral, toFullWidthDigits, toHebrewNumeral, toStrictNamespaceUri, toThaiDigits, treeDepth, treeWidth, truncate, uint32LE, ungroupElements, unionPolygons, unionShapes, unionSvgPaths, unwrapAlternateContent, unwrapOleEmbedding, updateSmartArtNodeText, upsertChartAxisChild, validatePptx, validateSmartArtColorStyleLabels, validateSmartArtDefinitionHeaderList, validateSmartArtDefinitionMetadata, verifyModifyPassword, verifyPassword, verifySignatureDigests, visitXmlObjects, withThemePlaceholderColor, writeBodyPrBooleanAttrs, writeChartColorChoice, writeChartShapeProps, writeOleDocParagraphEdit, writeOleDocumentParagraphEdit, writeOleNestedDeckElementText, writeOleSheetCellEdit, writeOleXlsNumericCellEdit, writeOleXlsStringCellEdit, writeShapeEffects, xmlAttr, xmlAttrBool, xmlAttrNumber, xmlChild, xmlChildren, xmlEscape, xmlHasChild, xmlPath, xmlText, zlibDeflate, zlibStore };
|
|
61486
|
+
export { ALL_ANIMATION_PRESETS, ARABIC_ABJADI_LETTERS, ARABIC_HIJAI_LETTERS, BLIP_FILL_ORDER, CLOUD_CALLOUT_TAIL_COUNT, CLOUD_LOBE_COUNT, COLOR_MAP_ALIAS_KEYS, CONNECTOR_ARROW_OPTIONS, CONNECTOR_GEOMETRY_OPTIONS, DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_CHART_GRADIENT_ANGLE, DEFAULT_COLOR_MAP, DEFAULT_FILL_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_SCHEME_COLOR_MAP, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_COLOR, DEFAULT_TEXT_FONT_SIZE, DGM_XMLNS, DIAGRAM_DRAWING_CONTENT_TYPE, DIAGRAM_DRAWING_REL_TYPE, DataIntegrityError, EFFECT_LST_ORDER, ELEMENT_FIELD_KIND, EMPHASIS_PRESETS, EMPTY_CONSTRAINT_INDEX, EMU_PER_INCH, EMU_PER_PIXEL, EMU_PER_POINT, EMU_PER_PX, ENTRANCE_PRESETS, ENTRY_TYPE_ROOT, EXIT_PRESETS, EncryptedFileError, FONT_SUBSTITUTION_MAP, FreeformPathBuilder, HEBREW_LETTERS, HINDI_CONSONANTS, HINDI_VOWELS, IncorrectPasswordError, MAX_SHAPE_ID, MAX_TABLE_DIMENSION, MIN_ELEMENT_SIZE, MIN_TABLE_DIMENSION, MOTION_PATH_PRESETS, OOXML_ANGLE_UNITS_PER_DEGREE, OOXML_PERCENT_UNITS, Ole2ParseError, P14_DIR_IS_ORIENTATION_TYPE, P14_GUIDE_URI, P14_TRANSITION_TYPES, P15_GUIDE_URI, PANOSE_FAMILY_MAP, PANOSE_MONOSPACE_PROPORTION, PANOSE_SANS_SERIF_STYLES, PANOSE_WEIGHT_MAP, PML_XMLNS, POWERPOINT_PRESENCE_KEY, PPTX_JSON_FILE_EXTENSION, PPTX_JSON_FORMAT, PPTX_JSON_MIME_TYPE, PPTX_JSON_VERSION, PRESENTATION_CHILD_ORDER, PRESENTATION_FIELD_KEYS, PRESENTATION_FIELD_NAMES, PRESET_COLOR_MAP, PRESET_GEOMETRY_ALIASES, PRESET_SHAPE_CATEGORY_LABELS, PRESET_SHAPE_CLIP_PATHS, PRESET_SHAPE_DEFINITIONS, PRESET_SHAPE_GEOMETRY_TABLE, PptxJsonConverter, PptxJsonFormatError, RC4_ALG_ID, RasterCanvas, SHAPE_STYLE_ORDER, SHAPE_TREE_ELEMENT_TAGS, SLIDE_FIELD_KIND, SMART_ART_DEFINITION_PARTS, SP_PR_ORDER2 as SP_PR_ORDER, STROKE_DASH_OPTIONS, STYLE_MATRIX_EFFECT_KEYS, STYLE_MATRIX_FILL_KEYS, STYLE_MATRIX_LINE_KEYS, ST_SHAPE_TYPE_VALUES, SWITCHABLE_LAYOUT_TYPES, SYSTEM_COLOR_MAP, SvgExporter, TC_PR_BORDERS_ORDER, TEXT_AUTONUMBER_SCHEMES, TEXT_ORIENTATION_IDENTITY, THAI_CONSONANTS, THEME_COLOR_SCHEME_KEYS, VML_SHAPE_TAGS, WHITESPACE_PRESERVING_TAGS, XML_PROLOG, addSmartArtNode, addSmartArtNodeAsChild, algorithmParam, alphaLabel, annotateCustomGeometryCommandOrder, annotateSmartArtTextOrder, applyActiveXControlsToSlide, applyBubbleChartOptions, applyCellWritesToWorksheet, applyChartAxisDisplayUnitsToXml, applyChartAxisLabelFormatting, applyChartAxisScaling, applyChartDateAxisUnits, applyChartGradientToSpPr, applyChartLayouts, applyChartManualLayout, applyChartUpDownBars, applyCustomGeometryGuideOverrides, applyCustomLayoutOverrides, applyCustomShows, applyDataLabelsRangeToDLbls, applyDiagramRelationshipIds, applyDrawingLineDash, applyDrawingMediaReference, applyImportedPptxData, applyKinsokuToXml, applyOleDocumentParagraphEdit, applyOleNestedDeckBytes, applyOleNestedDeckElementTextEdit, applyOleSheetCellEdit, applySections, applySeriesDataPointsToXml, applySeriesMarkerToXml, applySeriesPictureOptionsToXml, applySmartArtQuickStyle3d, applySmartArtRoleColors, applyTextBodySp3d, applyThemeOverrideToSlide, applyThemeToData, areNamespacesSupported, arrangeComposite, arrangeConn, arrangeCycle, arrangeHierarchy, arrangeLinear, arrangePyramid, arrangeSnake, arrangeSpacer, arrangeText, avLstForPreset, base64Decode, base64ToBytes, bijectiveLabel, blobUrlToDataUrl, buildActiveXControlNode, buildCalloutLeaderLineSvgPath, buildChartGradFillXml, buildChartMarkerXml, buildChartUniqueIdExtLst, buildClrMapOverrideXml, buildConstraintIndex, buildCustomGeometryPathsFromNodes, buildDefRPrTextProperties, buildEffectDagTreeFromXml, buildFabricatedDiagramDataXml, buildFabricatedDrawingXml, buildFontFamilyString, buildForest, buildGuideListExtension, buildInkMlContent, buildLinkedTextBoxChains, buildNodeGuidMap, buildOle2, buildPointFromParagraphs, buildPointFromRuns, buildPointText, buildPptxJsonDocument, buildPresentationGuidMap, buildSaveTimeCustomGeometryXml, buildSmartArtColorLists, buildSmartArtColorRoleMap, buildSrgbColorChoice, buildThemeColorMap, buildTree, buildTrendlineLabel, bytesToBase64, captureStyleBaseline, catmullRomToBezier, chartColorChoiceValue, chartColorHex, chartDataAddCategory, chartDataAddSeries, chartDataChangeType, chartDataRemoveCategory, chartDataRemoveSeries, chartDataUpdatePoint, chartGradientsEqual, chartGridAddCategory, chartGridAddSeries, chartGridRemoveCategory, chartGridRemoveSeries, chartGridSetCategoryLabel, chartGridSetCellValue, checkBlankSlide, checkComplexTables, checkDuplicateTitles, checkLowContrast, checkMissingAltText, checkMissingSlideTitle, checkPresentation, chevronPoints, chooseAlgType, circleNode, clampByRules, classifyPanose, collectAllText, colorsEqual, colour, combineShapes, computeContrastRatio, computeSmartArtElementsWithoutCache, concatArrays, containsConvertibleStrictNamespaceAttribute, convertMetafileToDataUrl, convertXmlToStrict, createArrayBufferCopy, createBuiltinVariables, createDrawingObjectId, createEditorId, createLineStyleGate, createModifyVerifier, createOfficeGuid, createSaltlessModifyVerifierForTesting, createTemplateConnectorRawXml, createTemplateShapeRawXml, createUniformTextSegments, cropShapeForPresetGeometry, cssDegreesToOoxmlGradientAngle, customGeometryPathsToSvgSubpaths, decodeJsonValue, decodeOle10Native, decodePngDimensions, decodePptxJsonText, decodeXmlEntities, decomposeSmartArt, decryptPptx, demoteSmartArtNode, deobfuscateFont, deriveSlideTitle, deriveSlideTitles, deserializePptxFromJson, detectDigitalSignatures, detectFileFormat, detectFontFormat, detectOleObjectType, detectOlePayloadEditorKind, detectStrictConformance, discoverArrangement, distributeSegmentsAcrossChain, douglasPeucker, effectChild, elementActionToPptxAction, elementHasAction, emu, encodeCompressedPng, encodeJsonValue, encodeOle10Native, encodePasswordUtf16LE, encodePng, encodeXmlAttributeValue, encodeXmlTextValue, encryptPptx, ensureArrayValue, ensureXmlChild, ensureXmlChildOrCreate, ensureXmlChildren, esc, escAttr, escText, estimateMediaDurationMs, estimateTextBoxCapacity, evaluateCustomGeometryPathData, evaluateCustomGeometryPaths, evaluateGeometryPaths, evaluateGuides, evaluatePresetShape, expandRangeAddresses, extractColorChoiceXml, extractGuidFromPartName, extractModel3DTransform, extractStyleReferenceColorXml, fetchUrlToBytes, fillIsPurelyStyleMatrix, filterValidShapeAdjustmentEntries, findChartExtByUri, findChildByLocalName, findCnvPrNode, findConstraint, findCustomShow, findKey6 as findKey, firstParagraphRuns, fitFontSize, flattenChartUserShapes, flattenNodes, formatAutoNumberMarker, formatCommentTimestamp, formatScriptAutoNumber, fragmentShapes, gearPoints, generateFontGuid, getAdjustmentAwareClipPath, getAdjustmentAwareShapeClipPath, getAnimationPresetInfo, getCalloutLeaderLineGeometry, getCalloutTier, getCalloutViewBoxBounds, getCloudCalloutClipPath, getCloudClipPath, getCloudPathForRendering, getCommentMarkerPosition, getConnectorAdjustment, getConnectorPathGeometry, getCssBorderDashStyle, getCustomShowNames, getCustomShowPositionLabel, getElementLabel, getElementOrientationMatrix, getElementTextContent, getElementTransform, getImageMaskStyle, getLinkedTextBoxSegments, getNativeAnimationPresetMetadata, getOleDocumentParagraphs, getOleNestedDeckBytes, getOleNestedDeckDetail, getOleObjectTypeLabel, getOleSheetGrid, getPanoseWeight, getPresetConnectionSites, getPresetShapeClipPath, getPresetTextRect, getPresetsByCategory, getRoundRectRadiusPx, getSectionSlideRange, getShapeClipPath, getShapeClipPathFromPreset, getShapeType, getSignaturePathsToStrip, getSubstituteFontFamily, getSubstituteFonts, getSupportedNamespaces, getSvgStrokeDasharray, getTextCompensationTransform, getZoomElements, getZoomTargetSlideIndexes, gradFill, groupElements, guidToKey, guideEmuToPx, guidePxToEmu, hasDirectSubstitution, hasNonTrivialOverride, hasReference, hasShapeProperties, hasTextProperties, hash, hebrewAlphaLabel, inferOleExtensionFromTarget, inheritCustomGeometryCommandOrder, inheritedPlaceholderFieldType, inkBounds, inkElementToStrokes, inkLengthToPx, inkPointMapper, insertAt2 as insertAt, interpretSmartArtLayout, interpretedLayoutToElements, intersectPolygons, intersectShapes, intersectSvgPaths, isAlternateContentChoiceSupported, isAlternateContentChoiceXmlSupported, isCalloutShape, isConnectorElement, isContentPoint, isDefaultSmartArtLabelScene, isEditableTextElement, isHeaderFooterPlaceholder, isImageLikeElement, isInkElement, isNamespaceSupported, isOle2CompoundFile, isParetoChartData, isPptxJsonText, isShapeElement, isStShapeType, isStrictNamespaceUri, isSummaryZoomSlide, isSwitchableLayoutType, isTemplateElement, isTemplateElementId, isTextElement, isTextOrientationMatrix, isTransitionalNamespaceUri, isXmlNode, isZoomElement, isZoomElement2, itemNode, lookupPresetConnectionSites, lookupPresetShape, lookupPresetTextRectOverride, makeStoreAwareId, mergeAttributeEffectNode, mergeEffectNode, mergeShapes, mergeSmartArtConnectionXml, mergeSmartArtPointXml, mergeStyleParts, mergeThemeColorOverride, mimeTypeForOleFile, multiplyTextOrientationMatrices, navigateCustomShow, newSmartArtGuid, nodeFill, nodeOpacity, nodeStroke, nodeTextStyle, normalizeNamespaceUri, normalizePositiveFixedAngleDegrees, normalizeStShapeType, normalizeStrictXml, normalizeStrokeDashType, numericParam, obfuscateFont, oleBytesToDataUrl, oleObjectTypeToGlyph, ooxmlArcToSvg, ooxmlGradientAngleToCssDegrees, orderedXmlKey, parseActiveXControlsFromSlide, parseAdjustmentValues, parseAlignmentAttr, parseBodyPrBooleanAttrs, parseBubbleChartOptions, parseBulletSizePercent, parseChart3DSurfaces, parseChartAxes, parseChartDataLabelOptions, parseChartDataPointPicture, parseChartDataPointPictureBlipRel, parseChartFormulaRange, parseChartLayouts, parseChartManualLayout, parseChartUniqueId, parseChartUpDownBars, parseChartUserShapesDrawing, parseChartWideTextStyle, parseCustomShows, parseCxChartSeries, parseDataTable, parseDataUrlToBytes, parseDefRPrTextStyle, parseDiagramRelationshipIds, parseDrawingColor, parseDrawingColorChoice, parseDrawingColorOpacity, parseDrawingLineDash, parseDrawingMediaReference, parseEmbeddedXlsx, parseEncryptionInfo, parseGuideDefinitions, parseHexColor, parseImplicitBlipPictureFill, parseInkMlContent, parseKinsoku, parseLineStyle, parseMarker, parseModel3DScene, parseOle2, parseP14DirectChild, parseP14FromExtLst, parsePanoseBytes, parsePanoseString, parseParagraphExtraAttributes, parseParagraphLevel, parseParagraphMargins, parseParagraphRtl, parsePptxJson, parsePptxJsonDocument, parsePresentationDrawingGuides, parsePresentationSmartTags, parseSeriesDataLabels, parseSeriesDataPoints, parseSeriesErrBars, parseSeriesExplosion, parseSeriesTrendlines, parseShapeId, parseShapeProps, parseSignatureXml, parseSlideDrawingGuides, parseSmartArtColorListHexes, parseSmartArtColorStyleLabels, parseSmartArtConnection, parseSmartArtDefinitionHeaderList, parseSmartArtDefinitionMetadata, parseSmartArtPointCustomLayout, parseSmartArtPresLayoutVars, parseSmartArtQuickStyleLabels, parseSmartArtStyleLabelRefs, parseSmartArtTextParagraphs, parseStructuredCustomGeometry, parseTabStops, parseVmlElement, parseVmlElements, polygonNode, polygonsToSvgPath, positiveFixedAngleAttribute, pptxActionToElementAction, pptxDataFromJsonDocument, preservesSpreadsheetXmlWhitespace, preservesXmlWhitespace, presetGeometryForCropShape, prismFamilyFlags, prismFamilyTypeForFlags, prismFamilyTypeOfNode, projectSmartArtNodeText, promoteSmartArtNode, ratioConstraint, reResolveElementColors, reResolveElementFonts, reResolveSlideColors, reResolveSlideFonts, readFileAsDataUrl, readOleDocParagraphs, readOleDocumentParagraphs, readOleNestedDeckDetail, readOleNestedDeckFirstSlideTextLines, readOleSheetGrid, readOleXlsGrid, reapplyAlternateContentToTree, reassignDescendantIds, rectNode, reflowSmartArtLayout, regenerateClonedUniqueId, regenerateSmartArtDrawingShapes, relativeLuminance, relayoutSmartArt, remapElementShapeIds, remapShapeIdReferences, removeSmartArtNode, renderOleDeckPreviewPng, renderOleDocumentPreviewPng, renderOleIconPng, renderOleSheetPreviewPng, reorderObjectKeys, reorderObjectKeysByLocalName, reorderSmartArtNode, reorderSmartArtNodeToIndex, repairPptx, repeatedLabel, replaceFirstText, replaceOleEmbedding, replaceOleFile, resetDecomposeCounter, resetSmartArtEditCounter, resetSpPrFormattingForStyleMatrix, resolveConstraint, resolveConstraintDeclaredBy, resolveCoordinate, resolveCustomGeometryGuideContext, resolveCustomGeometryToken, resolveCustomShowSlideIndices, resolveDisplayedChartTypeName, resolveFlowDirection, resolveLayoutDisplayName, resolveModel3DMimeType, resolveModifyVerifierAlgorithmName, resolveOleEditorKindFromPayload, resolveParagraphAlignment, resolveRatioConstraint, resolveSmartArtEffectIntensity, resolveSmartArtNodeCoherent3DOff, resolveSmartArtNodeStyleRoles, resolveTableCellStyle, resolveTxPrDefRPr, rgb, roleOf, romanNumeral, roundCoordinate, safeResolveZipPath, sampleFirstPixelColorFromBytes, scaleVectorToIntegers, selectAlternateContentBranch, selectArrangedNodes, serializeColorChoice, serializeColorChoiceWithRef, serializePptxToJson, serializeSmartArtDefinitionHeaderList, serializeTabStop, setAutoTitleDeleted, setOleObjectName, setSmartArtNodeStyle, shadowOffsetToDistanceAndDirection, shouldRebuildFromParagraphs, shouldRebuildFromRuns, shouldRenderFallbackLabel, shouldReturnToZoomSlide, smartArtParagraphsText, smartArtQuickStyleHas3d, solidFill, stripParentDirSegments, stripXmlOrderMarkers, stripXmlOrderSuffix, strokeFor, styleContext, styleShadow, styleStroke, subtractPolygons, subtractShapes, subtractSvgPaths, supportsChartGradientFill, svgPathToPolygons, svgToCustomGeometryPaths, switchSmartArtLayout, syncPictureShapeTypeWithCropShape, themeColorSchemesEqual, toArabicAbjadNumeral, toChineseNumeral, toCjkDigitString, toDevanagariDigits, toEa1ChsNumeral, toEa1ChtNumeral, toFullWidthDigits, toHebrewNumeral, toStrictNamespaceUri, toThaiDigits, treeDepth, treeWidth, truncate, uint32LE, ungroupElements, unionPolygons, unionShapes, unionSvgPaths, unwrapAlternateContent, unwrapOleEmbedding, updateSmartArtNodeText, upsertChartAxisChild, validatePptx, validateSmartArtColorStyleLabels, validateSmartArtDefinitionHeaderList, validateSmartArtDefinitionMetadata, verifyModifyPassword, verifyPassword, verifySignatureDigests, visitXmlObjects, withThemePlaceholderColor, writeBodyPrBooleanAttrs, writeChartColorChoice, writeChartShapeProps, writeOleDocParagraphEdit, writeOleDocumentParagraphEdit, writeOleNestedDeckElementText, writeOleSheetCellEdit, writeOleXlsNumericCellEdit, writeOleXlsStringCellEdit, writeShapeEffects, xmlAttr, xmlAttrBool, xmlAttrNumber, xmlChild, xmlChildren, xmlEscape, xmlHasChild, xmlPath, xmlText, zlibDeflate, zlibStore };
|