react-native-quick-crypto 1.0.0-beta.15 → 1.0.0-beta.17
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/QuickCrypto.podspec +66 -7
- package/README.md +7 -3
- package/android/CMakeLists.txt +18 -6
- package/android/build.gradle +9 -1
- package/cpp/cipher/ChaCha20Cipher.cpp +97 -0
- package/cpp/cipher/ChaCha20Cipher.hpp +25 -0
- package/cpp/cipher/ChaCha20Poly1305Cipher.cpp +170 -0
- package/cpp/cipher/ChaCha20Poly1305Cipher.hpp +30 -0
- package/cpp/cipher/HybridCipher.cpp +0 -1
- package/cpp/cipher/HybridCipher.hpp +0 -1
- package/cpp/cipher/HybridCipherFactory.hpp +61 -28
- package/cpp/cipher/XSalsa20Cipher.cpp +61 -0
- package/cpp/cipher/XSalsa20Cipher.hpp +33 -0
- package/cpp/random/HybridRandom.cpp +2 -2
- package/cpp/utils/Utils.hpp +15 -0
- package/deps/fastpbkdf2/fastpbkdf2.c +5 -1
- package/lib/commonjs/cipher.js +29 -6
- package/lib/commonjs/cipher.js.map +1 -1
- package/lib/commonjs/index.js +5 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/cipher.js +28 -5
- package/lib/module/cipher.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/typescript/cipher.d.ts +17 -9
- package/lib/typescript/cipher.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +11 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/cipher.ts +41 -9
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-quick-crypto",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.17",
|
|
4
4
|
"description": "A fast implementation of Node's `crypto` module written in C/C++ JSI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"registry": "https://registry.npmjs.org/"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@craftzdog/react-native-buffer": "6.0
|
|
71
|
+
"@craftzdog/react-native-buffer": "6.1.0",
|
|
72
72
|
"events": "3.3.0",
|
|
73
|
-
"react-native-quick-base64": "2.
|
|
73
|
+
"react-native-quick-base64": "2.2.0",
|
|
74
74
|
"readable-stream": "4.5.2",
|
|
75
75
|
"util": "0.12.5"
|
|
76
76
|
},
|
package/src/cipher.ts
CHANGED
|
@@ -96,6 +96,13 @@ class CipherCommon extends Stream.Transform {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
update(data: Buffer): Buffer;
|
|
100
|
+
update(data: BinaryLike, inputEncoding?: Encoding): Buffer;
|
|
101
|
+
update(
|
|
102
|
+
data: BinaryLike,
|
|
103
|
+
inputEncoding: Encoding,
|
|
104
|
+
outputEncoding: Encoding,
|
|
105
|
+
): string;
|
|
99
106
|
update(
|
|
100
107
|
data: BinaryLike,
|
|
101
108
|
inputEncoding?: Encoding,
|
|
@@ -207,7 +214,7 @@ class Cipheriv extends CipherCommon {
|
|
|
207
214
|
}
|
|
208
215
|
}
|
|
209
216
|
|
|
210
|
-
type Cipher = Cipheriv;
|
|
217
|
+
export type Cipher = Cipheriv;
|
|
211
218
|
|
|
212
219
|
class Decipheriv extends CipherCommon {
|
|
213
220
|
constructor(
|
|
@@ -226,7 +233,7 @@ class Decipheriv extends CipherCommon {
|
|
|
226
233
|
}
|
|
227
234
|
}
|
|
228
235
|
|
|
229
|
-
type Decipher = Decipheriv;
|
|
236
|
+
export type Decipher = Decipheriv;
|
|
230
237
|
|
|
231
238
|
export function createDecipheriv(
|
|
232
239
|
algorithm: CipherCCMTypes,
|
|
@@ -294,10 +301,35 @@ export function createCipheriv(
|
|
|
294
301
|
return new Cipheriv(algorithm, key, iv, options);
|
|
295
302
|
}
|
|
296
303
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
+
/**
|
|
305
|
+
* xsalsa20 stream encryption with @noble/ciphers compatible API
|
|
306
|
+
*
|
|
307
|
+
* @param key - 32 bytes
|
|
308
|
+
* @param nonce - 24 bytes
|
|
309
|
+
* @param data - data to encrypt
|
|
310
|
+
* @param output - unused
|
|
311
|
+
* @param counter - unused
|
|
312
|
+
* @returns encrypted data
|
|
313
|
+
*/
|
|
314
|
+
export function xsalsa20(
|
|
315
|
+
key: Uint8Array,
|
|
316
|
+
nonce: Uint8Array,
|
|
317
|
+
data: Uint8Array,
|
|
318
|
+
// @ts-expect-error haven't implemented this part of @noble/ciphers API
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
320
|
+
output?: Uint8Array | undefined,
|
|
321
|
+
// @ts-expect-error haven't implemented this part of @noble/ciphers API
|
|
322
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
323
|
+
counter?: number,
|
|
324
|
+
): Uint8Array {
|
|
325
|
+
const factory =
|
|
326
|
+
NitroModules.createHybridObject<CipherFactory>('CipherFactory');
|
|
327
|
+
const native = factory.createCipher({
|
|
328
|
+
isCipher: true,
|
|
329
|
+
cipherType: 'xsalsa20',
|
|
330
|
+
cipherKey: binaryLikeToArrayBuffer(key),
|
|
331
|
+
iv: binaryLikeToArrayBuffer(nonce),
|
|
332
|
+
});
|
|
333
|
+
const result = native.update(binaryLikeToArrayBuffer(data));
|
|
334
|
+
return new Uint8Array(result);
|
|
335
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Buffer } from '@craftzdog/react-native-buffer';
|
|
|
3
3
|
|
|
4
4
|
// API imports
|
|
5
5
|
import * as keys from './keys';
|
|
6
|
-
import
|
|
6
|
+
import * as cipher from './cipher';
|
|
7
7
|
import * as ed from './ed';
|
|
8
8
|
import { hashExports as hash } from './hash';
|
|
9
9
|
import { hmacExports as hmac } from './hmac';
|