mol_crypto_lib 0.1.1568 → 0.1.1570
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/node.js +7 -7
- package/node.js.map +1 -1
- package/node.mjs +7 -7
- package/node.test.js +11 -7
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.js +7 -7
- package/web.js.map +1 -1
- package/web.mjs +7 -7
- package/web.test.js +4 -0
- package/web.test.js.map +1 -1
package/node.mjs
CHANGED
@@ -2593,10 +2593,10 @@ var $;
|
|
2593
2593
|
const kword = 0x80 << (24 - bits & 0b11111);
|
2594
2594
|
const bytes = 16 + (bits + 64 >>> 9 << 4);
|
2595
2595
|
const klens = bytes - 1;
|
2596
|
-
const words = new
|
2596
|
+
const words = new DataView(data.buffer, data.byteOffset, data.byteLength >> 2 << 2);
|
2597
2597
|
let tail = 0;
|
2598
|
-
for (let i = words.
|
2599
|
-
tail |= data[i] << (
|
2598
|
+
for (let i = words.byteLength; i < data.length; ++i) {
|
2599
|
+
tail |= data[i] << ((3 - i & 0b11) << 3);
|
2600
2600
|
}
|
2601
2601
|
const hash = new Int32Array([1732584193, -271733879, -1732584194, 271733878, -1009589776]);
|
2602
2602
|
for (let i = 0; i < bytes; i += 16) {
|
@@ -2611,10 +2611,10 @@ var $;
|
|
2611
2611
|
sponge[j] = bits;
|
2612
2612
|
}
|
2613
2613
|
else {
|
2614
|
-
|
2615
|
-
|
2616
|
-
|
2617
|
-
|
2614
|
+
const pos = k << 2;
|
2615
|
+
let word = pos === words.byteLength ? tail :
|
2616
|
+
pos > words.byteLength ? 0 :
|
2617
|
+
words.getInt32(pos, false);
|
2618
2618
|
if (k === kbits)
|
2619
2619
|
word |= kword;
|
2620
2620
|
sponge[j] = word;
|
package/node.test.js
CHANGED
@@ -2584,10 +2584,10 @@ var $;
|
|
2584
2584
|
const kword = 0x80 << (24 - bits & 0b11111);
|
2585
2585
|
const bytes = 16 + (bits + 64 >>> 9 << 4);
|
2586
2586
|
const klens = bytes - 1;
|
2587
|
-
const words = new
|
2587
|
+
const words = new DataView(data.buffer, data.byteOffset, data.byteLength >> 2 << 2);
|
2588
2588
|
let tail = 0;
|
2589
|
-
for (let i = words.
|
2590
|
-
tail |= data[i] << (
|
2589
|
+
for (let i = words.byteLength; i < data.length; ++i) {
|
2590
|
+
tail |= data[i] << ((3 - i & 0b11) << 3);
|
2591
2591
|
}
|
2592
2592
|
const hash = new Int32Array([1732584193, -271733879, -1732584194, 271733878, -1009589776]);
|
2593
2593
|
for (let i = 0; i < bytes; i += 16) {
|
@@ -2602,10 +2602,10 @@ var $;
|
|
2602
2602
|
sponge[j] = bits;
|
2603
2603
|
}
|
2604
2604
|
else {
|
2605
|
-
|
2606
|
-
|
2607
|
-
|
2608
|
-
|
2605
|
+
const pos = k << 2;
|
2606
|
+
let word = pos === words.byteLength ? tail :
|
2607
|
+
pos > words.byteLength ? 0 :
|
2608
|
+
words.getInt32(pos, false);
|
2609
2609
|
if (k === kbits)
|
2610
2610
|
word |= kword;
|
2611
2611
|
sponge[j] = word;
|
@@ -4834,6 +4834,10 @@ var $;
|
|
4834
4834
|
'seven bytes hash'() {
|
4835
4835
|
$mol_assert_equal($mol_crypto_hash(new Uint8Array([1, 2, 3, 4, 5, 6, 7])), new Uint8Array([140, 31, 40, 252, 47, 72, 194, 113, 214, 196, 152, 240, 242, 73, 205, 222, 54, 92, 84, 197]));
|
4836
4836
|
},
|
4837
|
+
'unaligned hash'() {
|
4838
|
+
const data = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7]);
|
4839
|
+
$mol_assert_equal($mol_crypto_hash(new Uint8Array(data.buffer, 1, 7)), new Uint8Array([140, 31, 40, 252, 47, 72, 194, 113, 214, 196, 152, 240, 242, 73, 205, 222, 54, 92, 84, 197]));
|
4840
|
+
},
|
4837
4841
|
async 'reference'() {
|
4838
4842
|
const data = new Uint8Array([255, 254, 253]);
|
4839
4843
|
$mol_assert_equal($mol_crypto_hash(data), new Uint8Array(await $mol_crypto_native.subtle.digest('SHA-1', data)));
|