@cloudpss/crypto 0.6.0-alpha.9 → 0.6.0-beta.1
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/lib/wasm.d.ts +6 -4
- package/lib/wasm_bg.js +29 -32
- package/lib/wasm_bg.wasm +0 -0
- package/lib/wasm_bg.wasm.d.ts +3 -3
- package/package.json +1 -1
package/lib/wasm.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
* Encrypts the given data using PBKDF2 and AES-GCM.
|
|
5
|
-
*/
|
|
6
|
-
export function encrypt(passphrase: Uint8Array, data: Uint8Array, aad: Uint8Array, nonce: Uint8Array, pbkdf2_iterations: number, aes_key_size: number, aes_tag_size: number): Uint8Array;
|
|
3
|
+
|
|
7
4
|
/**
|
|
8
5
|
* Decrypts the given data using PBKDF2 and AES-GCM.
|
|
9
6
|
*/
|
|
10
7
|
export function decrypt(passphrase: Uint8Array, data: Uint8Array, aad: Uint8Array, nonce: Uint8Array, pbkdf2_iterations: number, aes_key_size: number, aes_tag_size: number): Uint8Array;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Encrypts the given data using PBKDF2 and AES-GCM.
|
|
11
|
+
*/
|
|
12
|
+
export function encrypt(passphrase: Uint8Array, data: Uint8Array, aad: Uint8Array, nonce: Uint8Array, pbkdf2_iterations: number, aes_key_size: number, aes_tag_size: number): Uint8Array;
|
package/lib/wasm_bg.js
CHANGED
|
@@ -3,9 +3,20 @@ export function __wbg_set_wasm(val) {
|
|
|
3
3
|
wasm = val;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
7
|
+
ptr = ptr >>> 0;
|
|
8
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
9
|
+
}
|
|
6
10
|
|
|
7
|
-
let
|
|
11
|
+
let cachedDataViewMemory0 = null;
|
|
12
|
+
function getDataViewMemory0() {
|
|
13
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
14
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
15
|
+
}
|
|
16
|
+
return cachedDataViewMemory0;
|
|
17
|
+
}
|
|
8
18
|
|
|
19
|
+
let cachedUint8ArrayMemory0 = null;
|
|
9
20
|
function getUint8ArrayMemory0() {
|
|
10
21
|
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
11
22
|
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
@@ -13,8 +24,6 @@ function getUint8ArrayMemory0() {
|
|
|
13
24
|
return cachedUint8ArrayMemory0;
|
|
14
25
|
}
|
|
15
26
|
|
|
16
|
-
let WASM_VECTOR_LEN = 0;
|
|
17
|
-
|
|
18
27
|
function passArray8ToWasm0(arg, malloc) {
|
|
19
28
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
20
29
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
@@ -22,21 +31,10 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
22
31
|
return ptr;
|
|
23
32
|
}
|
|
24
33
|
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
function getDataViewMemory0() {
|
|
28
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
29
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
30
|
-
}
|
|
31
|
-
return cachedDataViewMemory0;
|
|
32
|
-
}
|
|
34
|
+
let WASM_VECTOR_LEN = 0;
|
|
33
35
|
|
|
34
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
35
|
-
ptr = ptr >>> 0;
|
|
36
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
37
|
-
}
|
|
38
36
|
/**
|
|
39
|
-
*
|
|
37
|
+
* Decrypts the given data using PBKDF2 and AES-GCM.
|
|
40
38
|
* @param {Uint8Array} passphrase
|
|
41
39
|
* @param {Uint8Array} data
|
|
42
40
|
* @param {Uint8Array} aad
|
|
@@ -46,22 +44,22 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
46
44
|
* @param {number} aes_tag_size
|
|
47
45
|
* @returns {Uint8Array}
|
|
48
46
|
*/
|
|
49
|
-
export function
|
|
47
|
+
export function decrypt(passphrase, data, aad, nonce, pbkdf2_iterations, aes_key_size, aes_tag_size) {
|
|
50
48
|
try {
|
|
51
49
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
52
|
-
const ptr0 = passArray8ToWasm0(passphrase, wasm.
|
|
50
|
+
const ptr0 = passArray8ToWasm0(passphrase, wasm.__wbindgen_export);
|
|
53
51
|
const len0 = WASM_VECTOR_LEN;
|
|
54
|
-
const ptr1 = passArray8ToWasm0(data, wasm.
|
|
52
|
+
const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
55
53
|
const len1 = WASM_VECTOR_LEN;
|
|
56
|
-
const ptr2 = passArray8ToWasm0(aad, wasm.
|
|
54
|
+
const ptr2 = passArray8ToWasm0(aad, wasm.__wbindgen_export);
|
|
57
55
|
const len2 = WASM_VECTOR_LEN;
|
|
58
|
-
const ptr3 = passArray8ToWasm0(nonce, wasm.
|
|
56
|
+
const ptr3 = passArray8ToWasm0(nonce, wasm.__wbindgen_export);
|
|
59
57
|
const len3 = WASM_VECTOR_LEN;
|
|
60
|
-
wasm.
|
|
58
|
+
wasm.decrypt(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pbkdf2_iterations, aes_key_size, aes_tag_size);
|
|
61
59
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
62
60
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
63
61
|
var v5 = getArrayU8FromWasm0(r0, r1).slice();
|
|
64
|
-
wasm.
|
|
62
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
65
63
|
return v5;
|
|
66
64
|
} finally {
|
|
67
65
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
@@ -69,7 +67,7 @@ export function encrypt(passphrase, data, aad, nonce, pbkdf2_iterations, aes_key
|
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
/**
|
|
72
|
-
*
|
|
70
|
+
* Encrypts the given data using PBKDF2 and AES-GCM.
|
|
73
71
|
* @param {Uint8Array} passphrase
|
|
74
72
|
* @param {Uint8Array} data
|
|
75
73
|
* @param {Uint8Array} aad
|
|
@@ -79,25 +77,24 @@ export function encrypt(passphrase, data, aad, nonce, pbkdf2_iterations, aes_key
|
|
|
79
77
|
* @param {number} aes_tag_size
|
|
80
78
|
* @returns {Uint8Array}
|
|
81
79
|
*/
|
|
82
|
-
export function
|
|
80
|
+
export function encrypt(passphrase, data, aad, nonce, pbkdf2_iterations, aes_key_size, aes_tag_size) {
|
|
83
81
|
try {
|
|
84
82
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
85
|
-
const ptr0 = passArray8ToWasm0(passphrase, wasm.
|
|
83
|
+
const ptr0 = passArray8ToWasm0(passphrase, wasm.__wbindgen_export);
|
|
86
84
|
const len0 = WASM_VECTOR_LEN;
|
|
87
|
-
const ptr1 = passArray8ToWasm0(data, wasm.
|
|
85
|
+
const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
88
86
|
const len1 = WASM_VECTOR_LEN;
|
|
89
|
-
const ptr2 = passArray8ToWasm0(aad, wasm.
|
|
87
|
+
const ptr2 = passArray8ToWasm0(aad, wasm.__wbindgen_export);
|
|
90
88
|
const len2 = WASM_VECTOR_LEN;
|
|
91
|
-
const ptr3 = passArray8ToWasm0(nonce, wasm.
|
|
89
|
+
const ptr3 = passArray8ToWasm0(nonce, wasm.__wbindgen_export);
|
|
92
90
|
const len3 = WASM_VECTOR_LEN;
|
|
93
|
-
wasm.
|
|
91
|
+
wasm.encrypt(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, pbkdf2_iterations, aes_key_size, aes_tag_size);
|
|
94
92
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
95
93
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
96
94
|
var v5 = getArrayU8FromWasm0(r0, r1).slice();
|
|
97
|
-
wasm.
|
|
95
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
98
96
|
return v5;
|
|
99
97
|
} finally {
|
|
100
98
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
101
99
|
}
|
|
102
100
|
}
|
|
103
|
-
|
package/lib/wasm_bg.wasm
CHANGED
|
Binary file
|
package/lib/wasm_bg.wasm.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const encrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
5
4
|
export const decrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
5
|
+
export const encrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
6
6
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
7
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
8
|
+
export const __wbindgen_export2: (a: number, b: number, c: number) => void;
|