react-native-quick-crypto 0.7.0 → 0.7.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/android/CMakeLists.txt +2 -0
- package/cpp/Cipher/MGLRsa.cpp +179 -3
- package/cpp/Cipher/MGLRsa.h +40 -0
- package/cpp/JSIUtils/MGLJSIUtils.h +8 -0
- package/cpp/MGLKeys.cpp +41 -43
- package/cpp/MGLKeys.h +9 -2
- package/cpp/MGLQuickCryptoHostObject.cpp +6 -6
- package/cpp/Utils/MGLUtils.cpp +71 -1
- package/cpp/Utils/MGLUtils.h +55 -1
- package/cpp/webcrypto/MGLWebCrypto.cpp +89 -37
- package/cpp/webcrypto/MGLWebCrypto.h +5 -7
- package/cpp/webcrypto/crypto_aes.cpp +516 -0
- package/cpp/webcrypto/crypto_aes.h +79 -0
- package/cpp/webcrypto/crypto_ec.cpp +4 -20
- package/cpp/webcrypto/crypto_ec.h +0 -5
- package/cpp/webcrypto/crypto_keygen.cpp +86 -0
- package/cpp/webcrypto/crypto_keygen.h +38 -0
- package/lib/commonjs/Cipher.js +3 -1
- package/lib/commonjs/Cipher.js.map +1 -1
- package/lib/commonjs/Hashnames.js +20 -8
- package/lib/commonjs/Hashnames.js.map +1 -1
- package/lib/commonjs/NativeQuickCrypto/Cipher.js +13 -1
- package/lib/commonjs/NativeQuickCrypto/Cipher.js.map +1 -1
- package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js.map +1 -1
- package/lib/commonjs/NativeQuickCrypto/aes.js +6 -0
- package/lib/commonjs/NativeQuickCrypto/aes.js.map +1 -0
- package/lib/commonjs/NativeQuickCrypto/keygen.js +6 -0
- package/lib/commonjs/NativeQuickCrypto/keygen.js.map +1 -0
- package/lib/commonjs/NativeQuickCrypto/rsa.js +6 -0
- package/lib/commonjs/NativeQuickCrypto/rsa.js.map +1 -0
- package/lib/commonjs/Utils.js +30 -6
- package/lib/commonjs/Utils.js.map +1 -1
- package/lib/commonjs/aes.js +184 -227
- package/lib/commonjs/aes.js.map +1 -1
- package/lib/commonjs/index.js +12 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/keygen.js +56 -0
- package/lib/commonjs/keygen.js.map +1 -0
- package/lib/commonjs/keys.js +74 -5
- package/lib/commonjs/keys.js.map +1 -1
- package/lib/commonjs/rsa.js +115 -196
- package/lib/commonjs/rsa.js.map +1 -1
- package/lib/commonjs/sig.js.map +1 -1
- package/lib/commonjs/subtle.js +140 -78
- package/lib/commonjs/subtle.js.map +1 -1
- package/lib/commonjs/webcrypto.js +14 -0
- package/lib/commonjs/webcrypto.js.map +1 -0
- package/lib/module/Cipher.js +3 -1
- package/lib/module/Cipher.js.map +1 -1
- package/lib/module/Hashnames.js +20 -8
- package/lib/module/Hashnames.js.map +1 -1
- package/lib/module/NativeQuickCrypto/Cipher.js +12 -0
- package/lib/module/NativeQuickCrypto/Cipher.js.map +1 -1
- package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js.map +1 -1
- package/lib/module/NativeQuickCrypto/aes.js +2 -0
- package/lib/module/NativeQuickCrypto/aes.js.map +1 -0
- package/lib/module/NativeQuickCrypto/keygen.js +2 -0
- package/lib/module/NativeQuickCrypto/keygen.js.map +1 -0
- package/lib/module/NativeQuickCrypto/rsa.js +2 -0
- package/lib/module/NativeQuickCrypto/rsa.js.map +1 -0
- package/lib/module/Utils.js +26 -5
- package/lib/module/Utils.js.map +1 -1
- package/lib/module/aes.js +183 -228
- package/lib/module/aes.js.map +1 -1
- package/lib/module/index.js +11 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/keygen.js +47 -0
- package/lib/module/keygen.js.map +1 -0
- package/lib/module/keys.js +68 -4
- package/lib/module/keys.js.map +1 -1
- package/lib/module/rsa.js +115 -198
- package/lib/module/rsa.js.map +1 -1
- package/lib/module/sig.js.map +1 -1
- package/lib/module/subtle.js +143 -82
- package/lib/module/subtle.js.map +1 -1
- package/lib/module/webcrypto.js +8 -0
- package/lib/module/webcrypto.js.map +1 -0
- package/lib/typescript/Cipher.d.ts +0 -1
- package/lib/typescript/Cipher.d.ts.map +1 -1
- package/lib/typescript/Hash.d.ts.map +1 -1
- package/lib/typescript/Hashnames.d.ts +2 -2
- package/lib/typescript/Hashnames.d.ts.map +1 -1
- package/lib/typescript/NativeQuickCrypto/Cipher.d.ts +5 -0
- package/lib/typescript/NativeQuickCrypto/Cipher.d.ts.map +1 -1
- package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts +4 -1
- package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts.map +1 -1
- package/lib/typescript/NativeQuickCrypto/aes.d.ts +5 -0
- package/lib/typescript/NativeQuickCrypto/aes.d.ts.map +1 -0
- package/lib/typescript/NativeQuickCrypto/keygen.d.ts +4 -0
- package/lib/typescript/NativeQuickCrypto/keygen.d.ts.map +1 -0
- package/lib/typescript/NativeQuickCrypto/rsa.d.ts +5 -0
- package/lib/typescript/NativeQuickCrypto/rsa.d.ts.map +1 -0
- package/lib/typescript/NativeQuickCrypto/webcrypto.d.ts +12 -2
- package/lib/typescript/NativeQuickCrypto/webcrypto.d.ts.map +1 -1
- package/lib/typescript/Utils.d.ts +4 -4
- package/lib/typescript/Utils.d.ts.map +1 -1
- package/lib/typescript/aes.d.ts +18 -1
- package/lib/typescript/aes.d.ts.map +1 -1
- package/lib/typescript/ec.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +27 -24
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/keygen.d.ts +6 -0
- package/lib/typescript/keygen.d.ts.map +1 -0
- package/lib/typescript/keys.d.ts +55 -17
- package/lib/typescript/keys.d.ts.map +1 -1
- package/lib/typescript/rsa.d.ts +9 -1
- package/lib/typescript/rsa.d.ts.map +1 -1
- package/lib/typescript/sig.d.ts +3 -17
- package/lib/typescript/sig.d.ts.map +1 -1
- package/lib/typescript/subtle.d.ts +6 -5
- package/lib/typescript/subtle.d.ts.map +1 -1
- package/lib/typescript/webcrypto.d.ts +9 -0
- package/lib/typescript/webcrypto.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/Cipher.ts +1 -1
- package/src/Hashnames.ts +23 -21
- package/src/NativeQuickCrypto/Cipher.ts +32 -0
- package/src/NativeQuickCrypto/NativeQuickCrypto.ts +6 -0
- package/src/NativeQuickCrypto/aes.ts +14 -0
- package/src/NativeQuickCrypto/keygen.ts +7 -0
- package/src/NativeQuickCrypto/rsa.ts +12 -0
- package/src/NativeQuickCrypto/webcrypto.ts +26 -2
- package/src/Utils.ts +37 -8
- package/src/aes.ts +259 -222
- package/src/index.ts +10 -1
- package/src/keygen.ts +80 -0
- package/src/keys.ts +139 -30
- package/src/rsa.ts +161 -187
- package/src/sig.ts +7 -23
- package/src/subtle.ts +211 -93
- package/src/webcrypto.ts +8 -0
package/lib/typescript/aes.d.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { type BufferLike } from './Utils';
|
|
2
|
-
import { type ImportFormat, type SubtleAlgorithm, type KeyUsage, CryptoKey, type JWK } from './keys';
|
|
2
|
+
import { type ImportFormat, type SubtleAlgorithm, type KeyUsage, CryptoKey, type JWK, CipherOrWrapMode, type EncryptDecryptParams, type AesKeyGenParams } from './keys';
|
|
3
|
+
export declare enum AESKeyVariant {
|
|
4
|
+
AES_CTR_128 = 0,
|
|
5
|
+
AES_CTR_192 = 1,
|
|
6
|
+
AES_CTR_256 = 2,
|
|
7
|
+
AES_CBC_128 = 3,
|
|
8
|
+
AES_CBC_192 = 4,
|
|
9
|
+
AES_CBC_256 = 5,
|
|
10
|
+
AES_GCM_128 = 6,
|
|
11
|
+
AES_GCM_192 = 7,
|
|
12
|
+
AES_GCM_256 = 8,
|
|
13
|
+
AES_KW_128 = 9,
|
|
14
|
+
AES_KW_192 = 10,
|
|
15
|
+
AES_KW_256 = 11
|
|
16
|
+
}
|
|
17
|
+
export declare const kAesKeyLengths: number[];
|
|
3
18
|
export declare const getAlgorithmName: (name: string, length?: number) => string;
|
|
19
|
+
export declare const aesCipher: (mode: CipherOrWrapMode, key: CryptoKey, data: ArrayBuffer, algorithm: EncryptDecryptParams) => Promise<ArrayBuffer>;
|
|
20
|
+
export declare const aesGenerateKey: (algorithm: AesKeyGenParams, extractable: boolean, keyUsages: KeyUsage[]) => Promise<CryptoKey>;
|
|
4
21
|
export declare const aesImportKey: (algorithm: SubtleAlgorithm, format: ImportFormat, keyData: BufferLike | JWK, extractable: boolean, keyUsages: KeyUsage[]) => Promise<CryptoKey>;
|
|
5
22
|
//# sourceMappingURL=aes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aes.d.ts","sourceRoot":"","sources":["../../src/aes.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"aes.d.ts","sourceRoot":"","sources":["../../src/aes.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,UAAU,EAMhB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,SAAS,EAGT,KAAK,GAAG,EAER,gBAAgB,EAChB,KAAK,oBAAoB,EAMzB,KAAK,eAAe,EACrB,MAAM,QAAQ,CAAC;AAIhB,oBAAY,aAAa;IACvB,WAAW,IAAA;IACX,WAAW,IAAA;IACX,WAAW,IAAA;IACX,WAAW,IAAA;IACX,WAAW,IAAA;IACX,WAAW,IAAA;IACX,WAAW,IAAA;IACX,WAAW,IAAA;IACX,WAAW,IAAA;IACX,UAAU,IAAA;IACV,UAAU,KAAA;IACV,UAAU,KAAA;CACX;AAID,eAAO,MAAM,cAAc,UAAkB,CAAC;AAE9C,eAAO,MAAM,gBAAgB,SAAU,MAAM,WAAW,MAAM,WAkB7D,CAAC;AAiLF,eAAO,MAAM,SAAS,SACd,gBAAgB,OACjB,SAAS,QACR,WAAW,aACN,oBAAoB,KAC9B,OAAO,CAAC,WAAW,CAYrB,CAAC;AAEF,eAAO,MAAM,cAAc,cACd,eAAe,eACb,OAAO,aACT,QAAQ,EAAE,KACpB,OAAO,CAAC,SAAS,CAyCnB,CAAC;AAEF,eAAO,MAAM,YAAY,cACZ,eAAe,UAClB,YAAY,WACX,UAAU,GAAG,GAAG,eACZ,OAAO,aACT,QAAQ,EAAE,KACpB,OAAO,CAAC,SAAS,CAoFnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ec.d.ts","sourceRoot":"","sources":["../../src/ec.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,UAAU,EAQhB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,QAAQ,EAIb,mBAAmB,EACnB,SAAS,EACT,KAAK,GAAG,EAIR,KAAK,aAAa,EACnB,MAAM,QAAQ,CAAC;AA6FhB,wBAAgB,WAAW,CACzB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,mBAAmB,GAC1B,WAAW,CAEb;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,GAAG,EACtC,SAAS,EAAE,eAAe,EAC1B,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,QAAQ,EAAE,GACpB,SAAS,CAoIX;AAED,eAAO,MAAM,eAAe,QACrB,SAAS,QACR,UAAU,YACN,eAAe,cACb,UAAU,0BA2BvB,CAAC;AAEF,eAAO,MAAM,aAAa,cACb,eAAe,eACb,OAAO,aACT,QAAQ,EAAE,KACpB,
|
|
1
|
+
{"version":3,"file":"ec.d.ts","sourceRoot":"","sources":["../../src/ec.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,UAAU,EAQhB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,QAAQ,EAIb,mBAAmB,EACnB,SAAS,EACT,KAAK,GAAG,EAIR,KAAK,aAAa,EACnB,MAAM,QAAQ,CAAC;AA6FhB,wBAAgB,WAAW,CACzB,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,mBAAmB,GAC1B,WAAW,CAEb;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,GAAG,EACtC,SAAS,EAAE,eAAe,EAC1B,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,QAAQ,EAAE,GACpB,SAAS,CAoIX;AAED,eAAO,MAAM,eAAe,QACrB,SAAS,QACR,UAAU,YACN,eAAe,cACb,UAAU,0BA2BvB,CAAC;AAEF,eAAO,MAAM,aAAa,cACb,eAAe,eACb,OAAO,aACT,QAAQ,EAAE,KACpB,OAAO,CAAC,aAAa,CAoEvB,CAAC"}
|
|
@@ -4,18 +4,24 @@ import { createCipher, createCipheriv, createDecipher, createDecipheriv, generat
|
|
|
4
4
|
import { createSign, createVerify } from './sig';
|
|
5
5
|
import { createHmac } from './Hmac';
|
|
6
6
|
import { createHash } from './Hash';
|
|
7
|
+
import { createPublicKey, createSecretKey } from './keys';
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Loosely matches Node.js {crypto} with some unimplemented functionality
|
|
9
10
|
*/
|
|
10
11
|
declare const QuickCrypto: {
|
|
11
12
|
getCiphers: () => string[];
|
|
12
13
|
getHashes: () => string[];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
webcrypto: {
|
|
15
|
+
subtle: import("./subtle").Subtle;
|
|
16
|
+
SubtleCrypto: typeof import("./subtle").Subtle;
|
|
17
|
+
CryptoKey: typeof import("./keys").CryptoKey;
|
|
18
|
+
};
|
|
19
|
+
randomFill<T extends import("./Utils").TypedArray | Buffer | ArrayBufferLike | DataView>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
|
|
20
|
+
randomFill<T extends import("./Utils").TypedArray | Buffer | ArrayBufferLike | DataView>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
|
|
21
|
+
randomFill<T extends import("./Utils").TypedArray | Buffer | ArrayBufferLike | DataView>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
|
|
22
|
+
randomFillSync<T extends import("./Utils").TypedArray | Buffer | ArrayBufferLike | DataView>(buffer: T, offset?: number, size?: number): T;
|
|
17
23
|
randomBytes(size: number): Buffer;
|
|
18
|
-
randomBytes(size: number, callback: (err: Error | null, buf?: Buffer
|
|
24
|
+
randomBytes(size: number, callback: (err: Error | null, buf?: Buffer) => void): void;
|
|
19
25
|
randomInt(max: number, callback: (err: Error | null, value: number) => void): void;
|
|
20
26
|
randomInt(max: number): number;
|
|
21
27
|
randomInt(min: number, max: number, callback: (err: Error | null, value: number) => void): void;
|
|
@@ -25,9 +31,9 @@ declare const QuickCrypto: {
|
|
|
25
31
|
rng: typeof random.randomBytes;
|
|
26
32
|
pseudoRandomBytes: typeof random.randomBytes;
|
|
27
33
|
prng: typeof random.randomBytes;
|
|
28
|
-
pbkdf2(password: import("./Utils").BinaryLike, salt: import("./Utils").BinaryLike, iterations: number, keylen: number, digest: import("./keys").HashAlgorithm, callback: (err: Error | null, derivedKey?: Buffer
|
|
29
|
-
pbkdf2(password: import("./Utils").BinaryLike, salt: import("./Utils").BinaryLike, iterations: number, keylen: number, callback: (err: Error | null, derivedKey?: Buffer
|
|
30
|
-
pbkdf2Sync(password: import("./Utils").BinaryLike, salt: import("./Utils").BinaryLike, iterations: number, keylen: number, digest?: import("./keys").HashAlgorithm
|
|
34
|
+
pbkdf2(password: import("./Utils").BinaryLike, salt: import("./Utils").BinaryLike, iterations: number, keylen: number, digest: import("./keys").HashAlgorithm, callback: (err: Error | null, derivedKey?: Buffer) => void): void;
|
|
35
|
+
pbkdf2(password: import("./Utils").BinaryLike, salt: import("./Utils").BinaryLike, iterations: number, keylen: number, callback: (err: Error | null, derivedKey?: Buffer) => void): void;
|
|
36
|
+
pbkdf2Sync(password: import("./Utils").BinaryLike, salt: import("./Utils").BinaryLike, iterations: number, keylen: number, digest?: import("./keys").HashAlgorithm): ArrayBuffer;
|
|
31
37
|
pbkdf2DeriveBits(algorithm: import("./keys").SubtleAlgorithm, baseKey: import("./keys").CryptoKey, length: number): Promise<ArrayBuffer>;
|
|
32
38
|
createHmac: typeof createHmac;
|
|
33
39
|
Hmac: typeof createHmac;
|
|
@@ -37,46 +43,43 @@ declare const QuickCrypto: {
|
|
|
37
43
|
createCipheriv: typeof createCipheriv;
|
|
38
44
|
createDecipher: typeof createDecipher;
|
|
39
45
|
createDecipheriv: typeof createDecipheriv;
|
|
46
|
+
createPublicKey: typeof createPublicKey;
|
|
47
|
+
createPrivateKey: (key: import("./Utils").BinaryLike | import("./keys").EncodingOptions) => import("./keys").PrivateKeyObject;
|
|
48
|
+
createSecretKey: typeof createSecretKey;
|
|
40
49
|
publicEncrypt: (options: {
|
|
41
50
|
key: any;
|
|
42
|
-
encoding?: string
|
|
51
|
+
encoding?: string;
|
|
43
52
|
format?: any;
|
|
44
53
|
padding?: any;
|
|
45
54
|
oaepHash?: any;
|
|
46
55
|
oaepLabel?: any;
|
|
47
|
-
passphrase?: string
|
|
56
|
+
passphrase?: string;
|
|
48
57
|
}, buffer: import("./Utils").BinaryLike) => Buffer;
|
|
49
58
|
publicDecrypt: (options: {
|
|
50
59
|
key: any;
|
|
51
|
-
encoding?: string
|
|
60
|
+
encoding?: string;
|
|
52
61
|
format?: any;
|
|
53
62
|
padding?: any;
|
|
54
63
|
oaepHash?: any;
|
|
55
64
|
oaepLabel?: any;
|
|
56
|
-
passphrase?: string
|
|
65
|
+
passphrase?: string;
|
|
57
66
|
}, buffer: import("./Utils").BinaryLike) => Buffer;
|
|
58
67
|
privateDecrypt: (options: {
|
|
59
68
|
key: any;
|
|
60
|
-
encoding?: string
|
|
69
|
+
encoding?: string;
|
|
61
70
|
format?: any;
|
|
62
71
|
padding?: any;
|
|
63
72
|
oaepHash?: any;
|
|
64
73
|
oaepLabel?: any;
|
|
65
|
-
passphrase?: string
|
|
74
|
+
passphrase?: string;
|
|
66
75
|
}, buffer: import("./Utils").BinaryLike) => Buffer;
|
|
76
|
+
generateKey: (type: import("./keys").SecretKeyType, options: import("./keys").AesKeyGenParams, callback: import("./keygen").KeyGenCallback) => void;
|
|
67
77
|
generateKeyPair: (type: import("./keys").KeyPairType, options: import("./Cipher").GenerateKeyPairOptions, callback: import("./Cipher").GenerateKeyPairCallback) => void;
|
|
68
78
|
generateKeyPairSync: typeof generateKeyPairSync;
|
|
79
|
+
generateKeySync: (type: import("./keys").SecretKeyType, options: import("./keys").AesKeyGenParams) => import("./keys").SecretKeyObject;
|
|
69
80
|
createSign: typeof createSign;
|
|
70
81
|
createVerify: typeof createVerify;
|
|
71
|
-
subtle:
|
|
72
|
-
digest(algorithm: import("./keys").AnyAlgorithm | import("./keys").SubtleAlgorithm, data: import("./Utils").BufferLike): Promise<ArrayBuffer>;
|
|
73
|
-
deriveBits(algorithm: import("./keys").SubtleAlgorithm, baseKey: import("./keys").CryptoKey, length: number): Promise<ArrayBuffer>;
|
|
74
|
-
importKey(format: import("./keys").ImportFormat, data: string | ArrayBuffer | Uint8Array | import("./keys").JWK | Buffer | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array | ArrayBufferView, algorithm: import("./keys").AnyAlgorithm | import("./keys").SubtleAlgorithm, extractable: boolean, keyUsages: import("./keys").KeyUsage[]): Promise<import("./keys").CryptoKey>;
|
|
75
|
-
exportKey(format: import("./keys").ImportFormat, key: import("./keys").CryptoKey): Promise<any>;
|
|
76
|
-
generateKey(algorithm: import("./keys").SubtleAlgorithm, extractable: boolean, keyUsages: import("./keys").KeyUsage[]): Promise<import("./keys").CryptoKey | import("./keys").CryptoKeyPair>;
|
|
77
|
-
sign(algorithm: import("./keys").SubtleAlgorithm, key: import("./keys").CryptoKey, data: import("./Utils").BufferLike): Promise<ArrayBuffer>;
|
|
78
|
-
verify(algorithm: import("./keys").SubtleAlgorithm, key: import("./keys").CryptoKey, signature: import("./Utils").BufferLike, data: import("./Utils").BufferLike): Promise<ArrayBuffer>;
|
|
79
|
-
};
|
|
82
|
+
subtle: import("./subtle").Subtle;
|
|
80
83
|
constants: {
|
|
81
84
|
OPENSSL_VERSION_NUMBER: number;
|
|
82
85
|
SSL_OP_ALL: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAKhB,mBAAmB,EACpB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAKhB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAKpC,OAAO,EAAoB,eAAe,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE5E;;GAEG;AACH,QAAA,MAAM,WAAW;;;;;;;;;;;;;+DA+CmK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAAk/O,CAAC;cAAsB,CAAC;eAAoB,CAAC;gBAAqB,CAAC;iBAAsB,CAAC;kBAAuB,CAAC;;;;gBAAlH,CAAC;cAAsB,CAAC;eAAoB,CAAC;gBAAqB,CAAC;iBAAsB,CAAC;kBAAuB,CAAC;;;;gBAAlH,CAAC;cAAsB,CAAC;eAAoB,CAAC;gBAAqB,CAAC;iBAAsB,CAAC;kBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAnBxxP,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,YAMnB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SecretKeyObject, type SecretKeyType, type AesKeyGenParams } from './keys';
|
|
2
|
+
export type KeyGenCallback = (err: Error | undefined, key?: SecretKeyObject) => void;
|
|
3
|
+
export declare const generateKeyPromise: (type: SecretKeyType, options: AesKeyGenParams) => Promise<[Error | undefined, SecretKeyObject | undefined]>;
|
|
4
|
+
export declare const generateKey: (type: SecretKeyType, options: AesKeyGenParams, callback: KeyGenCallback) => void;
|
|
5
|
+
export declare const generateKeySync: (type: SecretKeyType, options: AesKeyGenParams) => SecretKeyObject;
|
|
6
|
+
//# sourceMappingURL=keygen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keygen.d.ts","sourceRoot":"","sources":["../../src/keygen.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,QAAQ,CAAC;AAEhB,MAAM,MAAM,cAAc,GAAG,CAC3B,GAAG,EAAE,KAAK,GAAG,SAAS,EACtB,GAAG,CAAC,EAAE,eAAe,KAClB,IAAI,CAAC;AAEV,eAAO,MAAM,kBAAkB,SACvB,aAAa,WACV,eAAe,KACvB,OAAO,CAAC,CAAC,KAAK,GAAG,SAAS,EAAE,eAAe,GAAG,SAAS,CAAC,CAS1D,CAAC;AAEF,eAAO,MAAM,WAAW,SAChB,aAAa,WACV,eAAe,YACd,cAAc,KACvB,IAaF,CAAC;AAEF,eAAO,MAAM,eAAe,SACpB,aAAa,WACV,eAAe,KACvB,eAMF,CAAC"}
|
package/lib/typescript/keys.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BinaryLike } from './Utils';
|
|
1
|
+
import { type BinaryLike, type BufferLike, type TypedArray } from './Utils';
|
|
2
2
|
import type { KeyObjectHandle } from './NativeQuickCrypto/webcrypto';
|
|
3
3
|
import type { KeyPairKey } from './Cipher';
|
|
4
4
|
export declare const kNamedCurveAliases: {
|
|
@@ -9,15 +9,48 @@ export declare const kNamedCurveAliases: {
|
|
|
9
9
|
export type NamedCurve = 'P-256' | 'P-384' | 'P-521';
|
|
10
10
|
export type ImportFormat = 'raw' | 'pkcs8' | 'spki' | 'jwk';
|
|
11
11
|
export type AnyAlgorithm = HashAlgorithm | KeyPairAlgorithm | SecretKeyAlgorithm | SignVerifyAlgorithm | DeriveBitsAlgorithm | EncryptDecryptAlgorithm | 'PBKDF2' | 'HKDF';
|
|
12
|
-
export type HashAlgorithm = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
12
|
+
export type HashAlgorithm = 'SHA-1' | 'SHA-224' | 'SHA-256' | 'SHA-384' | 'SHA-512' | 'RIPEMD-160';
|
|
13
|
+
export type DigestAlgorithm = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
13
14
|
export type KeyPairType = 'rsa' | 'rsa-pss' | 'ec';
|
|
14
15
|
export type RSAKeyPairAlgorithm = 'RSASSA-PKCS1-v1_5' | 'RSA-PSS' | 'RSA-OAEP';
|
|
15
16
|
export type ECKeyPairAlgorithm = 'ECDSA' | 'ECDH';
|
|
16
17
|
export type CFRGKeyPairAlgorithm = 'Ed25519' | 'Ed448' | 'X25519' | 'X448';
|
|
18
|
+
export type AESAlgorithm = 'AES-CTR' | 'AES-CBC' | 'AES-GCM' | 'AES-KW';
|
|
17
19
|
export type KeyPairAlgorithm = RSAKeyPairAlgorithm | ECKeyPairAlgorithm | CFRGKeyPairAlgorithm;
|
|
18
|
-
export type SecretKeyAlgorithm = 'HMAC' |
|
|
20
|
+
export type SecretKeyAlgorithm = 'HMAC' | AESAlgorithm;
|
|
21
|
+
export type SecretKeyType = 'hmac' | 'aes';
|
|
19
22
|
export type SignVerifyAlgorithm = 'RSASSA-PKCS1-v1_5' | 'RSA-PSS' | 'ECDSA' | 'HMAC' | 'Ed25519' | 'Ed448';
|
|
20
23
|
export type DeriveBitsAlgorithm = 'PBKDF2' | 'HKDF' | 'ECDH' | 'X25519' | 'X448';
|
|
24
|
+
export type RsaOaepParams = {
|
|
25
|
+
name: 'RSA-OAEP';
|
|
26
|
+
label?: BufferLike;
|
|
27
|
+
};
|
|
28
|
+
export type AesCbcParams = {
|
|
29
|
+
name: 'AES-CBC';
|
|
30
|
+
iv: BufferLike;
|
|
31
|
+
};
|
|
32
|
+
export type AesCtrParams = {
|
|
33
|
+
name: 'AES-CTR';
|
|
34
|
+
counter: TypedArray;
|
|
35
|
+
length: number;
|
|
36
|
+
};
|
|
37
|
+
export type AesGcmParams = {
|
|
38
|
+
name: 'AES-GCM';
|
|
39
|
+
iv: BufferLike;
|
|
40
|
+
tagLength?: TagLength;
|
|
41
|
+
additionalData?: BufferLike;
|
|
42
|
+
};
|
|
43
|
+
export type AesKwParams = {
|
|
44
|
+
name: 'AES-KW';
|
|
45
|
+
wrappingKey?: BufferLike;
|
|
46
|
+
};
|
|
47
|
+
export type AesKeyGenParams = {
|
|
48
|
+
length: AESLength;
|
|
49
|
+
name?: AESAlgorithm;
|
|
50
|
+
};
|
|
51
|
+
export type TagLength = 32 | 64 | 96 | 104 | 112 | 120 | 128;
|
|
52
|
+
export type AESLength = 128 | 192 | 256;
|
|
53
|
+
export type EncryptDecryptParams = AesCbcParams | AesCtrParams | AesGcmParams | RsaOaepParams;
|
|
21
54
|
export type EncryptDecryptAlgorithm = 'RSA-OAEP' | 'AES-CTR' | 'AES-CBC' | 'AES-GCM';
|
|
22
55
|
export type SubtleAlgorithm = {
|
|
23
56
|
name: AnyAlgorithm;
|
|
@@ -35,11 +68,15 @@ export declare enum KFormatType {
|
|
|
35
68
|
kKeyFormatPEM = 1,
|
|
36
69
|
kKeyFormatJWK = 2
|
|
37
70
|
}
|
|
71
|
+
export type KFormat = 'der' | 'pem' | 'jwk';
|
|
38
72
|
export declare enum KeyType {
|
|
39
73
|
Secret = 0,
|
|
40
74
|
Public = 1,
|
|
41
75
|
Private = 2
|
|
42
76
|
}
|
|
77
|
+
export type KTypePrivate = 'pkcs1' | 'pkcs8' | 'sec1';
|
|
78
|
+
export type KTypePublic = 'pkcs1' | 'spki';
|
|
79
|
+
export type KType = KTypePrivate | KTypePublic;
|
|
43
80
|
export declare enum KWebCryptoKeyFormat {
|
|
44
81
|
kWebCryptoKeyFormatRaw = 0,
|
|
45
82
|
kWebCryptoKeyFormatPKCS8 = 1,
|
|
@@ -58,10 +95,10 @@ export declare enum KeyEncoding {
|
|
|
58
95
|
kKeyEncodingSEC1 = 3
|
|
59
96
|
}
|
|
60
97
|
export type EncodingOptions = {
|
|
61
|
-
key
|
|
62
|
-
type?:
|
|
98
|
+
key?: any;
|
|
99
|
+
type?: KType;
|
|
63
100
|
encoding?: string;
|
|
64
|
-
format?:
|
|
101
|
+
format?: KFormat;
|
|
65
102
|
padding?: number;
|
|
66
103
|
cipher?: string;
|
|
67
104
|
passphrase?: string | ArrayBuffer;
|
|
@@ -95,22 +132,21 @@ export type CryptoKeyPair = {
|
|
|
95
132
|
publicKey: KeyPairKey;
|
|
96
133
|
privateKey: KeyPairKey;
|
|
97
134
|
};
|
|
135
|
+
export declare enum CipherOrWrapMode {
|
|
136
|
+
kWebCryptoCipherEncrypt = 0,
|
|
137
|
+
kWebCryptoCipherDecrypt = 1
|
|
138
|
+
}
|
|
98
139
|
export declare function preparePrivateKey(key: BinaryLike | EncodingOptions): {
|
|
99
140
|
format: KFormatType;
|
|
100
141
|
data: ArrayBuffer;
|
|
101
|
-
type?: KeyEncoding
|
|
102
|
-
passphrase?: string | ArrayBuffer
|
|
142
|
+
type?: KeyEncoding;
|
|
143
|
+
passphrase?: string | ArrayBuffer;
|
|
103
144
|
};
|
|
104
|
-
export declare function preparePublicOrPrivateKey(key: BinaryLike | {
|
|
105
|
-
key: any;
|
|
106
|
-
encoding?: string;
|
|
107
|
-
format?: any;
|
|
108
|
-
padding?: number;
|
|
109
|
-
}): {
|
|
145
|
+
export declare function preparePublicOrPrivateKey(key: BinaryLike | EncodingOptions): {
|
|
110
146
|
format: KFormatType;
|
|
111
147
|
data: ArrayBuffer;
|
|
112
|
-
type?: KeyEncoding
|
|
113
|
-
passphrase?: string | ArrayBuffer
|
|
148
|
+
type?: KeyEncoding;
|
|
149
|
+
passphrase?: string | ArrayBuffer;
|
|
114
150
|
};
|
|
115
151
|
export declare function parsePublicKeyEncoding(enc: EncodingOptions, keyType: string | undefined, objName?: string): {
|
|
116
152
|
format: KFormatType;
|
|
@@ -125,6 +161,8 @@ export declare function parsePrivateKeyEncoding(enc: EncodingOptions, keyType: s
|
|
|
125
161
|
passphrase: ArrayBuffer | undefined;
|
|
126
162
|
};
|
|
127
163
|
export declare function createSecretKey(key: any, encoding?: string): SecretKeyObject;
|
|
164
|
+
export declare function createPublicKey(key: BinaryLike | EncodingOptions): PublicKeyObject;
|
|
165
|
+
export declare const createPrivateKey: (key: BinaryLike | EncodingOptions) => PrivateKeyObject;
|
|
128
166
|
export declare class CryptoKey {
|
|
129
167
|
keyObject: KeyObject;
|
|
130
168
|
keyAlgorithm: SubtleAlgorithm;
|
|
@@ -145,7 +183,7 @@ declare class KeyObject {
|
|
|
145
183
|
}
|
|
146
184
|
export declare class SecretKeyObject extends KeyObject {
|
|
147
185
|
constructor(handle: KeyObjectHandle);
|
|
148
|
-
export(options
|
|
186
|
+
export(options?: EncodingOptions): ArrayBuffer;
|
|
149
187
|
}
|
|
150
188
|
declare class AsymmetricKeyObject extends KeyObject {
|
|
151
189
|
constructor(type: string, handle: KeyObjectHandle);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAGf,KAAK,UAAU,EACf,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAE5D,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,gBAAgB,GAChB,kBAAkB,GAClB,mBAAmB,GACnB,mBAAmB,GACnB,uBAAuB,GACvB,QAAQ,GACR,MAAM,CAAC;AAEX,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,YAAY,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAE1E,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,GAAG,SAAS,GAAG,UAAU,CAAC;AAC/E,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,CAAC;AAClD,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,Y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import { CryptoKey, type ImportFormat, type JWK, type KeyUsage, type SubtleAlgorithm } from './keys';
|
|
2
|
+
import { CryptoKey, type ImportFormat, type JWK, type KeyUsage, type SubtleAlgorithm, type CryptoKeyPair, KWebCryptoKeyFormat, CipherOrWrapMode, type RsaOaepParams } from './keys';
|
|
3
|
+
export declare enum RSAKeyVariant {
|
|
4
|
+
RSA_SSA_PKCS1_v1_5 = 0,
|
|
5
|
+
RSA_PSS = 1,
|
|
6
|
+
RSA_OAEP = 2
|
|
7
|
+
}
|
|
8
|
+
export declare const rsaCipher: (mode: CipherOrWrapMode, key: CryptoKey, data: ArrayBuffer, { label }: RsaOaepParams) => Promise<ArrayBuffer>;
|
|
9
|
+
export declare const rsaKeyGenerate: (algorithm: SubtleAlgorithm, extractable: boolean, keyUsages: KeyUsage[]) => Promise<CryptoKeyPair>;
|
|
10
|
+
export declare const rsaExportKey: (key: CryptoKey, format: KWebCryptoKeyFormat) => ArrayBuffer;
|
|
3
11
|
export declare const rsaImportKey: (format: ImportFormat, keyData: BufferLike | JWK, algorithm: SubtleAlgorithm, extractable: boolean, keyUsages: KeyUsage[]) => CryptoKey;
|
|
4
12
|
//# sourceMappingURL=rsa.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsa.d.ts","sourceRoot":"","sources":["../../src/rsa.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rsa.d.ts","sourceRoot":"","sources":["../../src/rsa.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,UAAU,EAShB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,SAAS,EAGT,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,QAAQ,EACb,KAAK,eAAe,EAKpB,KAAK,aAAa,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,aAAa,EAEnB,MAAM,QAAQ,CAAC;AAGhB,oBAAY,aAAa;IACvB,kBAAkB,IAAA;IAClB,OAAO,IAAA;IACP,QAAQ,IAAA;CACT;AA2DD,eAAO,MAAM,SAAS,SA3Bd,gBAAgB,OACjB,SAAS,QACR,WAAW,aACN,aAAa,KACvB,OAAO,CAAC,WAAW,CAuBgB,CAAC;AAEvC,eAAO,MAAM,cAAc,cACd,eAAe,eACb,OAAO,aACT,QAAQ,EAAE,KACpB,OAAO,CAAC,aAAa,CA8EvB,CAAC;AAEF,eAAO,MAAM,YAAY,QAClB,SAAS,UACN,mBAAmB,KAC1B,WAaF,CAAC;AAEF,eAAO,MAAM,YAAY,WACf,YAAY,WACX,UAAU,GAAG,GAAG,aACd,eAAe,eACb,OAAO,aACT,QAAQ,EAAE,KACpB,SAyHF,CAAC"}
|
package/lib/typescript/sig.d.ts
CHANGED
|
@@ -1,33 +1,19 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import Stream from 'readable-stream';
|
|
3
2
|
import { type BinaryLike } from './Utils';
|
|
3
|
+
import { type EncodingOptions } from './keys';
|
|
4
4
|
declare class Verify extends Stream.Writable {
|
|
5
5
|
private internal;
|
|
6
6
|
constructor(algorithm: string, options: Stream.WritableOptions);
|
|
7
7
|
_write(chunk: BinaryLike, encoding: string, callback: () => void): void;
|
|
8
8
|
update(data: BinaryLike, encoding?: string): this;
|
|
9
|
-
verify(options:
|
|
10
|
-
key: string | Buffer;
|
|
11
|
-
format?: string;
|
|
12
|
-
type?: string;
|
|
13
|
-
passphrase?: string;
|
|
14
|
-
padding?: number;
|
|
15
|
-
saltLength?: number;
|
|
16
|
-
}, signature: BinaryLike): boolean;
|
|
9
|
+
verify(options: EncodingOptions, signature: BinaryLike): boolean;
|
|
17
10
|
}
|
|
18
11
|
declare class Sign extends Stream.Writable {
|
|
19
12
|
private internal;
|
|
20
13
|
constructor(algorithm: string, options: Stream.WritableOptions);
|
|
21
14
|
_write(chunk: BinaryLike, encoding: string, callback: () => void): void;
|
|
22
15
|
update(data: BinaryLike, encoding?: string): this;
|
|
23
|
-
sign(options:
|
|
24
|
-
key: string | Buffer;
|
|
25
|
-
format?: string;
|
|
26
|
-
type?: string;
|
|
27
|
-
passphrase?: string;
|
|
28
|
-
padding?: number;
|
|
29
|
-
saltLength?: number;
|
|
30
|
-
}, encoding?: string): string | Buffer;
|
|
16
|
+
sign(options: EncodingOptions, encoding?: string): string | Buffer;
|
|
31
17
|
}
|
|
32
18
|
export declare function createSign(algorithm: string, options?: any): Sign;
|
|
33
19
|
export declare function createVerify(algorithm: string, options?: any): Verify;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sig.d.ts","sourceRoot":"","sources":["../../src/sig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sig.d.ts","sourceRoot":"","sources":["../../src/sig.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AASrC,OAAO,EACL,KAAK,UAAU,EAGhB,MAAM,SAAS,CAAC;AACjB,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,QAAQ,CAAC;AAoChB,cAAM,MAAO,SAAQ,MAAM,CAAC,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAiB;gBACrB,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,eAAe;IAM9D,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI;IAKhE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM;IAO1C,MAAM,CAAC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO;CA2BjE;AAED,cAAM,IAAK,SAAQ,MAAM,CAAC,QAAQ;IAChC,OAAO,CAAC,QAAQ,CAAe;gBACnB,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,eAAe;IAM9D,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI;IAKhE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM;IAO1C,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,MAAM;CA8BjD;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,QAE1D;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,UAE5D"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { type ImportFormat, type SubtleAlgorithm, type KeyUsage, CryptoKey, type AnyAlgorithm, type JWK, type CryptoKeyPair } from './keys';
|
|
1
|
+
import { type ImportFormat, type SubtleAlgorithm, type KeyUsage, CryptoKey, type AnyAlgorithm, type JWK, type CryptoKeyPair, type EncryptDecryptParams } from './keys';
|
|
2
2
|
import { type BufferLike, type BinaryLike } from './Utils';
|
|
3
|
-
declare class Subtle {
|
|
3
|
+
export declare class Subtle {
|
|
4
|
+
decrypt(algorithm: EncryptDecryptParams, key: CryptoKey, data: BufferLike): Promise<ArrayBuffer>;
|
|
4
5
|
digest(algorithm: SubtleAlgorithm | AnyAlgorithm, data: BufferLike): Promise<ArrayBuffer>;
|
|
5
6
|
deriveBits(algorithm: SubtleAlgorithm, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
|
|
6
|
-
|
|
7
|
-
exportKey(format: ImportFormat, key: CryptoKey): Promise<ArrayBuffer |
|
|
7
|
+
encrypt(algorithm: EncryptDecryptParams, key: CryptoKey, data: BufferLike): Promise<ArrayBuffer>;
|
|
8
|
+
exportKey(format: ImportFormat, key: CryptoKey): Promise<ArrayBuffer | JWK>;
|
|
8
9
|
generateKey(algorithm: SubtleAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey | CryptoKeyPair>;
|
|
10
|
+
importKey(format: ImportFormat, data: BufferLike | BinaryLike | JWK, algorithm: SubtleAlgorithm | AnyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
|
|
9
11
|
sign(algorithm: SubtleAlgorithm, key: CryptoKey, data: BufferLike): Promise<ArrayBuffer>;
|
|
10
12
|
verify(algorithm: SubtleAlgorithm, key: CryptoKey, signature: BufferLike, data: BufferLike): Promise<ArrayBuffer>;
|
|
11
13
|
}
|
|
12
14
|
export declare const subtle: Subtle;
|
|
13
|
-
export {};
|
|
14
15
|
//# sourceMappingURL=subtle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subtle.d.ts","sourceRoot":"","sources":["../../src/subtle.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,SAAS,EAGT,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"subtle.d.ts","sourceRoot":"","sources":["../../src/subtle.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,SAAS,EAGT,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,aAAa,EAElB,KAAK,oBAAoB,EAE1B,MAAM,QAAQ,CAAC;AAChB,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,UAAU,EAQhB,MAAM,SAAS,CAAC;AA8VjB,qBAAa,MAAM;IACX,OAAO,CACX,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,WAAW,CAAC;IAWjB,MAAM,CACV,SAAS,EAAE,eAAe,GAAG,YAAY,EACzC,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,WAAW,CAAC;IAKjB,UAAU,CACd,SAAS,EAAE,eAAe,EAC1B,OAAO,EAAE,SAAS,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,CAAC;IAyBjB,OAAO,CACX,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,WAAW,CAAC;IAWjB,SAAS,CACb,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,GACb,OAAO,CAAC,WAAW,GAAG,GAAG,CAAC;IAevB,WAAW,CACf,SAAS,EAAE,eAAe,EAC1B,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,SAAS,GAAG,aAAa,CAAC;IAqD/B,SAAS,CACb,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,GAAG,EACnC,SAAS,EAAE,eAAe,GAAG,YAAY,EACzC,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,QAAQ,EAAE,GACpB,OAAO,CAAC,SAAS,CAAC;IAgGf,IAAI,CACR,SAAS,EAAE,eAAe,EAC1B,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,WAAW,CAAC;IAIjB,MAAM,CACV,SAAS,EAAE,eAAe,EAC1B,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,WAAW,CAAC;CAGxB;AAED,eAAO,MAAM,MAAM,QAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webcrypto.d.ts","sourceRoot":"","sources":["../../src/webcrypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;;;;;;AAEnC,wBAIE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-quick-crypto",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "A fast implementation of Node's `crypto` module written in C/C++ JSI",
|
|
5
5
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"prettier": "^3.2.5",
|
|
77
77
|
"react": "^18.2.0",
|
|
78
78
|
"react-native": "^0.72.7",
|
|
79
|
-
"react-native-builder-bob": "^0.
|
|
79
|
+
"react-native-builder-bob": "^0.24.0",
|
|
80
80
|
"release-it": "^17.2.0",
|
|
81
81
|
"sscrypto": "^1.1.1",
|
|
82
82
|
"typescript": "^5.1.6"
|
package/src/Cipher.ts
CHANGED
|
@@ -562,7 +562,7 @@ function internalGenerateKeyPair(
|
|
|
562
562
|
if (type === 'rsa') {
|
|
563
563
|
if (isAsync) {
|
|
564
564
|
NativeQuickCrypto.generateKeyPair(
|
|
565
|
-
KeyVariant.RSA_SSA_PKCS1_v1_5,
|
|
565
|
+
KeyVariant.RSA_SSA_PKCS1_v1_5, // Used also for RSA-OAEP
|
|
566
566
|
modulusLength as number,
|
|
567
567
|
publicExponent,
|
|
568
568
|
...encoding
|
package/src/Hashnames.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
HashAlgorithm,
|
|
3
|
-
KeyPairAlgorithm,
|
|
4
|
-
SecretKeyAlgorithm,
|
|
5
|
-
SubtleAlgorithm,
|
|
6
|
-
} from './keys';
|
|
1
|
+
import type { HashAlgorithm } from './keys';
|
|
7
2
|
|
|
8
3
|
export enum HashContext {
|
|
9
4
|
Node,
|
|
@@ -32,6 +27,14 @@ const kHashNames: HashNames = {
|
|
|
32
27
|
[HashContext.JwkRsaOaep]: 'RSA-OAEP',
|
|
33
28
|
[HashContext.JwkHmac]: 'HS1',
|
|
34
29
|
},
|
|
30
|
+
sha224: {
|
|
31
|
+
[HashContext.Node]: 'sha224',
|
|
32
|
+
[HashContext.WebCrypto]: 'SHA-224',
|
|
33
|
+
[HashContext.JwkRsa]: 'RS224',
|
|
34
|
+
[HashContext.JwkRsaPss]: 'PS224',
|
|
35
|
+
[HashContext.JwkRsaOaep]: 'RSA-OAEP-224',
|
|
36
|
+
[HashContext.JwkHmac]: 'HS224',
|
|
37
|
+
},
|
|
35
38
|
sha256: {
|
|
36
39
|
[HashContext.Node]: 'sha256',
|
|
37
40
|
[HashContext.WebCrypto]: 'SHA-256',
|
|
@@ -56,6 +59,10 @@ const kHashNames: HashNames = {
|
|
|
56
59
|
[HashContext.JwkRsaOaep]: 'RSA-OAEP-512',
|
|
57
60
|
[HashContext.JwkHmac]: 'HS512',
|
|
58
61
|
},
|
|
62
|
+
ripemd160: {
|
|
63
|
+
[HashContext.Node]: 'ripemd160',
|
|
64
|
+
[HashContext.WebCrypto]: 'RIPEMD-160',
|
|
65
|
+
},
|
|
59
66
|
};
|
|
60
67
|
|
|
61
68
|
{
|
|
@@ -72,20 +79,15 @@ const kHashNames: HashNames = {
|
|
|
72
79
|
}
|
|
73
80
|
|
|
74
81
|
export function normalizeHashName(
|
|
75
|
-
algo:
|
|
76
|
-
| SubtleAlgorithm
|
|
77
|
-
| HashAlgorithm
|
|
78
|
-
| KeyPairAlgorithm
|
|
79
|
-
| SecretKeyAlgorithm
|
|
80
|
-
| undefined,
|
|
82
|
+
algo: string | HashAlgorithm | undefined,
|
|
81
83
|
context: HashContext = HashContext.Node
|
|
82
|
-
):
|
|
83
|
-
if (typeof algo
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
84
|
+
): HashAlgorithm {
|
|
85
|
+
if (typeof algo !== 'undefined') {
|
|
86
|
+
const normAlgo = algo.toString().toLowerCase();
|
|
87
|
+
try {
|
|
88
|
+
const alias = kHashNames[normAlgo]![context] as HashAlgorithm;
|
|
89
|
+
if (alias) return alias;
|
|
90
|
+
} catch (_e) {}
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Invalid Hash Algorithm: ${algo}`);
|
|
91
93
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { GenerateKeyPairReturn } from '../Cipher';
|
|
2
2
|
import type { BinaryLike } from '../Utils';
|
|
3
3
|
import type { Buffer } from '@craftzdog/react-native-buffer';
|
|
4
|
+
import type {
|
|
5
|
+
EncodingOptions,
|
|
6
|
+
PrivateKeyObject,
|
|
7
|
+
PublicKeyObject,
|
|
8
|
+
SecretKeyObject,
|
|
9
|
+
} from '../keys';
|
|
4
10
|
|
|
5
11
|
// TODO: until shared, keep in sync with C++ side (cpp/Utils/MGLUtils.h)
|
|
6
12
|
export enum KeyVariant {
|
|
@@ -13,6 +19,19 @@ export enum KeyVariant {
|
|
|
13
19
|
DH,
|
|
14
20
|
}
|
|
15
21
|
|
|
22
|
+
export const KeyVariantLookup: Record<string, KeyVariant> = {
|
|
23
|
+
'RSASSA-PKCS1-v1_5': KeyVariant.RSA_SSA_PKCS1_v1_5,
|
|
24
|
+
'RSA-PSS': KeyVariant.RSA_PSS,
|
|
25
|
+
'RSA-OAEP': KeyVariant.RSA_OAEP,
|
|
26
|
+
'ECDSA': KeyVariant.DSA,
|
|
27
|
+
'ECDH': KeyVariant.EC,
|
|
28
|
+
'Ed25519': KeyVariant.NID,
|
|
29
|
+
'Ed448': KeyVariant.NID,
|
|
30
|
+
'X25519': KeyVariant.NID,
|
|
31
|
+
'X448': KeyVariant.NID,
|
|
32
|
+
'DH': KeyVariant.DH,
|
|
33
|
+
};
|
|
34
|
+
|
|
16
35
|
export type InternalCipher = {
|
|
17
36
|
update: (data: BinaryLike | ArrayBufferView) => ArrayBuffer;
|
|
18
37
|
final: () => ArrayBuffer;
|
|
@@ -68,3 +87,16 @@ export type GenerateKeyPairSyncMethod = (
|
|
|
68
87
|
keyVariant: KeyVariant,
|
|
69
88
|
...rest: any[]
|
|
70
89
|
) => GenerateKeyPairReturn;
|
|
90
|
+
|
|
91
|
+
export type CreatePublicKeyMethod = (
|
|
92
|
+
key: BinaryLike | EncodingOptions
|
|
93
|
+
) => PublicKeyObject;
|
|
94
|
+
|
|
95
|
+
export type CreatePrivateKeyMethod = (
|
|
96
|
+
key: BinaryLike | EncodingOptions
|
|
97
|
+
) => PrivateKeyObject;
|
|
98
|
+
|
|
99
|
+
export type CreateSecretKeyMethod = (
|
|
100
|
+
key: BinaryLike | EncodingOptions,
|
|
101
|
+
encoding?: string
|
|
102
|
+
) => SecretKeyObject;
|
|
@@ -10,6 +10,9 @@ import type {
|
|
|
10
10
|
PrivateDecryptMethod,
|
|
11
11
|
GenerateKeyPairMethod,
|
|
12
12
|
GenerateKeyPairSyncMethod,
|
|
13
|
+
CreatePublicKeyMethod,
|
|
14
|
+
CreatePrivateKeyMethod,
|
|
15
|
+
CreateSecretKeyMethod,
|
|
13
16
|
} from './Cipher';
|
|
14
17
|
import type { CreateSignMethod, CreateVerifyMethod } from './sig';
|
|
15
18
|
import type { webcrypto } from './webcrypto';
|
|
@@ -21,6 +24,9 @@ interface NativeQuickCryptoSpec {
|
|
|
21
24
|
createHash: CreateHashMethod;
|
|
22
25
|
createCipher: CreateCipherMethod;
|
|
23
26
|
createDecipher: CreateDecipherMethod;
|
|
27
|
+
createPublicKey: CreatePublicKeyMethod;
|
|
28
|
+
createPrivateKey: CreatePrivateKeyMethod;
|
|
29
|
+
createSecretKey: CreateSecretKeyMethod;
|
|
24
30
|
publicEncrypt: PublicEncryptMethod;
|
|
25
31
|
publicDecrypt: PublicEncryptMethod;
|
|
26
32
|
privateDecrypt: PrivateDecryptMethod;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AESKeyVariant } from '../aes';
|
|
2
|
+
import type { CipherOrWrapMode } from '../keys';
|
|
3
|
+
import type { KeyObjectHandle } from './webcrypto';
|
|
4
|
+
|
|
5
|
+
export type AESCipher = (
|
|
6
|
+
mode: CipherOrWrapMode,
|
|
7
|
+
handle: KeyObjectHandle,
|
|
8
|
+
data: ArrayBuffer,
|
|
9
|
+
variant: AESKeyVariant,
|
|
10
|
+
iv_or_counter?: ArrayBuffer,
|
|
11
|
+
length?: number,
|
|
12
|
+
authTag?: ArrayBuffer,
|
|
13
|
+
additionalData?: ArrayBuffer
|
|
14
|
+
) => Promise<ArrayBuffer>;
|