@aidc-toolkit/utility 1.0.23-beta → 1.0.25-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -30
- package/dist/index.cjs +3570 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +953 -0
- package/dist/index.d.ts +953 -26
- package/dist/index.js +3505 -8
- package/dist/index.js.map +1 -1
- package/package.json +7 -11
- package/src/character-set.ts +20 -19
- package/src/exclusion.ts +6 -1
- package/src/index.ts +9 -9
- package/src/locale/i18n.ts +3 -5
- package/src/locale/i18next.d.ts +1 -1
- package/src/record.ts +2 -2
- package/src/reg-exp.ts +7 -7
- package/src/string.ts +3 -3
- package/src/transformer.ts +19 -18
- package/test/record.test.ts +3 -1
- package/tsup.config.ts +3 -0
- package/typedoc.json +1 -3
- package/dist/character-set.d.ts +0 -307
- package/dist/character-set.d.ts.map +0 -1
- package/dist/character-set.js +0 -563
- package/dist/character-set.js.map +0 -1
- package/dist/exclusion.d.ts +0 -22
- package/dist/exclusion.d.ts.map +0 -1
- package/dist/exclusion.js +0 -18
- package/dist/exclusion.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/iterable-utility.d.ts +0 -39
- package/dist/iterable-utility.d.ts.map +0 -1
- package/dist/iterable-utility.js +0 -35
- package/dist/iterable-utility.js.map +0 -1
- package/dist/locale/en/locale-resources.d.ts +0 -33
- package/dist/locale/en/locale-resources.d.ts.map +0 -1
- package/dist/locale/en/locale-resources.js +0 -32
- package/dist/locale/en/locale-resources.js.map +0 -1
- package/dist/locale/fr/locale-resources.d.ts +0 -33
- package/dist/locale/fr/locale-resources.d.ts.map +0 -1
- package/dist/locale/fr/locale-resources.js +0 -32
- package/dist/locale/fr/locale-resources.js.map +0 -1
- package/dist/locale/i18n.d.ts +0 -27
- package/dist/locale/i18n.d.ts.map +0 -1
- package/dist/locale/i18n.js +0 -35
- package/dist/locale/i18n.js.map +0 -1
- package/dist/record.d.ts +0 -44
- package/dist/record.d.ts.map +0 -1
- package/dist/record.js +0 -58
- package/dist/record.js.map +0 -1
- package/dist/reg-exp.d.ts +0 -43
- package/dist/reg-exp.d.ts.map +0 -1
- package/dist/reg-exp.js +0 -55
- package/dist/reg-exp.js.map +0 -1
- package/dist/sequence.d.ts +0 -68
- package/dist/sequence.d.ts.map +0 -1
- package/dist/sequence.js +0 -96
- package/dist/sequence.js.map +0 -1
- package/dist/string.d.ts +0 -25
- package/dist/string.d.ts.map +0 -1
- package/dist/string.js +0 -2
- package/dist/string.js.map +0 -1
- package/dist/transformer.d.ts +0 -346
- package/dist/transformer.d.ts.map +0 -1
- package/dist/transformer.js +0 -456
- package/dist/transformer.js.map +0 -1
package/dist/transformer.js
DELETED
|
@@ -1,456 +0,0 @@
|
|
|
1
|
-
import { mapIterable } from "./iterable-utility.js";
|
|
2
|
-
import { i18nextUtility } from "./locale/i18n.js";
|
|
3
|
-
import { Sequence } from "./sequence.js";
|
|
4
|
-
/**
|
|
5
|
-
* Transformer that transforms values in a numeric domain to values in a range equal to the domain or to another range
|
|
6
|
-
* defined by a callback function. In other words, the domain determines valid input values and, without a callback, the
|
|
7
|
-
* range of valid output values.
|
|
8
|
-
*
|
|
9
|
-
* The concept is similar to {@link https://en.wikipedia.org/wiki/Format-preserving_encryption | format-preserving
|
|
10
|
-
* encryption}, where input values within a specified domain (e.g., {@link
|
|
11
|
-
* https://en.wikipedia.org/wiki/Payment_card_number | payment card numbers} ranging from 8-19 digits) are transformed
|
|
12
|
-
* into values in the same domain, typically for storage in a database where the data type and length are already fixed
|
|
13
|
-
* and exfiltration of the data can have significant repercussions.
|
|
14
|
-
*
|
|
15
|
-
* Two subclasses are supported directly by this class: {@link IdentityTransformer} (which operates based on a domain
|
|
16
|
-
* only) and {@link EncryptionTransformer} (which operates based on a domain and a tweak). If an application is expected
|
|
17
|
-
* to make repeated use of a transformer with the same domain and (optional) tweak and can't manage the transformer
|
|
18
|
-
* object, an in-memory cache is available via the {@link get} method. Properties in {@link IdentityTransformer} and
|
|
19
|
-
* {@link EncryptionTransformer} are read-only once constructed, so there is no issue with their shared use.
|
|
20
|
-
*/
|
|
21
|
-
export class Transformer {
|
|
22
|
-
/**
|
|
23
|
-
* Transformers cache, mapping a domain to another map, which maps an optional tweak to a transformer.
|
|
24
|
-
*/
|
|
25
|
-
static TRANSFORMER_MAPS_MAP = new Map();
|
|
26
|
-
/**
|
|
27
|
-
* Domain.
|
|
28
|
-
*/
|
|
29
|
-
_domain;
|
|
30
|
-
/**
|
|
31
|
-
* Constructor.
|
|
32
|
-
*
|
|
33
|
-
* @param domain
|
|
34
|
-
* Domain.
|
|
35
|
-
*/
|
|
36
|
-
constructor(domain) {
|
|
37
|
-
this._domain = BigInt(domain);
|
|
38
|
-
if (this._domain <= 0n) {
|
|
39
|
-
throw new RangeError(i18nextUtility.t("Transformer.domainMustBeGreaterThanZero", {
|
|
40
|
-
domain
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Get a transformer, constructing it if necessary. The type returned is {@link IdentityTransformer} if tweak is
|
|
46
|
-
* undefined, {@link EncryptionTransformer} if tweak is defined. Note that although an {@link EncryptionTransformer}
|
|
47
|
-
* with a zero tweak operates as an {@link IdentityTransformer}, {@link EncryptionTransformer} is still the type
|
|
48
|
-
* returned if a zero tweak is explicitly specified.
|
|
49
|
-
*
|
|
50
|
-
* @param domain
|
|
51
|
-
* Domain.
|
|
52
|
-
*
|
|
53
|
-
* @param tweak
|
|
54
|
-
* Tweak.
|
|
55
|
-
*
|
|
56
|
-
* @returns
|
|
57
|
-
* {@link IdentityTransformer} if tweak is undefined, {@link EncryptionTransformer} if tweak is defined.
|
|
58
|
-
*/
|
|
59
|
-
static get(domain, tweak) {
|
|
60
|
-
const domainN = BigInt(domain);
|
|
61
|
-
let transformersMap = Transformer.TRANSFORMER_MAPS_MAP.get(domainN);
|
|
62
|
-
if (transformersMap === undefined) {
|
|
63
|
-
transformersMap = new Map();
|
|
64
|
-
Transformer.TRANSFORMER_MAPS_MAP.set(domainN, transformersMap);
|
|
65
|
-
}
|
|
66
|
-
const tweakN = tweak === undefined ? undefined : BigInt(tweak);
|
|
67
|
-
let transformer = transformersMap.get(tweakN);
|
|
68
|
-
if (transformer === undefined) {
|
|
69
|
-
transformer = tweakN === undefined ? new IdentityTransformer(domainN) : new EncryptionTransformer(domainN, tweakN);
|
|
70
|
-
transformersMap.set(tweakN, transformer);
|
|
71
|
-
}
|
|
72
|
-
return transformer;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Get the domain.
|
|
76
|
-
*/
|
|
77
|
-
get domain() {
|
|
78
|
-
return this._domain;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Validate that a value is within the domain.
|
|
82
|
-
*
|
|
83
|
-
* @param value
|
|
84
|
-
* Value.
|
|
85
|
-
*/
|
|
86
|
-
validate(value) {
|
|
87
|
-
if (value < 0n) {
|
|
88
|
-
throw new RangeError(i18nextUtility.t("Transformer.valueMustBeGreaterThanOrEqualToZero", {
|
|
89
|
-
value
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
92
|
-
if (value >= this.domain) {
|
|
93
|
-
throw new RangeError(i18nextUtility.t("Transformer.valueMustBeLessThan", {
|
|
94
|
-
value,
|
|
95
|
-
domain: this.domain
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Validate that a value is within the domain and do the work of transforming it forward.
|
|
101
|
-
*
|
|
102
|
-
* @param value
|
|
103
|
-
* Value.
|
|
104
|
-
*
|
|
105
|
-
* @returns
|
|
106
|
-
* Transformed value.
|
|
107
|
-
*/
|
|
108
|
-
validateDoForward(value) {
|
|
109
|
-
const valueN = BigInt(value);
|
|
110
|
-
this.validate(valueN);
|
|
111
|
-
return this.doForward(valueN);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Validate that a value is within the domain, do the work of transforming it forward, and apply a callback.
|
|
115
|
-
*
|
|
116
|
-
* @param transformerCallback
|
|
117
|
-
* Called after each value is transformed to convert it to its final value.
|
|
118
|
-
*
|
|
119
|
-
* @param value
|
|
120
|
-
* Value.
|
|
121
|
-
*
|
|
122
|
-
* @param index
|
|
123
|
-
* Index in sequence (0 for single transformation).
|
|
124
|
-
*
|
|
125
|
-
* @returns
|
|
126
|
-
* Transformed value.
|
|
127
|
-
*/
|
|
128
|
-
validateDoForwardCallback(transformerCallback, value, index) {
|
|
129
|
-
return transformerCallback(this.validateDoForward(value), index);
|
|
130
|
-
}
|
|
131
|
-
;
|
|
132
|
-
// eslint-disable-next-line jsdoc/require-jsdoc -- Implementation of overloaded signatures.
|
|
133
|
-
forward(valueOrValues, transformerCallback) {
|
|
134
|
-
// TODO Refactor type when https://github.com/microsoft/TypeScript/pull/56941 released.
|
|
135
|
-
let result;
|
|
136
|
-
if (typeof valueOrValues !== "object") {
|
|
137
|
-
result = transformerCallback === undefined ? this.validateDoForward(valueOrValues) : this.validateDoForwardCallback(transformerCallback, valueOrValues);
|
|
138
|
-
}
|
|
139
|
-
else if (valueOrValues instanceof Sequence) {
|
|
140
|
-
if (valueOrValues.minimumValue < 0n) {
|
|
141
|
-
throw new RangeError(i18nextUtility.t("Transformer.minimumValueMustBeGreaterThanOrEqualToZero", {
|
|
142
|
-
minimumValue: valueOrValues.minimumValue
|
|
143
|
-
}));
|
|
144
|
-
}
|
|
145
|
-
if (valueOrValues.maximumValue >= this.domain) {
|
|
146
|
-
throw new RangeError(i18nextUtility.t("Transformer.maximumValueMustBeLessThan", {
|
|
147
|
-
maximumValue: valueOrValues.maximumValue,
|
|
148
|
-
domain: this.domain
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
result = transformerCallback === undefined ? mapIterable(valueOrValues, value => this.doForward(value)) : mapIterable(valueOrValues, (value, index) => transformerCallback(this.doForward(value), index));
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
result = transformerCallback === undefined ? mapIterable(valueOrValues, value => this.validateDoForward(value)) : mapIterable(valueOrValues, (value, index) => this.validateDoForwardCallback(transformerCallback, value, index));
|
|
155
|
-
}
|
|
156
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type determination is handled above.
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Transform a value in reverse.
|
|
161
|
-
*
|
|
162
|
-
* @param transformedValue
|
|
163
|
-
* Transformed value.
|
|
164
|
-
*
|
|
165
|
-
* @returns
|
|
166
|
-
* Value.
|
|
167
|
-
*/
|
|
168
|
-
reverse(transformedValue) {
|
|
169
|
-
const transformedValueN = BigInt(transformedValue);
|
|
170
|
-
this.validate(transformedValueN);
|
|
171
|
-
return this.doReverse(transformedValueN);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Identity transformer. Values are transformed to themselves.
|
|
176
|
-
*/
|
|
177
|
-
export class IdentityTransformer extends Transformer {
|
|
178
|
-
/**
|
|
179
|
-
* @inheritDoc
|
|
180
|
-
*/
|
|
181
|
-
doForward(value) {
|
|
182
|
-
return value;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* @inheritDoc
|
|
186
|
-
*/
|
|
187
|
-
doReverse(transformedValue) {
|
|
188
|
-
return transformedValue;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Encryption transformer. Values are transformed using repeated shuffle and xor operations, similar to those found in
|
|
193
|
-
* many cryptography algorithms, particularly AES. While sufficient for obfuscation of numeric sequences (e.g., serial
|
|
194
|
-
* number generation, below), if true format-preserving encryption is required, a more robust algorithm such as
|
|
195
|
-
* {@link https://doi.org/10.6028/NIST.SP.800-38Gr1-draft | FF1} is recommended. Furthermore, no work has been done to
|
|
196
|
-
* mitigate {@link https://timing.attacks.cr.yp.to/index.html | timing attacks} for key detection.
|
|
197
|
-
*
|
|
198
|
-
* The purpose of the encryption transformer is to generate pseudo-random values in a deterministic manner to obscure
|
|
199
|
-
* the sequence of values generated over time. A typical example is for serial number generation, where knowledge of the
|
|
200
|
-
* sequence can infer production volumes (e.g., serial number 1000 implies that at least 1,000 units have been
|
|
201
|
-
* manufactured) or can be used in counterfeiting (e.g., a counterfeiter can generate serial numbers 1001, 1002, ...
|
|
202
|
-
* with reasonable confidence that they would be valid if queried).
|
|
203
|
-
*
|
|
204
|
-
* The domain and the tweak together determine the encryption key, which in turn determines the number of rounds of
|
|
205
|
-
* shuffle and xor operations. The minimum number of rounds is 4, except where the domain is less than or equal to 256,
|
|
206
|
-
* which results in single-byte operations. To ensure that the operations are effective for single-byte domains, the
|
|
207
|
-
* number of rounds is 1 and only the xor operation is applied (shuffling a single byte is an identity operation).
|
|
208
|
-
*
|
|
209
|
-
* Another exception is when there is a tweak value of 0; this results in identity operations where the output value is
|
|
210
|
-
* identical to the input value, as no shuffle or xor takes place.
|
|
211
|
-
*/
|
|
212
|
-
export class EncryptionTransformer extends Transformer {
|
|
213
|
-
/**
|
|
214
|
-
* Individual bits, pre-calculated for performance.
|
|
215
|
-
*/
|
|
216
|
-
static BITS = new Uint8Array([
|
|
217
|
-
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
|
|
218
|
-
]);
|
|
219
|
-
/**
|
|
220
|
-
* Inverse individual bits, pre-calculated for performance.
|
|
221
|
-
*/
|
|
222
|
-
static INVERSE_BITS = new Uint8Array([
|
|
223
|
-
0xFE, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF, 0x7F
|
|
224
|
-
]);
|
|
225
|
-
/**
|
|
226
|
-
* Number of bytes covered by the domain.
|
|
227
|
-
*/
|
|
228
|
-
_domainBytes;
|
|
229
|
-
/**
|
|
230
|
-
* Xor bytes array generated from the domain and tweak.
|
|
231
|
-
*/
|
|
232
|
-
_xorBytes;
|
|
233
|
-
/**
|
|
234
|
-
* Bits array generated from the domain and tweak.
|
|
235
|
-
*/
|
|
236
|
-
_bits;
|
|
237
|
-
/**
|
|
238
|
-
* Inverse bits array generated from the domain and tweak.
|
|
239
|
-
*/
|
|
240
|
-
_inverseBits;
|
|
241
|
-
/**
|
|
242
|
-
* Number of rounds (length of arrays) generated from the domain and tweak.
|
|
243
|
-
*/
|
|
244
|
-
_rounds;
|
|
245
|
-
/**
|
|
246
|
-
* Constructor.
|
|
247
|
-
*
|
|
248
|
-
* @param domain
|
|
249
|
-
* Domain.
|
|
250
|
-
*
|
|
251
|
-
* @param tweak
|
|
252
|
-
* Tweak.
|
|
253
|
-
*/
|
|
254
|
-
constructor(domain, tweak) {
|
|
255
|
-
super(domain);
|
|
256
|
-
if (tweak < 0n) {
|
|
257
|
-
throw new RangeError(i18nextUtility.t("Transformer.tweakMustBeGreaterThanOrEqualToZero", {
|
|
258
|
-
tweak
|
|
259
|
-
}));
|
|
260
|
-
}
|
|
261
|
-
let domainBytes = 0;
|
|
262
|
-
// The number of bytes in the domain determines the size of the shuffle and xor operations.
|
|
263
|
-
for (let reducedDomainMinusOne = this.domain - 1n; reducedDomainMinusOne !== 0n; reducedDomainMinusOne >>= 8n) {
|
|
264
|
-
domainBytes++;
|
|
265
|
-
}
|
|
266
|
-
this._domainBytes = domainBytes;
|
|
267
|
-
const xorBytes = new Array();
|
|
268
|
-
const bits = new Array();
|
|
269
|
-
const inverseBits = new Array();
|
|
270
|
-
// Key is the product of domain, tweak, and an 8-digit prime to force at least four rounds.
|
|
271
|
-
for (let reducedKey = this.domain * BigInt(tweak) * 603868999n; reducedKey !== 0n; reducedKey >>= 8n) {
|
|
272
|
-
// Extract the least significant byte.
|
|
273
|
-
xorBytes.unshift(Number(BigInt.asUintN(8, reducedKey)));
|
|
274
|
-
// Bit number is the reduced key mod 8.
|
|
275
|
-
const bitNumber = Number(BigInt.asUintN(3, reducedKey));
|
|
276
|
-
// Bits are applied in reverse order so that they don't correlate directly with the key bytes at the same index.
|
|
277
|
-
bits.push(EncryptionTransformer.BITS[bitNumber]);
|
|
278
|
-
inverseBits.push(EncryptionTransformer.INVERSE_BITS[bitNumber]);
|
|
279
|
-
}
|
|
280
|
-
// Domains occupying a single byte will not shuffle and will map all values to themselves for very small domains.
|
|
281
|
-
if (domainBytes === 1) {
|
|
282
|
-
// Determine the lowest possible mask that will cover all values in the domain.
|
|
283
|
-
const domainMask = EncryptionTransformer.BITS.filter(bit => bit < domain).reduce((accumulator, bit) => accumulator | bit, 0);
|
|
284
|
-
// Reduce all xor bytes to a single byte and strip higher bits.
|
|
285
|
-
this._xorBytes = new Uint8Array([xorBytes.reduce((accumulator, xorByte) => accumulator ^ xorByte, 0) & domainMask]);
|
|
286
|
-
// Bits and inverse bits are irrelevant as there will be no shuffling; choose first bit arbitrarily.
|
|
287
|
-
this._bits = new Uint8Array([EncryptionTransformer.BITS[0]]);
|
|
288
|
-
this._inverseBits = new Uint8Array([EncryptionTransformer.INVERSE_BITS[0]]);
|
|
289
|
-
// Everything will be done in one round.
|
|
290
|
-
this._rounds = 1;
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
this._xorBytes = new Uint8Array(xorBytes);
|
|
294
|
-
this._bits = new Uint8Array(bits);
|
|
295
|
-
this._inverseBits = new Uint8Array(inverseBits);
|
|
296
|
-
this._rounds = xorBytes.length;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Convert a value to a byte array big enough to handle the entire domain.
|
|
301
|
-
*
|
|
302
|
-
* @param value
|
|
303
|
-
* Value.
|
|
304
|
-
*
|
|
305
|
-
* @returns
|
|
306
|
-
* Big-endian byte array equivalent to the value.
|
|
307
|
-
*/
|
|
308
|
-
valueToBytes(value) {
|
|
309
|
-
const bytes = new Uint8Array(this._domainBytes);
|
|
310
|
-
// Build byte array in reverse order to get as big-endian.
|
|
311
|
-
for (let index = this._domainBytes - 1, reducedValue = value; index >= 0 && reducedValue !== 0n; index--, reducedValue >>= 8n) {
|
|
312
|
-
bytes[index] = Number(BigInt.asUintN(8, reducedValue));
|
|
313
|
-
}
|
|
314
|
-
return bytes;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Convert a byte array to a value.
|
|
318
|
-
*
|
|
319
|
-
* @param bytes
|
|
320
|
-
* Big-endian byte array equivalent to the value.
|
|
321
|
-
*
|
|
322
|
-
* @returns
|
|
323
|
-
* Value.
|
|
324
|
-
*/
|
|
325
|
-
static bytesToValue(bytes) {
|
|
326
|
-
return bytes.reduce((accumulator, byte) => accumulator << 8n | BigInt(byte), 0n);
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Shuffle a byte array.
|
|
330
|
-
*
|
|
331
|
-
* The input array to the forward operation (output from the reverse operation) is `bytes` and the output array from
|
|
332
|
-
* the forward operation (input to the reverse operation) is `bytes'`.
|
|
333
|
-
*
|
|
334
|
-
* The shuffle operation starts by testing the bit at `bits[round]` for each `byte` in `bytes`. The indexes for all
|
|
335
|
-
* bytes with that bit set are put into one array (`shuffleIndexes1`) and the rest are put into another
|
|
336
|
-
* (`shuffleIndexes0`). The two arrays are concatenated and used to shuffle the input array, using their values
|
|
337
|
-
* (`shuffleIndex`) and the indexes of those values (`index`) in the concatenated array.
|
|
338
|
-
*
|
|
339
|
-
* Forward shuffling moves the entry at `shuffleIndex` to the `index` position.
|
|
340
|
-
*
|
|
341
|
-
* Reverse shuffling moves the entry at `index` to the `shuffleIndex` position.
|
|
342
|
-
*
|
|
343
|
-
* As each byte is moved, the bit at `bits[round]` is preserved in its original position. This ensures that the
|
|
344
|
-
* process is reversible.
|
|
345
|
-
*
|
|
346
|
-
* @param bytes
|
|
347
|
-
* Byte array.
|
|
348
|
-
*
|
|
349
|
-
* @param round
|
|
350
|
-
* Round number.
|
|
351
|
-
*
|
|
352
|
-
* @param forward
|
|
353
|
-
* True if operating forward (encrypting), false if operating in reverse (decrypting).
|
|
354
|
-
*
|
|
355
|
-
* @returns
|
|
356
|
-
* Shuffled byte array.
|
|
357
|
-
*/
|
|
358
|
-
shuffle(bytes, round, forward) {
|
|
359
|
-
const bytesLength = bytes.length;
|
|
360
|
-
const determinants = new Uint8Array(bytesLength);
|
|
361
|
-
const shuffleIndexes1 = new Array();
|
|
362
|
-
const shuffleIndexes0 = new Array();
|
|
363
|
-
const bit = this._bits[round];
|
|
364
|
-
bytes.forEach((byte, index) => {
|
|
365
|
-
const determinant = byte & bit;
|
|
366
|
-
determinants[index] = determinant;
|
|
367
|
-
// Place byte in array chosen by bit state.
|
|
368
|
-
(determinant !== 0 ? shuffleIndexes1 : shuffleIndexes0).push(index);
|
|
369
|
-
});
|
|
370
|
-
const inverseBit = this._inverseBits[round];
|
|
371
|
-
const shuffleBytes = new Uint8Array(bytesLength);
|
|
372
|
-
// Concatenate shuffle indexes arrays and complete shuffle.
|
|
373
|
-
[...shuffleIndexes1, ...shuffleIndexes0].forEach((shuffleIndex, index) => {
|
|
374
|
-
if (forward) {
|
|
375
|
-
shuffleBytes[index] = (bytes[shuffleIndex] & inverseBit) | determinants[index];
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
shuffleBytes[shuffleIndex] = (bytes[index] & inverseBit) | determinants[shuffleIndex];
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
return shuffleBytes;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Xor a byte array.
|
|
385
|
-
*
|
|
386
|
-
* The input array to the forward operation (output from the reverse operation) is `bytes` and the output array from
|
|
387
|
-
* the forward operation (input to the reverse operation) is `bytes'`.
|
|
388
|
-
*
|
|
389
|
-
* Forward:
|
|
390
|
-
* - `bytes'[0] = bytes[0] ^ xorBytes[round]`
|
|
391
|
-
* - `bytes'[1] = bytes[1] ^ bytes'[0]`
|
|
392
|
-
* - `bytes'[2] = bytes[2] ^ bytes'[1]`
|
|
393
|
-
* - `...`
|
|
394
|
-
* - `bytes'[domainBytes - 1] = bytes[domainBytes - 1] ^ bytes'[domainBytes - 2]`
|
|
395
|
-
*
|
|
396
|
-
* Reverse:
|
|
397
|
-
* - `bytes[0] = bytes'[0] ^ xorBytes[round]`
|
|
398
|
-
* - `bytes[1] = bytes'[1] ^ bytes'[0]`
|
|
399
|
-
* - `bytes[2] = bytes'[2] ^ bytes'[1]`
|
|
400
|
-
* - `...`
|
|
401
|
-
* - `bytes[domainBytes - 1] = bytes'[domainBytes - 1] ^ bytes'[domainBytes - 2]`
|
|
402
|
-
*
|
|
403
|
-
* @param bytes
|
|
404
|
-
* Byte array.
|
|
405
|
-
*
|
|
406
|
-
* @param round
|
|
407
|
-
* Round number.
|
|
408
|
-
*
|
|
409
|
-
* @param forward
|
|
410
|
-
* True if operating forward (encrypting), false if operating in reverse (decrypting).
|
|
411
|
-
*
|
|
412
|
-
* @returns
|
|
413
|
-
* Xored byte array.
|
|
414
|
-
*/
|
|
415
|
-
xor(bytes, round, forward) {
|
|
416
|
-
let cumulativeXorByte = this._xorBytes[round];
|
|
417
|
-
return bytes.map((byte) => {
|
|
418
|
-
const xorByte = byte ^ cumulativeXorByte;
|
|
419
|
-
cumulativeXorByte = forward ? xorByte : byte;
|
|
420
|
-
return xorByte;
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* @inheritDoc
|
|
425
|
-
*/
|
|
426
|
-
doForward(value) {
|
|
427
|
-
let bytes = this.valueToBytes(value);
|
|
428
|
-
let transformedValue;
|
|
429
|
-
// Loop repeats until transformed value is within domain.
|
|
430
|
-
do {
|
|
431
|
-
// Forward operation is shuffle then xor for the number of rounds.
|
|
432
|
-
for (let round = 0; round < this._rounds; round++) {
|
|
433
|
-
bytes = this.xor(this.shuffle(bytes, round, true), round, true);
|
|
434
|
-
}
|
|
435
|
-
transformedValue = EncryptionTransformer.bytesToValue(bytes);
|
|
436
|
-
} while (transformedValue >= this.domain);
|
|
437
|
-
return transformedValue;
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* @inheritDoc
|
|
441
|
-
*/
|
|
442
|
-
doReverse(transformedValue) {
|
|
443
|
-
let bytes = this.valueToBytes(transformedValue);
|
|
444
|
-
let value;
|
|
445
|
-
// Loop repeats until value is within domain.
|
|
446
|
-
do {
|
|
447
|
-
// Reverse operation is xor then shuffle for the number of rounds in reverse.
|
|
448
|
-
for (let round = this._rounds - 1; round >= 0; round--) {
|
|
449
|
-
bytes = this.shuffle(this.xor(bytes, round, false), round, false);
|
|
450
|
-
}
|
|
451
|
-
value = EncryptionTransformer.bytesToValue(bytes);
|
|
452
|
-
} while (value >= this.domain);
|
|
453
|
-
return value;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
//# sourceMappingURL=transformer.js.map
|
package/dist/transformer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.js","sourceRoot":"","sources":["../src/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAgCzC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAgB,WAAW;IAC7B;;OAEG;IACK,MAAM,CAAU,oBAAoB,GAAG,IAAI,GAAG,EAAgD,CAAC;IAEvG;;OAEG;IACc,OAAO,CAAS;IAEjC;;;;;OAKG;IACH,YAAY,MAAuB;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAE9B,IAAI,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YACrB,MAAM,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,yCAAyC,EAAE;gBAC7E,MAAM;aACT,CAAC,CAAC,CAAC;QACR,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,GAAG,CAAC,MAAuB,EAAE,KAAuB;QACvD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAE/B,IAAI,eAAe,G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