@jscrypto/classic 0.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/LICENSE +21 -0
- package/README.md +89 -0
- package/dist/adapter/crypto-js.d.ts +19 -0
- package/dist/adapter/crypto-js.d.ts.map +1 -0
- package/dist/adapter/crypto-js.js +49 -0
- package/dist/adapter/crypto-js.js.map +1 -0
- package/dist/ciphers/aes.d.ts +4 -0
- package/dist/ciphers/aes.d.ts.map +1 -0
- package/dist/ciphers/aes.js +23 -0
- package/dist/ciphers/aes.js.map +1 -0
- package/dist/ciphers/des.d.ts +4 -0
- package/dist/ciphers/des.d.ts.map +1 -0
- package/dist/ciphers/des.js +23 -0
- package/dist/ciphers/des.js.map +1 -0
- package/dist/ciphers/rc4.d.ts +8 -0
- package/dist/ciphers/rc4.d.ts.map +1 -0
- package/dist/ciphers/rc4.js +98 -0
- package/dist/ciphers/rc4.js.map +1 -0
- package/dist/ciphers/triple-des.d.ts +4 -0
- package/dist/ciphers/triple-des.d.ts.map +1 -0
- package/dist/ciphers/triple-des.js +23 -0
- package/dist/ciphers/triple-des.js.map +1 -0
- package/dist/formats/openssl.d.ts +4 -0
- package/dist/formats/openssl.d.ts.map +1 -0
- package/dist/formats/openssl.js +34 -0
- package/dist/formats/openssl.js.map +1 -0
- package/dist/index.cjs +948 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +892 -0
- package/dist/index.mjs.map +7 -0
- package/dist/jscrypto-classic.iife.js +8012 -0
- package/dist/jscrypto-classic.iife.js.map +7 -0
- package/dist/jscrypto-classic.iife.min.js +28 -0
- package/dist/jscrypto-classic.iife.min.js.map +7 -0
- package/dist/jscrypto-classic.umd.js +8023 -0
- package/dist/jscrypto-classic.umd.js.map +7 -0
- package/dist/jscrypto-classic.umd.min.js +39 -0
- package/dist/jscrypto-classic.umd.min.js.map +7 -0
- package/dist/kdfs/evpkdf.d.ts +11 -0
- package/dist/kdfs/evpkdf.d.ts.map +1 -0
- package/dist/kdfs/evpkdf.js +46 -0
- package/dist/kdfs/evpkdf.js.map +1 -0
- package/dist/kdfs/pbkdf2.d.ts +11 -0
- package/dist/kdfs/pbkdf2.d.ts.map +1 -0
- package/dist/kdfs/pbkdf2.js +44 -0
- package/dist/kdfs/pbkdf2.js.map +1 -0
- package/dist/modes/cbc.d.ts +3 -0
- package/dist/modes/cbc.d.ts.map +1 -0
- package/dist/modes/cbc.js +56 -0
- package/dist/modes/cbc.js.map +1 -0
- package/dist/modes/cfb.d.ts +3 -0
- package/dist/modes/cfb.d.ts.map +1 -0
- package/dist/modes/cfb.js +51 -0
- package/dist/modes/cfb.js.map +1 -0
- package/dist/modes/ctr.d.ts +3 -0
- package/dist/modes/ctr.d.ts.map +1 -0
- package/dist/modes/ctr.js +46 -0
- package/dist/modes/ctr.js.map +1 -0
- package/dist/modes/ecb.d.ts +3 -0
- package/dist/modes/ecb.d.ts.map +1 -0
- package/dist/modes/ecb.js +46 -0
- package/dist/modes/ecb.js.map +1 -0
- package/dist/modes/gcm.d.ts +3 -0
- package/dist/modes/gcm.d.ts.map +1 -0
- package/dist/modes/gcm.js +14 -0
- package/dist/modes/gcm.js.map +1 -0
- package/dist/modes/ofb.d.ts +3 -0
- package/dist/modes/ofb.d.ts.map +1 -0
- package/dist/modes/ofb.js +38 -0
- package/dist/modes/ofb.js.map +1 -0
- package/dist/paddings/ansi-x923.d.ts +3 -0
- package/dist/paddings/ansi-x923.d.ts.map +1 -0
- package/dist/paddings/ansi-x923.js +36 -0
- package/dist/paddings/ansi-x923.js.map +1 -0
- package/dist/paddings/iso10126.d.ts +3 -0
- package/dist/paddings/iso10126.d.ts.map +1 -0
- package/dist/paddings/iso10126.js +45 -0
- package/dist/paddings/iso10126.js.map +1 -0
- package/dist/paddings/iso97971.d.ts +3 -0
- package/dist/paddings/iso97971.d.ts.map +1 -0
- package/dist/paddings/iso97971.js +35 -0
- package/dist/paddings/iso97971.js.map +1 -0
- package/dist/paddings/none.d.ts +3 -0
- package/dist/paddings/none.d.ts.map +1 -0
- package/dist/paddings/none.js +17 -0
- package/dist/paddings/none.js.map +1 -0
- package/dist/paddings/pkcs7.d.ts +3 -0
- package/dist/paddings/pkcs7.d.ts.map +1 -0
- package/dist/paddings/pkcs7.js +27 -0
- package/dist/paddings/pkcs7.js.map +1 -0
- package/dist/paddings/zero.d.ts +3 -0
- package/dist/paddings/zero.d.ts.map +1 -0
- package/dist/paddings/zero.js +24 -0
- package/dist/paddings/zero.js.map +1 -0
- package/dist/preset.d.ts +5 -0
- package/dist/preset.d.ts.map +1 -0
- package/dist/preset.js +55 -0
- package/dist/preset.js.map +1 -0
- package/package.json +46 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,892 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @jscrypto/classic v0.1.0
|
|
3
|
+
* Copyright 2026 Chen, Yi-Cyuan
|
|
4
|
+
* Released under the MIT license
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// packages/classic/src/adapter/crypto-js.ts
|
|
8
|
+
import CryptoJS from "crypto-js";
|
|
9
|
+
function createCryptoJsBlockCipher(options) {
|
|
10
|
+
const { name, key, blockSize, algorithm } = options;
|
|
11
|
+
const keyWords = bytesToWordArray(key);
|
|
12
|
+
const encryptor = algorithm.createEncryptor(keyWords);
|
|
13
|
+
const decryptor = algorithm.createDecryptor(keyWords);
|
|
14
|
+
return {
|
|
15
|
+
blockSize,
|
|
16
|
+
encryptBlock(block) {
|
|
17
|
+
assertBlock(block, blockSize, name);
|
|
18
|
+
const words = bytesToWords(block);
|
|
19
|
+
encryptor.encryptBlock(words, 0);
|
|
20
|
+
return wordsToBytes(words, blockSize);
|
|
21
|
+
},
|
|
22
|
+
decryptBlock(block) {
|
|
23
|
+
assertBlock(block, blockSize, name);
|
|
24
|
+
const words = bytesToWords(block);
|
|
25
|
+
decryptor.decryptBlock(words, 0);
|
|
26
|
+
return wordsToBytes(words, blockSize);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function assertBlock(block, blockSize, name) {
|
|
31
|
+
if (block.length !== blockSize) {
|
|
32
|
+
throw new Error(`${name} block must be ${blockSize * 8} bits.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function bytesToWordArray(bytes) {
|
|
36
|
+
return CryptoJS.lib.WordArray.create(bytesToWords(bytes), bytes.length);
|
|
37
|
+
}
|
|
38
|
+
function bytesToWords(bytes) {
|
|
39
|
+
const words = [];
|
|
40
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
41
|
+
words[i >>> 2] |= bytes[i] << 24 - i % 4 * 8;
|
|
42
|
+
}
|
|
43
|
+
return words;
|
|
44
|
+
}
|
|
45
|
+
function wordArrayToBytes(wordArray) {
|
|
46
|
+
return wordsToBytes(wordArray.words, wordArray.sigBytes);
|
|
47
|
+
}
|
|
48
|
+
function wordsToBytes(words, length) {
|
|
49
|
+
const bytes = new Uint8Array(length);
|
|
50
|
+
for (let i = 0; i < length; i++) {
|
|
51
|
+
bytes[i] = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
52
|
+
}
|
|
53
|
+
return bytes;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// packages/classic/src/ciphers/aes.ts
|
|
57
|
+
var aes = {
|
|
58
|
+
kind: "cipher",
|
|
59
|
+
name: "AES",
|
|
60
|
+
type: "block",
|
|
61
|
+
blockSize: 16,
|
|
62
|
+
keySizes: [16, 24, 32],
|
|
63
|
+
create(key) {
|
|
64
|
+
return createAesCipher(key);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
function createAesCipher(key) {
|
|
68
|
+
if (![16, 24, 32].includes(key.length)) {
|
|
69
|
+
throw new Error("AES key must be 128, 192, or 256 bits.");
|
|
70
|
+
}
|
|
71
|
+
return createCryptoJsBlockCipher({
|
|
72
|
+
name: "AES",
|
|
73
|
+
key,
|
|
74
|
+
blockSize: 16,
|
|
75
|
+
algorithm: CryptoJS.algo.AES
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// packages/classic/src/ciphers/des.ts
|
|
80
|
+
var des = {
|
|
81
|
+
kind: "cipher",
|
|
82
|
+
name: "DES",
|
|
83
|
+
type: "block",
|
|
84
|
+
blockSize: 8,
|
|
85
|
+
keySizes: [8],
|
|
86
|
+
create(key) {
|
|
87
|
+
return createDesCipher(key);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
function createDesCipher(key) {
|
|
91
|
+
if (key.length !== 8) {
|
|
92
|
+
throw new Error("DES key must be 64 bits.");
|
|
93
|
+
}
|
|
94
|
+
return createCryptoJsBlockCipher({
|
|
95
|
+
name: "DES",
|
|
96
|
+
key,
|
|
97
|
+
blockSize: 8,
|
|
98
|
+
algorithm: CryptoJS.algo.DES
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// packages/classic/src/ciphers/rc4.ts
|
|
103
|
+
var rc4 = {
|
|
104
|
+
kind: "cipher",
|
|
105
|
+
name: "RC4",
|
|
106
|
+
type: "stream",
|
|
107
|
+
createEncryptor({ key, options }) {
|
|
108
|
+
return createRc4Transform(key, getDrop(options, 0));
|
|
109
|
+
},
|
|
110
|
+
createDecryptor({ key, options }) {
|
|
111
|
+
return createRc4Transform(key, getDrop(options, 0));
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var rc4Drop = {
|
|
115
|
+
kind: "cipher",
|
|
116
|
+
name: "RC4Drop",
|
|
117
|
+
type: "stream",
|
|
118
|
+
createEncryptor({ key, options }) {
|
|
119
|
+
return createRc4Transform(key, getDrop(options, 192));
|
|
120
|
+
},
|
|
121
|
+
createDecryptor({ key, options }) {
|
|
122
|
+
return createRc4Transform(key, getDrop(options, 192));
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
function createRc4Transform(key, drop = 0) {
|
|
126
|
+
assertKey(key);
|
|
127
|
+
assertDrop(drop);
|
|
128
|
+
const state = createInitialState(key);
|
|
129
|
+
for (let n = 0; n < drop; n++) {
|
|
130
|
+
nextByte(state);
|
|
131
|
+
}
|
|
132
|
+
let finalized = false;
|
|
133
|
+
const processInput = (input) => {
|
|
134
|
+
const output = new Uint8Array(input.length);
|
|
135
|
+
for (let i = 0; i < input.length; i++) {
|
|
136
|
+
output[i] = input[i] ^ nextByte(state);
|
|
137
|
+
}
|
|
138
|
+
return output;
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
process(input) {
|
|
142
|
+
assertNotFinalized(finalized);
|
|
143
|
+
return processInput(input);
|
|
144
|
+
},
|
|
145
|
+
finalize(input = new Uint8Array()) {
|
|
146
|
+
assertNotFinalized(finalized);
|
|
147
|
+
finalized = true;
|
|
148
|
+
return input.length === 0 ? new Uint8Array() : processInput(input);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function createInitialState(key) {
|
|
153
|
+
const s = new Uint8Array(256);
|
|
154
|
+
for (let i = 0; i < s.length; i++) {
|
|
155
|
+
s[i] = i;
|
|
156
|
+
}
|
|
157
|
+
let j = 0;
|
|
158
|
+
for (let i = 0; i < s.length; i++) {
|
|
159
|
+
j = j + s[i] + key[i % key.length] & 255;
|
|
160
|
+
swap(s, i, j);
|
|
161
|
+
}
|
|
162
|
+
return { s, i: 0, j: 0 };
|
|
163
|
+
}
|
|
164
|
+
function nextByte(state) {
|
|
165
|
+
const { s } = state;
|
|
166
|
+
state.i = state.i + 1 & 255;
|
|
167
|
+
state.j = state.j + s[state.i] & 255;
|
|
168
|
+
swap(s, state.i, state.j);
|
|
169
|
+
return s[s[state.i] + s[state.j] & 255];
|
|
170
|
+
}
|
|
171
|
+
function swap(bytes, a, b) {
|
|
172
|
+
const value = bytes[a];
|
|
173
|
+
bytes[a] = bytes[b];
|
|
174
|
+
bytes[b] = value;
|
|
175
|
+
}
|
|
176
|
+
function getDrop(options, defaultDrop) {
|
|
177
|
+
if (!isRc4Options(options) || options.drop === void 0) {
|
|
178
|
+
return defaultDrop;
|
|
179
|
+
}
|
|
180
|
+
return options.drop;
|
|
181
|
+
}
|
|
182
|
+
function isRc4Options(options) {
|
|
183
|
+
return typeof options === "object" && options !== null;
|
|
184
|
+
}
|
|
185
|
+
function assertKey(key) {
|
|
186
|
+
if (key.length < 5) {
|
|
187
|
+
throw new Error("RC4 key should be greater or equal than 40 bits.");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function assertDrop(drop) {
|
|
191
|
+
if (!Number.isInteger(drop) || drop < 0) {
|
|
192
|
+
throw new RangeError("RC4 drop must be a non-negative integer.");
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function assertNotFinalized(finalized) {
|
|
196
|
+
if (finalized) {
|
|
197
|
+
throw new Error("Transform is already finalized.");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// packages/classic/src/ciphers/triple-des.ts
|
|
202
|
+
var tripleDes = {
|
|
203
|
+
kind: "cipher",
|
|
204
|
+
name: "TripleDES",
|
|
205
|
+
type: "block",
|
|
206
|
+
blockSize: 8,
|
|
207
|
+
keySizes: [16, 24],
|
|
208
|
+
create(key) {
|
|
209
|
+
return createTripleDesCipher(key);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
function createTripleDesCipher(key) {
|
|
213
|
+
if (![16, 24].includes(key.length)) {
|
|
214
|
+
throw new Error("Triple DES key must be 128 or 192 bits.");
|
|
215
|
+
}
|
|
216
|
+
return createCryptoJsBlockCipher({
|
|
217
|
+
name: "Triple DES",
|
|
218
|
+
key,
|
|
219
|
+
blockSize: 8,
|
|
220
|
+
algorithm: CryptoJS.algo.TripleDES
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// packages/classic/src/formats/openssl.ts
|
|
225
|
+
import { concatBytes, equalBytes } from "@jscrypto/core";
|
|
226
|
+
var OPENSSL_SALTED_MAGIC = new Uint8Array([
|
|
227
|
+
83,
|
|
228
|
+
97,
|
|
229
|
+
108,
|
|
230
|
+
116,
|
|
231
|
+
101,
|
|
232
|
+
100,
|
|
233
|
+
95,
|
|
234
|
+
95
|
|
235
|
+
]);
|
|
236
|
+
var opensslFormat = {
|
|
237
|
+
kind: "format",
|
|
238
|
+
name: "OpenSSL",
|
|
239
|
+
mediaType: "application/octet-stream",
|
|
240
|
+
stringify({ ciphertext, salt }) {
|
|
241
|
+
if (!salt) {
|
|
242
|
+
return ciphertext.slice();
|
|
243
|
+
}
|
|
244
|
+
assertSalt(salt);
|
|
245
|
+
return concatBytes(OPENSSL_SALTED_MAGIC, salt, ciphertext);
|
|
246
|
+
},
|
|
247
|
+
parse(input) {
|
|
248
|
+
if (!hasSaltHeader(input)) {
|
|
249
|
+
return { ciphertext: input.slice() };
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
salt: input.slice(OPENSSL_SALTED_MAGIC.length, OPENSSL_SALTED_MAGIC.length + 8),
|
|
253
|
+
ciphertext: input.slice(OPENSSL_SALTED_MAGIC.length + 8)
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
function hasSaltHeader(input) {
|
|
258
|
+
return input.length >= 16 && equalBytes(input.subarray(0, OPENSSL_SALTED_MAGIC.length), OPENSSL_SALTED_MAGIC);
|
|
259
|
+
}
|
|
260
|
+
function assertSalt(salt) {
|
|
261
|
+
if (salt.length !== 8) {
|
|
262
|
+
throw new Error("OpenSSL salt must be 64 bits.");
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// packages/classic/src/kdfs/evpkdf.ts
|
|
267
|
+
var evpKdf = {
|
|
268
|
+
kind: "kdf",
|
|
269
|
+
name: "EvpKDF",
|
|
270
|
+
derive(params) {
|
|
271
|
+
return deriveEvpKdf(params);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
function deriveEvpKdf(params) {
|
|
275
|
+
assertPositiveInteger(params.length, "EvpKDF length");
|
|
276
|
+
if (params.iterations !== void 0) {
|
|
277
|
+
assertPositiveInteger(params.iterations, "EvpKDF iterations");
|
|
278
|
+
}
|
|
279
|
+
const options = {
|
|
280
|
+
keySize: params.length / 4,
|
|
281
|
+
iterations: params.iterations ?? 1
|
|
282
|
+
};
|
|
283
|
+
const hasher = getHasher(params.hash);
|
|
284
|
+
if (hasher) {
|
|
285
|
+
options.hasher = hasher;
|
|
286
|
+
}
|
|
287
|
+
const derived = CryptoJS.EvpKDF(toCryptoJsInput(params.passphrase), toCryptoJsInput(params.salt), options);
|
|
288
|
+
return wordArrayToBytes(derived);
|
|
289
|
+
}
|
|
290
|
+
function toCryptoJsInput(input) {
|
|
291
|
+
return typeof input === "string" ? input : bytesToWordArray(input);
|
|
292
|
+
}
|
|
293
|
+
function getHasher(hash) {
|
|
294
|
+
if (!hash) {
|
|
295
|
+
return void 0;
|
|
296
|
+
}
|
|
297
|
+
const hasher = CryptoJS.algo[normalizeHashName(hash)];
|
|
298
|
+
if (!hasher) {
|
|
299
|
+
throw new Error(`Unsupported EvpKDF hash: ${hash}`);
|
|
300
|
+
}
|
|
301
|
+
return hasher;
|
|
302
|
+
}
|
|
303
|
+
function normalizeHashName(hash) {
|
|
304
|
+
return hash.replaceAll("-", "").toUpperCase();
|
|
305
|
+
}
|
|
306
|
+
function assertPositiveInteger(value, label) {
|
|
307
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
308
|
+
throw new RangeError(`${label} must be a positive integer.`);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// packages/classic/src/kdfs/pbkdf2.ts
|
|
313
|
+
var pbkdf2 = {
|
|
314
|
+
kind: "kdf",
|
|
315
|
+
name: "PBKDF2",
|
|
316
|
+
derive(params) {
|
|
317
|
+
return derivePbkdf2(params);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
function derivePbkdf2(params) {
|
|
321
|
+
assertPositiveInteger2(params.iterations, "PBKDF2 iterations");
|
|
322
|
+
assertPositiveInteger2(params.length, "PBKDF2 length");
|
|
323
|
+
const options = {
|
|
324
|
+
keySize: params.length / 4,
|
|
325
|
+
iterations: params.iterations
|
|
326
|
+
};
|
|
327
|
+
const hasher = getHasher2(params.hash);
|
|
328
|
+
if (hasher) {
|
|
329
|
+
options.hasher = hasher;
|
|
330
|
+
}
|
|
331
|
+
const derived = CryptoJS.PBKDF2(toCryptoJsInput2(params.passphrase), toCryptoJsInput2(params.salt), options);
|
|
332
|
+
return wordArrayToBytes(derived);
|
|
333
|
+
}
|
|
334
|
+
function toCryptoJsInput2(input) {
|
|
335
|
+
return typeof input === "string" ? input : bytesToWordArray(input);
|
|
336
|
+
}
|
|
337
|
+
function getHasher2(hash) {
|
|
338
|
+
if (!hash) {
|
|
339
|
+
return void 0;
|
|
340
|
+
}
|
|
341
|
+
const hasher = CryptoJS.algo[normalizeHashName2(hash)];
|
|
342
|
+
if (!hasher) {
|
|
343
|
+
throw new Error(`Unsupported PBKDF2 hash: ${hash}`);
|
|
344
|
+
}
|
|
345
|
+
return hasher;
|
|
346
|
+
}
|
|
347
|
+
function normalizeHashName2(hash) {
|
|
348
|
+
return hash.replaceAll("-", "").toUpperCase();
|
|
349
|
+
}
|
|
350
|
+
function assertPositiveInteger2(value, label) {
|
|
351
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
352
|
+
throw new RangeError(`${label} must be a positive integer.`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// packages/classic/src/modes/cbc.ts
|
|
357
|
+
import {
|
|
358
|
+
assertBlockMultiple as assertCoreBlockMultiple,
|
|
359
|
+
assertIv,
|
|
360
|
+
xorBytes
|
|
361
|
+
} from "@jscrypto/core";
|
|
362
|
+
var cbc = {
|
|
363
|
+
kind: "mode",
|
|
364
|
+
name: "CBC",
|
|
365
|
+
requiresPadding: true,
|
|
366
|
+
createEncryptor({ cipher, iv }) {
|
|
367
|
+
assertIv(cipher.blockSize, iv, "CBC");
|
|
368
|
+
return createCbcEncryptor(cipher, iv);
|
|
369
|
+
},
|
|
370
|
+
createDecryptor({ cipher, iv }) {
|
|
371
|
+
assertIv(cipher.blockSize, iv, "CBC");
|
|
372
|
+
return createCbcDecryptor(cipher, iv);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
function createCbcEncryptor(cipher, iv) {
|
|
376
|
+
let previous = iv;
|
|
377
|
+
return {
|
|
378
|
+
process(input) {
|
|
379
|
+
assertBlockMultiple(cipher.blockSize, input);
|
|
380
|
+
const output = new Uint8Array(input.length);
|
|
381
|
+
for (let offset = 0; offset < input.length; offset += cipher.blockSize) {
|
|
382
|
+
const block = xorBytes(input.subarray(offset, offset + cipher.blockSize), previous);
|
|
383
|
+
const encrypted = cipher.encryptBlock(block);
|
|
384
|
+
output.set(encrypted, offset);
|
|
385
|
+
previous = encrypted;
|
|
386
|
+
}
|
|
387
|
+
return output;
|
|
388
|
+
},
|
|
389
|
+
finalize(input = new Uint8Array()) {
|
|
390
|
+
return input.length === 0 ? new Uint8Array() : this.process(input);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function createCbcDecryptor(cipher, iv) {
|
|
395
|
+
let previous = iv;
|
|
396
|
+
return {
|
|
397
|
+
process(input) {
|
|
398
|
+
assertBlockMultiple(cipher.blockSize, input);
|
|
399
|
+
const output = new Uint8Array(input.length);
|
|
400
|
+
for (let offset = 0; offset < input.length; offset += cipher.blockSize) {
|
|
401
|
+
const block = input.subarray(offset, offset + cipher.blockSize);
|
|
402
|
+
const decrypted = cipher.decryptBlock(block);
|
|
403
|
+
output.set(xorBytes(decrypted, previous), offset);
|
|
404
|
+
previous = block.slice();
|
|
405
|
+
}
|
|
406
|
+
return output;
|
|
407
|
+
},
|
|
408
|
+
finalize(input = new Uint8Array()) {
|
|
409
|
+
return input.length === 0 ? new Uint8Array() : this.process(input);
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function assertBlockMultiple(blockSize, input) {
|
|
414
|
+
assertCoreBlockMultiple(input, blockSize, "CBC");
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// packages/classic/src/modes/cfb.ts
|
|
418
|
+
import { assertIv as assertIv2 } from "@jscrypto/core";
|
|
419
|
+
var cfb = {
|
|
420
|
+
kind: "mode",
|
|
421
|
+
name: "CFB",
|
|
422
|
+
requiresPadding: false,
|
|
423
|
+
createEncryptor({ cipher, iv }) {
|
|
424
|
+
assertIv2(cipher.blockSize, iv, "CFB");
|
|
425
|
+
return createCfbEncryptor(cipher, iv);
|
|
426
|
+
},
|
|
427
|
+
createDecryptor({ cipher, iv }) {
|
|
428
|
+
assertIv2(cipher.blockSize, iv, "CFB");
|
|
429
|
+
return createCfbDecryptor(cipher, iv);
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
function createCfbEncryptor(cipher, iv) {
|
|
433
|
+
return createCfbTransform(cipher, iv, true);
|
|
434
|
+
}
|
|
435
|
+
function createCfbDecryptor(cipher, iv) {
|
|
436
|
+
return createCfbTransform(cipher, iv, false);
|
|
437
|
+
}
|
|
438
|
+
function createCfbTransform(cipher, iv, encrypting) {
|
|
439
|
+
let feedback = iv.slice();
|
|
440
|
+
let nextFeedback = new Uint8Array(cipher.blockSize);
|
|
441
|
+
let keystream = new Uint8Array(cipher.blockSize);
|
|
442
|
+
let position = 0;
|
|
443
|
+
return {
|
|
444
|
+
process(input) {
|
|
445
|
+
const output = new Uint8Array(input.length);
|
|
446
|
+
for (let i = 0; i < input.length; i++) {
|
|
447
|
+
if (position === 0) {
|
|
448
|
+
keystream = cipher.encryptBlock(feedback);
|
|
449
|
+
}
|
|
450
|
+
const inputByte = input[i];
|
|
451
|
+
const outputByte = inputByte ^ keystream[position];
|
|
452
|
+
output[i] = outputByte;
|
|
453
|
+
nextFeedback[position] = encrypting ? outputByte : inputByte;
|
|
454
|
+
position++;
|
|
455
|
+
if (position === cipher.blockSize) {
|
|
456
|
+
feedback = nextFeedback;
|
|
457
|
+
nextFeedback = new Uint8Array(cipher.blockSize);
|
|
458
|
+
position = 0;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return output;
|
|
462
|
+
},
|
|
463
|
+
finalize(input = new Uint8Array()) {
|
|
464
|
+
return input.length === 0 ? new Uint8Array() : this.process(input);
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// packages/classic/src/modes/ctr.ts
|
|
470
|
+
import { assertIv as assertIv3 } from "@jscrypto/core";
|
|
471
|
+
var ctr = {
|
|
472
|
+
kind: "mode",
|
|
473
|
+
name: "CTR",
|
|
474
|
+
requiresPadding: false,
|
|
475
|
+
createEncryptor({ cipher, iv }) {
|
|
476
|
+
assertIv3(cipher.blockSize, iv, "CTR");
|
|
477
|
+
return createCtrTransform(cipher, iv);
|
|
478
|
+
},
|
|
479
|
+
createDecryptor({ cipher, iv }) {
|
|
480
|
+
assertIv3(cipher.blockSize, iv, "CTR");
|
|
481
|
+
return createCtrTransform(cipher, iv);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
function createCtrTransform(cipher, iv) {
|
|
485
|
+
const counter = iv.slice();
|
|
486
|
+
let keystream = new Uint8Array(cipher.blockSize);
|
|
487
|
+
let position = cipher.blockSize;
|
|
488
|
+
return {
|
|
489
|
+
process(input) {
|
|
490
|
+
const output = new Uint8Array(input.length);
|
|
491
|
+
for (let i = 0; i < input.length; i++) {
|
|
492
|
+
if (position === cipher.blockSize) {
|
|
493
|
+
keystream = cipher.encryptBlock(counter);
|
|
494
|
+
incrementCounter(counter);
|
|
495
|
+
position = 0;
|
|
496
|
+
}
|
|
497
|
+
output[i] = input[i] ^ keystream[position];
|
|
498
|
+
position++;
|
|
499
|
+
}
|
|
500
|
+
return output;
|
|
501
|
+
},
|
|
502
|
+
finalize(input = new Uint8Array()) {
|
|
503
|
+
return input.length === 0 ? new Uint8Array() : this.process(input);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function incrementCounter(counter) {
|
|
508
|
+
for (let i = counter.length - 1; i >= 0; i--) {
|
|
509
|
+
counter[i] = counter[i] + 1 & 255;
|
|
510
|
+
if (counter[i] !== 0) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// packages/classic/src/modes/ecb.ts
|
|
517
|
+
import { assertBlockMultiple as assertCoreBlockMultiple2 } from "@jscrypto/core";
|
|
518
|
+
var ecb = {
|
|
519
|
+
kind: "mode",
|
|
520
|
+
name: "ECB",
|
|
521
|
+
requiresPadding: true,
|
|
522
|
+
createEncryptor({ cipher }) {
|
|
523
|
+
return createEcbEncryptor(cipher);
|
|
524
|
+
},
|
|
525
|
+
createDecryptor({ cipher }) {
|
|
526
|
+
return createEcbDecryptor(cipher);
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
function createEcbEncryptor(cipher) {
|
|
530
|
+
return {
|
|
531
|
+
process(input) {
|
|
532
|
+
assertBlockMultiple2(cipher.blockSize, input);
|
|
533
|
+
const output = new Uint8Array(input.length);
|
|
534
|
+
for (let offset = 0; offset < input.length; offset += cipher.blockSize) {
|
|
535
|
+
output.set(cipher.encryptBlock(input.subarray(offset, offset + cipher.blockSize)), offset);
|
|
536
|
+
}
|
|
537
|
+
return output;
|
|
538
|
+
},
|
|
539
|
+
finalize(input = new Uint8Array()) {
|
|
540
|
+
return input.length === 0 ? new Uint8Array() : this.process(input);
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
function createEcbDecryptor(cipher) {
|
|
545
|
+
return {
|
|
546
|
+
process(input) {
|
|
547
|
+
assertBlockMultiple2(cipher.blockSize, input);
|
|
548
|
+
const output = new Uint8Array(input.length);
|
|
549
|
+
for (let offset = 0; offset < input.length; offset += cipher.blockSize) {
|
|
550
|
+
output.set(cipher.decryptBlock(input.subarray(offset, offset + cipher.blockSize)), offset);
|
|
551
|
+
}
|
|
552
|
+
return output;
|
|
553
|
+
},
|
|
554
|
+
finalize(input = new Uint8Array()) {
|
|
555
|
+
return input.length === 0 ? new Uint8Array() : this.process(input);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function assertBlockMultiple2(blockSize, input) {
|
|
560
|
+
assertCoreBlockMultiple2(input, blockSize, "ECB");
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// packages/classic/src/modes/gcm.ts
|
|
564
|
+
var gcm = {
|
|
565
|
+
kind: "mode",
|
|
566
|
+
name: "GCM",
|
|
567
|
+
aead: true,
|
|
568
|
+
requiredBlockSize: 16,
|
|
569
|
+
requiresPadding: false,
|
|
570
|
+
createEncryptor() {
|
|
571
|
+
throw new Error("GCM mode is not implemented yet.");
|
|
572
|
+
},
|
|
573
|
+
createDecryptor() {
|
|
574
|
+
throw new Error("GCM mode is not implemented yet.");
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
// packages/classic/src/modes/ofb.ts
|
|
579
|
+
import { assertIv as assertIv4 } from "@jscrypto/core";
|
|
580
|
+
var ofb = {
|
|
581
|
+
kind: "mode",
|
|
582
|
+
name: "OFB",
|
|
583
|
+
requiresPadding: false,
|
|
584
|
+
createEncryptor({ cipher, iv }) {
|
|
585
|
+
assertIv4(cipher.blockSize, iv, "OFB");
|
|
586
|
+
return createOfbTransform(cipher, iv);
|
|
587
|
+
},
|
|
588
|
+
createDecryptor({ cipher, iv }) {
|
|
589
|
+
assertIv4(cipher.blockSize, iv, "OFB");
|
|
590
|
+
return createOfbTransform(cipher, iv);
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
function createOfbTransform(cipher, iv) {
|
|
594
|
+
let feedback = iv.slice();
|
|
595
|
+
let keystream = new Uint8Array(cipher.blockSize);
|
|
596
|
+
let position = cipher.blockSize;
|
|
597
|
+
return {
|
|
598
|
+
process(input) {
|
|
599
|
+
const output = new Uint8Array(input.length);
|
|
600
|
+
for (let i = 0; i < input.length; i++) {
|
|
601
|
+
if (position === cipher.blockSize) {
|
|
602
|
+
feedback = cipher.encryptBlock(feedback);
|
|
603
|
+
keystream = feedback;
|
|
604
|
+
position = 0;
|
|
605
|
+
}
|
|
606
|
+
output[i] = input[i] ^ keystream[position];
|
|
607
|
+
position++;
|
|
608
|
+
}
|
|
609
|
+
return output;
|
|
610
|
+
},
|
|
611
|
+
finalize(input = new Uint8Array()) {
|
|
612
|
+
return input.length === 0 ? new Uint8Array() : this.process(input);
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
// packages/classic/src/paddings/ansi-x923.ts
|
|
618
|
+
import {
|
|
619
|
+
assertBlockSize as assertCoreBlockSize,
|
|
620
|
+
assertPaddedInput as assertCorePaddedInput,
|
|
621
|
+
getBlockPaddingLength
|
|
622
|
+
} from "@jscrypto/core";
|
|
623
|
+
var ansiX923 = {
|
|
624
|
+
kind: "padding",
|
|
625
|
+
name: "AnsiX923",
|
|
626
|
+
pad(input, blockSize) {
|
|
627
|
+
assertBlockSize(blockSize);
|
|
628
|
+
const paddingLength = getPaddingLength(input.length, blockSize);
|
|
629
|
+
const output = new Uint8Array(input.length + paddingLength);
|
|
630
|
+
output.set(input);
|
|
631
|
+
output[output.length - 1] = paddingLength;
|
|
632
|
+
return output;
|
|
633
|
+
},
|
|
634
|
+
unpad(input, blockSize) {
|
|
635
|
+
assertPaddedInput(input, blockSize);
|
|
636
|
+
const paddingLength = input[input.length - 1];
|
|
637
|
+
if (paddingLength === 0 || paddingLength > blockSize || paddingLength > input.length) {
|
|
638
|
+
throw new Error("Invalid ANSI X9.23 padding.");
|
|
639
|
+
}
|
|
640
|
+
for (let i = input.length - paddingLength; i < input.length - 1; i++) {
|
|
641
|
+
if (input[i] !== 0) {
|
|
642
|
+
throw new Error("Invalid ANSI X9.23 padding.");
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
return input.slice(0, input.length - paddingLength);
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
function assertBlockSize(blockSize) {
|
|
649
|
+
assertCoreBlockSize(blockSize, { max: 255 });
|
|
650
|
+
}
|
|
651
|
+
function assertPaddedInput(input, blockSize) {
|
|
652
|
+
assertCorePaddedInput(input, blockSize, "ANSI X9.23", { max: 255 });
|
|
653
|
+
}
|
|
654
|
+
function getPaddingLength(inputLength, blockSize) {
|
|
655
|
+
return getBlockPaddingLength(inputLength, blockSize);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// packages/classic/src/paddings/iso10126.ts
|
|
659
|
+
import {
|
|
660
|
+
assertBlockSize as assertCoreBlockSize2,
|
|
661
|
+
assertPaddedInput as assertCorePaddedInput2,
|
|
662
|
+
getBlockPaddingLength as getBlockPaddingLength2
|
|
663
|
+
} from "@jscrypto/core";
|
|
664
|
+
var iso10126 = {
|
|
665
|
+
kind: "padding",
|
|
666
|
+
name: "Iso10126",
|
|
667
|
+
pad(input, blockSize) {
|
|
668
|
+
assertBlockSize2(blockSize);
|
|
669
|
+
const paddingLength = getPaddingLength2(input.length, blockSize);
|
|
670
|
+
const output = new Uint8Array(input.length + paddingLength);
|
|
671
|
+
output.set(input);
|
|
672
|
+
fillRandom(output.subarray(input.length, output.length - 1));
|
|
673
|
+
output[output.length - 1] = paddingLength;
|
|
674
|
+
return output;
|
|
675
|
+
},
|
|
676
|
+
unpad(input, blockSize) {
|
|
677
|
+
assertPaddedInput2(input, blockSize);
|
|
678
|
+
const paddingLength = input[input.length - 1];
|
|
679
|
+
if (paddingLength === 0 || paddingLength > blockSize || paddingLength > input.length) {
|
|
680
|
+
throw new Error("Invalid ISO 10126 padding.");
|
|
681
|
+
}
|
|
682
|
+
return input.slice(0, input.length - paddingLength);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
function assertBlockSize2(blockSize) {
|
|
686
|
+
assertCoreBlockSize2(blockSize, { max: 255 });
|
|
687
|
+
}
|
|
688
|
+
function assertPaddedInput2(input, blockSize) {
|
|
689
|
+
assertCorePaddedInput2(input, blockSize, "ISO 10126", { max: 255 });
|
|
690
|
+
}
|
|
691
|
+
function getPaddingLength2(inputLength, blockSize) {
|
|
692
|
+
return getBlockPaddingLength2(inputLength, blockSize);
|
|
693
|
+
}
|
|
694
|
+
function fillRandom(bytes) {
|
|
695
|
+
if (bytes.length === 0) {
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
const crypto = globalThis;
|
|
699
|
+
crypto.crypto?.getRandomValues(bytes);
|
|
700
|
+
if (bytes.some((byte) => byte !== 0)) {
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
704
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// packages/classic/src/paddings/iso97971.ts
|
|
709
|
+
import {
|
|
710
|
+
assertBlockSize as assertCoreBlockSize3,
|
|
711
|
+
assertPaddedInput as assertCorePaddedInput3
|
|
712
|
+
} from "@jscrypto/core";
|
|
713
|
+
var iso97971 = {
|
|
714
|
+
kind: "padding",
|
|
715
|
+
name: "Iso97971",
|
|
716
|
+
pad(input, blockSize) {
|
|
717
|
+
assertBlockSize3(blockSize);
|
|
718
|
+
const paddingLength = getPaddingLength3(input.length, blockSize);
|
|
719
|
+
const output = new Uint8Array(input.length + paddingLength);
|
|
720
|
+
output.set(input);
|
|
721
|
+
output[input.length] = 128;
|
|
722
|
+
return output;
|
|
723
|
+
},
|
|
724
|
+
unpad(input, blockSize) {
|
|
725
|
+
assertPaddedInput3(input, blockSize);
|
|
726
|
+
let index = input.length - 1;
|
|
727
|
+
while (index >= 0 && input[index] === 0) {
|
|
728
|
+
index--;
|
|
729
|
+
}
|
|
730
|
+
if (index < 0 || input[index] !== 128) {
|
|
731
|
+
throw new Error("Invalid ISO/IEC 9797-1 padding.");
|
|
732
|
+
}
|
|
733
|
+
return input.slice(0, index);
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
function assertBlockSize3(blockSize) {
|
|
737
|
+
assertCoreBlockSize3(blockSize);
|
|
738
|
+
}
|
|
739
|
+
function assertPaddedInput3(input, blockSize) {
|
|
740
|
+
assertCorePaddedInput3(input, blockSize, "ISO/IEC 9797-1");
|
|
741
|
+
}
|
|
742
|
+
function getPaddingLength3(inputLength, blockSize) {
|
|
743
|
+
const remainder = (inputLength + 1) % blockSize;
|
|
744
|
+
return 1 + (remainder === 0 ? 0 : blockSize - remainder);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// packages/classic/src/paddings/none.ts
|
|
748
|
+
import { assertBlockMultiple as assertBlockMultiple3 } from "@jscrypto/core";
|
|
749
|
+
var noPadding = {
|
|
750
|
+
kind: "padding",
|
|
751
|
+
name: "NoPadding",
|
|
752
|
+
pad(input, blockSize) {
|
|
753
|
+
assertMultiple(input, blockSize);
|
|
754
|
+
return input.slice();
|
|
755
|
+
},
|
|
756
|
+
unpad(input, blockSize) {
|
|
757
|
+
assertMultiple(input, blockSize);
|
|
758
|
+
return input.slice();
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
function assertMultiple(input, blockSize) {
|
|
762
|
+
assertBlockMultiple3(input, blockSize, "NoPadding");
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// packages/classic/src/paddings/pkcs7.ts
|
|
766
|
+
import { assertBlockSize as assertBlockSize4, assertPaddedInput as assertPaddedInput4, getBlockPaddingLength as getBlockPaddingLength3 } from "@jscrypto/core";
|
|
767
|
+
var pkcs7 = {
|
|
768
|
+
kind: "padding",
|
|
769
|
+
name: "Pkcs7",
|
|
770
|
+
pad(input, blockSize) {
|
|
771
|
+
assertBlockSize4(blockSize, { max: 255 });
|
|
772
|
+
const paddingLength = getBlockPaddingLength3(input.length, blockSize);
|
|
773
|
+
const output = new Uint8Array(input.length + paddingLength);
|
|
774
|
+
output.set(input);
|
|
775
|
+
output.fill(paddingLength, input.length);
|
|
776
|
+
return output;
|
|
777
|
+
},
|
|
778
|
+
unpad(input, blockSize) {
|
|
779
|
+
assertPaddedInput4(input, blockSize, "PKCS#7", { max: 255 });
|
|
780
|
+
const paddingLength = input[input.length - 1];
|
|
781
|
+
if (paddingLength === 0 || paddingLength > blockSize || paddingLength > input.length) {
|
|
782
|
+
throw new Error("Invalid PKCS#7 padding.");
|
|
783
|
+
}
|
|
784
|
+
for (let i = input.length - paddingLength; i < input.length; i++) {
|
|
785
|
+
if (input[i] !== paddingLength) {
|
|
786
|
+
throw new Error("Invalid PKCS#7 padding.");
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return input.slice(0, input.length - paddingLength);
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
// packages/classic/src/paddings/zero.ts
|
|
794
|
+
var zeroPadding = {
|
|
795
|
+
kind: "padding",
|
|
796
|
+
name: "ZeroPadding",
|
|
797
|
+
pad(input, blockSize) {
|
|
798
|
+
if (!Number.isInteger(blockSize) || blockSize <= 0) {
|
|
799
|
+
throw new RangeError("blockSize must be a positive integer.");
|
|
800
|
+
}
|
|
801
|
+
const remainder = input.length % blockSize;
|
|
802
|
+
if (remainder === 0) {
|
|
803
|
+
return input.slice();
|
|
804
|
+
}
|
|
805
|
+
const output = new Uint8Array(input.length + blockSize - remainder);
|
|
806
|
+
output.set(input);
|
|
807
|
+
return output;
|
|
808
|
+
},
|
|
809
|
+
unpad(input) {
|
|
810
|
+
let end = input.length;
|
|
811
|
+
while (end > 0 && input[end - 1] === 0) {
|
|
812
|
+
end--;
|
|
813
|
+
}
|
|
814
|
+
return input.slice(0, end);
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
// packages/classic/src/preset.ts
|
|
819
|
+
import { createRegistry } from "@jscrypto/core";
|
|
820
|
+
function classicPreset() {
|
|
821
|
+
return {
|
|
822
|
+
kind: "preset",
|
|
823
|
+
name: "classic",
|
|
824
|
+
components() {
|
|
825
|
+
return [
|
|
826
|
+
aes,
|
|
827
|
+
des,
|
|
828
|
+
rc4,
|
|
829
|
+
rc4Drop,
|
|
830
|
+
tripleDes,
|
|
831
|
+
cbc,
|
|
832
|
+
cfb,
|
|
833
|
+
ctr,
|
|
834
|
+
ecb,
|
|
835
|
+
gcm,
|
|
836
|
+
ofb,
|
|
837
|
+
pkcs7,
|
|
838
|
+
noPadding,
|
|
839
|
+
ansiX923,
|
|
840
|
+
iso10126,
|
|
841
|
+
iso97971,
|
|
842
|
+
zeroPadding,
|
|
843
|
+
pbkdf2,
|
|
844
|
+
evpKdf,
|
|
845
|
+
opensslFormat
|
|
846
|
+
];
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
function createClassicRegistry() {
|
|
851
|
+
return createRegistry().use(classicPreset());
|
|
852
|
+
}
|
|
853
|
+
var registry = createClassicRegistry();
|
|
854
|
+
export {
|
|
855
|
+
CryptoJS,
|
|
856
|
+
OPENSSL_SALTED_MAGIC,
|
|
857
|
+
aes,
|
|
858
|
+
ansiX923,
|
|
859
|
+
bytesToWordArray,
|
|
860
|
+
bytesToWords,
|
|
861
|
+
cbc,
|
|
862
|
+
cfb,
|
|
863
|
+
classicPreset,
|
|
864
|
+
createAesCipher,
|
|
865
|
+
createClassicRegistry,
|
|
866
|
+
createCryptoJsBlockCipher,
|
|
867
|
+
createDesCipher,
|
|
868
|
+
createRc4Transform,
|
|
869
|
+
createTripleDesCipher,
|
|
870
|
+
ctr,
|
|
871
|
+
deriveEvpKdf,
|
|
872
|
+
derivePbkdf2,
|
|
873
|
+
des,
|
|
874
|
+
ecb,
|
|
875
|
+
evpKdf,
|
|
876
|
+
gcm,
|
|
877
|
+
iso10126,
|
|
878
|
+
iso97971,
|
|
879
|
+
noPadding,
|
|
880
|
+
ofb,
|
|
881
|
+
opensslFormat,
|
|
882
|
+
pbkdf2,
|
|
883
|
+
pkcs7,
|
|
884
|
+
rc4,
|
|
885
|
+
rc4Drop,
|
|
886
|
+
registry,
|
|
887
|
+
tripleDes,
|
|
888
|
+
wordArrayToBytes,
|
|
889
|
+
wordsToBytes,
|
|
890
|
+
zeroPadding
|
|
891
|
+
};
|
|
892
|
+
//# sourceMappingURL=index.mjs.map
|