mol_crypto2_lib 0.0.116 → 0.0.118
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.d.ts +8 -1
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +30 -1
- package/node.js.map +1 -1
- package/node.meta.tree +1 -0
- package/node.mjs +30 -1
- package/node.test.js +60 -1
- package/node.test.js.map +1 -1
- package/package.json +3 -2
- package/web.d.ts +8 -1
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +30 -1
- package/web.js.map +1 -1
- package/web.meta.tree +1 -0
- package/web.mjs +30 -1
- package/web.test.js +30 -0
- package/web.test.js.map +1 -1
package/node.meta.tree
CHANGED
package/node.mjs
CHANGED
|
@@ -2954,7 +2954,7 @@ var $;
|
|
|
2954
2954
|
socket() {
|
|
2955
2955
|
return $mol_crypto2_socket.from(this.asArray());
|
|
2956
2956
|
}
|
|
2957
|
-
/** Makes shared secret for combination of Chiper and
|
|
2957
|
+
/** Makes shared secret for combination of Chiper and Socket. */
|
|
2958
2958
|
async secret(pub) {
|
|
2959
2959
|
return $mol_crypto_sacred.from(new Uint8Array(await $mol_crypto_native.subtle.deriveBits({
|
|
2960
2960
|
name: "X25519",
|
|
@@ -3067,6 +3067,35 @@ var $;
|
|
|
3067
3067
|
$.$mol_crypto2_private = $mol_crypto2_private;
|
|
3068
3068
|
})($ || ($ = {}));
|
|
3069
3069
|
|
|
3070
|
+
;
|
|
3071
|
+
"use strict";
|
|
3072
|
+
var $;
|
|
3073
|
+
(function ($) {
|
|
3074
|
+
/** Pads any buffer view to a multiple of 16 bytes. */
|
|
3075
|
+
function $mol_crypto2_padding_add(data) {
|
|
3076
|
+
const source = data instanceof Uint8Array
|
|
3077
|
+
? data
|
|
3078
|
+
: new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
3079
|
+
const count = 16 - source.byteLength % 16;
|
|
3080
|
+
const padded = new Uint8Array(source.byteLength + count);
|
|
3081
|
+
padded.set(source);
|
|
3082
|
+
this.$mol_crypto_native.getRandomValues(padded.subarray(source.byteLength));
|
|
3083
|
+
padded[padded.byteLength - 1] = (padded[padded.byteLength - 1] & 0xF0) | (count & 0x0F);
|
|
3084
|
+
return padded;
|
|
3085
|
+
}
|
|
3086
|
+
$.$mol_crypto2_padding_add = $mol_crypto2_padding_add;
|
|
3087
|
+
/** Returns a view without the padding bytes. */
|
|
3088
|
+
function $mol_crypto2_padding_crop(data) {
|
|
3089
|
+
const source = data instanceof Uint8Array
|
|
3090
|
+
? data
|
|
3091
|
+
: new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
3092
|
+
const marker = source[source.byteLength - 1] & 0x0F;
|
|
3093
|
+
const count = marker || 16;
|
|
3094
|
+
return source.subarray(0, source.byteLength - count);
|
|
3095
|
+
}
|
|
3096
|
+
$.$mol_crypto2_padding_crop = $mol_crypto2_padding_crop;
|
|
3097
|
+
})($ || ($ = {}));
|
|
3098
|
+
|
|
3070
3099
|
|
|
3071
3100
|
export default $
|
|
3072
3101
|
//# sourceMappingURL=node.js.map
|
package/node.test.js
CHANGED
|
@@ -2945,7 +2945,7 @@ var $;
|
|
|
2945
2945
|
socket() {
|
|
2946
2946
|
return $mol_crypto2_socket.from(this.asArray());
|
|
2947
2947
|
}
|
|
2948
|
-
/** Makes shared secret for combination of Chiper and
|
|
2948
|
+
/** Makes shared secret for combination of Chiper and Socket. */
|
|
2949
2949
|
async secret(pub) {
|
|
2950
2950
|
return $mol_crypto_sacred.from(new Uint8Array(await $mol_crypto_native.subtle.deriveBits({
|
|
2951
2951
|
name: "X25519",
|
|
@@ -3058,6 +3058,35 @@ var $;
|
|
|
3058
3058
|
$.$mol_crypto2_private = $mol_crypto2_private;
|
|
3059
3059
|
})($ || ($ = {}));
|
|
3060
3060
|
|
|
3061
|
+
;
|
|
3062
|
+
"use strict";
|
|
3063
|
+
var $;
|
|
3064
|
+
(function ($) {
|
|
3065
|
+
/** Pads any buffer view to a multiple of 16 bytes. */
|
|
3066
|
+
function $mol_crypto2_padding_add(data) {
|
|
3067
|
+
const source = data instanceof Uint8Array
|
|
3068
|
+
? data
|
|
3069
|
+
: new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
3070
|
+
const count = 16 - source.byteLength % 16;
|
|
3071
|
+
const padded = new Uint8Array(source.byteLength + count);
|
|
3072
|
+
padded.set(source);
|
|
3073
|
+
this.$mol_crypto_native.getRandomValues(padded.subarray(source.byteLength));
|
|
3074
|
+
padded[padded.byteLength - 1] = (padded[padded.byteLength - 1] & 0xF0) | (count & 0x0F);
|
|
3075
|
+
return padded;
|
|
3076
|
+
}
|
|
3077
|
+
$.$mol_crypto2_padding_add = $mol_crypto2_padding_add;
|
|
3078
|
+
/** Returns a view without the padding bytes. */
|
|
3079
|
+
function $mol_crypto2_padding_crop(data) {
|
|
3080
|
+
const source = data instanceof Uint8Array
|
|
3081
|
+
? data
|
|
3082
|
+
: new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
3083
|
+
const marker = source[source.byteLength - 1] & 0x0F;
|
|
3084
|
+
const count = marker || 16;
|
|
3085
|
+
return source.subarray(0, source.byteLength - count);
|
|
3086
|
+
}
|
|
3087
|
+
$.$mol_crypto2_padding_crop = $mol_crypto2_padding_crop;
|
|
3088
|
+
})($ || ($ = {}));
|
|
3089
|
+
|
|
3061
3090
|
;
|
|
3062
3091
|
"use strict";
|
|
3063
3092
|
var $;
|
|
@@ -5599,5 +5628,35 @@ var $;
|
|
|
5599
5628
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
5600
5629
|
})($ || ($ = {}));
|
|
5601
5630
|
|
|
5631
|
+
;
|
|
5632
|
+
"use strict";
|
|
5633
|
+
var $;
|
|
5634
|
+
(function ($_1) {
|
|
5635
|
+
$mol_test({
|
|
5636
|
+
'Pads buffer views to 16 bytes'($) {
|
|
5637
|
+
const buffer = new Uint8Array([9, 1, 2, 3, 8]);
|
|
5638
|
+
const data = buffer.subarray(1, 4);
|
|
5639
|
+
const padded = $$.$mol_crypto2_padding_add.call($, data);
|
|
5640
|
+
$mol_assert_equal(padded.subarray(0, 3), data);
|
|
5641
|
+
$mol_assert_unique(padded.subarray(3), new Uint8Array(13));
|
|
5642
|
+
$mol_assert_equal(padded[15] & 0x0F, 13);
|
|
5643
|
+
const cropped = $$.$mol_crypto2_padding_crop.call($, padded);
|
|
5644
|
+
$mol_assert_equal(cropped, data);
|
|
5645
|
+
$mol_assert_equal(cropped.buffer, padded.buffer);
|
|
5646
|
+
},
|
|
5647
|
+
'Adds full block when already padded'($) {
|
|
5648
|
+
const buffer = Uint8Array.from({ length: 18 }, (_, i) => i);
|
|
5649
|
+
const data = buffer.subarray(1, 17);
|
|
5650
|
+
const padded = $$.$mol_crypto2_padding_add.call($, data);
|
|
5651
|
+
$mol_assert_equal(padded.subarray(0, 16), data);
|
|
5652
|
+
$mol_assert_unique(padded.subarray(16), new Uint8Array(16));
|
|
5653
|
+
$mol_assert_equal(padded[31] & 0x0F, 0);
|
|
5654
|
+
const cropped = $$.$mol_crypto2_padding_crop.call($, padded);
|
|
5655
|
+
$mol_assert_equal(cropped, data);
|
|
5656
|
+
$mol_assert_equal(cropped.buffer, padded.buffer);
|
|
5657
|
+
},
|
|
5658
|
+
});
|
|
5659
|
+
})($ || ($ = {}));
|
|
5660
|
+
|
|
5602
5661
|
|
|
5603
5662
|
//# sourceMappingURL=node.test.js.map
|