react-native-quick-crypto 1.0.0-beta.3 → 1.0.0-beta.5
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 +4 -0
- package/README.md +2 -0
- package/android/CMakeLists.txt +26 -13
- package/android/build.gradle +4 -0
- package/android/src/main/cpp/cpp-adapter.cpp +3 -10
- package/android/src/main/java/com/margelo/nitro/quickcrypto/QuickCryptoPackage.java +15 -10
- package/cpp/pbkdf2/HybridPbkdf2.cpp +71 -0
- package/cpp/pbkdf2/HybridPbkdf2.hpp +35 -0
- package/cpp/random/HybridRandom.cpp +42 -18
- package/cpp/random/HybridRandom.hpp +13 -28
- package/cpp/utils/Utils.hpp +12 -1
- package/deps/fastpbkdf2/fastpbkdf2.c +352 -0
- package/deps/fastpbkdf2/fastpbkdf2.h +68 -0
- package/lib/commonjs/index.js +24 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/keys/index.js +86 -0
- package/lib/commonjs/keys/index.js.map +1 -0
- package/lib/commonjs/pbkdf2.js +89 -0
- package/lib/commonjs/pbkdf2.js.map +1 -0
- package/lib/commonjs/random.js +3 -3
- package/lib/commonjs/random.js.map +1 -1
- package/lib/commonjs/specs/keyObjectHandle.nitro.js +6 -0
- package/lib/commonjs/specs/keyObjectHandle.nitro.js.map +1 -0
- package/lib/commonjs/specs/pbkdf2.nitro.js +6 -0
- package/lib/commonjs/specs/pbkdf2.nitro.js.map +1 -0
- package/lib/commonjs/utils/conversion.js +74 -0
- package/lib/commonjs/utils/conversion.js.map +1 -1
- package/lib/commonjs/utils/errors.js +14 -0
- package/lib/commonjs/utils/errors.js.map +1 -0
- package/lib/commonjs/utils/hashnames.js +90 -0
- package/lib/commonjs/utils/hashnames.js.map +1 -0
- package/lib/commonjs/utils/index.js +43 -5
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/types.js +27 -0
- package/lib/commonjs/utils/types.js.map +1 -1
- package/lib/module/index.js +9 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/keys/index.js +81 -0
- package/lib/module/keys/index.js.map +1 -0
- package/lib/module/pbkdf2.js +83 -0
- package/lib/module/pbkdf2.js.map +1 -0
- package/lib/module/random.js +1 -1
- package/lib/module/random.js.map +1 -1
- package/lib/module/specs/keyObjectHandle.nitro.js +4 -0
- package/lib/module/specs/keyObjectHandle.nitro.js.map +1 -0
- package/lib/module/specs/pbkdf2.nitro.js +4 -0
- package/lib/module/specs/pbkdf2.nitro.js.map +1 -0
- package/lib/module/utils/conversion.js +71 -0
- package/lib/module/utils/conversion.js.map +1 -1
- package/lib/module/utils/errors.js +10 -0
- package/lib/module/utils/errors.js.map +1 -0
- package/lib/module/utils/hashnames.js +88 -0
- package/lib/module/utils/hashnames.js.map +1 -0
- package/lib/module/utils/index.js +4 -5
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/types.js +26 -0
- package/lib/module/utils/types.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/typescript/index.d.ts +26 -9
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/keys/index.d.ts +22 -0
- package/lib/typescript/keys/index.d.ts.map +1 -0
- package/lib/typescript/pbkdf2.d.ts +12 -0
- package/lib/typescript/pbkdf2.d.ts.map +1 -0
- package/lib/typescript/random.d.ts +1 -1
- package/lib/typescript/random.d.ts.map +1 -1
- package/lib/typescript/specs/keyObjectHandle.nitro.d.ts +15 -0
- package/lib/typescript/specs/keyObjectHandle.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/pbkdf2.nitro.d.ts +9 -0
- package/lib/typescript/specs/pbkdf2.nitro.d.ts.map +1 -0
- package/lib/typescript/utils/conversion.d.ts +7 -1
- package/lib/typescript/utils/conversion.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +7 -0
- package/lib/typescript/utils/errors.d.ts.map +1 -0
- package/lib/typescript/utils/hashnames.d.ts +11 -0
- package/lib/typescript/utils/hashnames.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +4 -5
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/lib/typescript/utils/types.d.ts +101 -0
- package/lib/typescript/utils/types.d.ts.map +1 -1
- package/nitrogen/generated/android/QuickCrypto+autolinking.cmake +19 -3
- package/nitrogen/generated/android/QuickCrypto+autolinking.gradle +1 -2
- package/nitrogen/generated/android/QuickCryptoOnLoad.cpp +50 -0
- package/nitrogen/generated/android/QuickCryptoOnLoad.hpp +25 -0
- package/nitrogen/generated/android/QuickCryptoOnLoad.kt +1 -0
- package/nitrogen/generated/ios/QuickCrypto+autolinking.rb +7 -6
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.cpp +10 -2
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.hpp +4 -2
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Umbrella.hpp +12 -6
- package/nitrogen/generated/ios/QuickCryptoAutolinking.mm +45 -0
- package/nitrogen/generated/ios/QuickCryptoAutolinking.swift +12 -0
- package/nitrogen/generated/shared/c++/AsymmetricKeyType.hpp +86 -0
- package/nitrogen/generated/shared/c++/HybridKeyObjectHandleSpec.cpp +27 -0
- package/nitrogen/generated/shared/c++/HybridKeyObjectHandleSpec.hpp +93 -0
- package/nitrogen/generated/shared/c++/HybridPbkdf2Spec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridPbkdf2Spec.hpp +66 -0
- package/nitrogen/generated/shared/c++/HybridRandomSpec.cpp +1 -2
- package/nitrogen/generated/shared/c++/HybridRandomSpec.hpp +7 -4
- package/nitrogen/generated/shared/c++/JWK.hpp +162 -0
- package/nitrogen/generated/shared/c++/JWKkty.hpp +86 -0
- package/nitrogen/generated/shared/c++/JWKuse.hpp +78 -0
- package/nitrogen/generated/shared/c++/KFormatType.hpp +65 -0
- package/nitrogen/generated/shared/c++/KeyDetail.hpp +93 -0
- package/nitrogen/generated/shared/c++/KeyEncoding.hpp +66 -0
- package/nitrogen/generated/shared/c++/KeyType.hpp +65 -0
- package/nitrogen/generated/shared/c++/KeyUsage.hpp +102 -0
- package/nitrogen/generated/shared/c++/NamedCurve.hpp +82 -0
- package/package.json +13 -12
- package/src/index.ts +8 -4
- package/src/keys/index.ts +99 -0
- package/src/pbkdf2.ts +154 -0
- package/src/random.ts +14 -14
- package/src/specs/keyObjectHandle.nitro.ts +32 -0
- package/src/specs/pbkdf2.nitro.ts +18 -0
- package/src/specs/random.nitro.ts +2 -2
- package/src/utils/conversion.ts +83 -1
- package/src/utils/errors.ts +15 -0
- package/src/utils/hashnames.ts +96 -0
- package/src/utils/index.ts +4 -6
- package/src/utils/types.ts +178 -2
- package/ios/QuickCryptoOnLoad.mm +0 -19
package/src/utils/types.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { type Buffer } from '@craftzdog/react-native-buffer';
|
|
2
|
+
import { type Buffer as SBuffer } from 'safe-buffer';
|
|
3
|
+
import { type CipherKey } from 'crypto'; // @types/node
|
|
4
|
+
|
|
1
5
|
export type ArrayBufferView = TypedArray | DataView | ArrayBufferLike | Buffer;
|
|
2
6
|
|
|
3
7
|
export type TypedArray =
|
|
@@ -11,5 +15,177 @@ export type TypedArray =
|
|
|
11
15
|
| Float32Array
|
|
12
16
|
| Float64Array;
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
export type RandomCallback<T> = (err: Error | null, value: T) => void;
|
|
19
|
+
|
|
20
|
+
export type BufferLike = ArrayBuffer | Buffer | SBuffer | ArrayBufferView;
|
|
21
|
+
|
|
22
|
+
export type BinaryLike =
|
|
23
|
+
| string
|
|
24
|
+
| ArrayBuffer
|
|
25
|
+
| Buffer
|
|
26
|
+
| SBuffer
|
|
27
|
+
| TypedArray
|
|
28
|
+
| DataView;
|
|
29
|
+
|
|
30
|
+
export type BinaryLikeNode = CipherKey | BinaryLike;
|
|
31
|
+
|
|
32
|
+
export type DigestAlgorithm = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
33
|
+
|
|
34
|
+
export type HashAlgorithm = DigestAlgorithm | 'SHA-224' | 'RIPEMD-160';
|
|
35
|
+
|
|
36
|
+
export type RSAKeyPairAlgorithm = 'RSASSA-PKCS1-v1_5' | 'RSA-PSS' | 'RSA-OAEP';
|
|
37
|
+
|
|
38
|
+
export type ECKeyPairAlgorithm = 'ECDSA' | 'ECDH';
|
|
39
|
+
|
|
40
|
+
export type CFRGKeyPairAlgorithm = 'Ed25519' | 'Ed448' | 'X25519' | 'X448';
|
|
41
|
+
|
|
42
|
+
export type KeyPairAlgorithm =
|
|
43
|
+
| RSAKeyPairAlgorithm
|
|
44
|
+
| ECKeyPairAlgorithm
|
|
45
|
+
| CFRGKeyPairAlgorithm;
|
|
46
|
+
|
|
47
|
+
export type AESAlgorithm = 'AES-CTR' | 'AES-CBC' | 'AES-GCM' | 'AES-KW';
|
|
48
|
+
|
|
49
|
+
export type SecretKeyAlgorithm = 'HMAC' | AESAlgorithm;
|
|
50
|
+
|
|
51
|
+
export type SignVerifyAlgorithm =
|
|
52
|
+
| 'RSASSA-PKCS1-v1_5'
|
|
53
|
+
| 'RSA-PSS'
|
|
54
|
+
| 'ECDSA'
|
|
55
|
+
| 'HMAC'
|
|
56
|
+
| 'Ed25519'
|
|
57
|
+
| 'Ed448';
|
|
58
|
+
|
|
59
|
+
export type DeriveBitsAlgorithm =
|
|
60
|
+
| 'PBKDF2'
|
|
61
|
+
| 'HKDF'
|
|
62
|
+
| 'ECDH'
|
|
63
|
+
| 'X25519'
|
|
64
|
+
| 'X448';
|
|
65
|
+
|
|
66
|
+
export type EncryptDecryptAlgorithm =
|
|
67
|
+
| 'RSA-OAEP'
|
|
68
|
+
| 'AES-CTR'
|
|
69
|
+
| 'AES-CBC'
|
|
70
|
+
| 'AES-GCM';
|
|
71
|
+
|
|
72
|
+
export type AnyAlgorithm =
|
|
73
|
+
| DigestAlgorithm
|
|
74
|
+
| HashAlgorithm
|
|
75
|
+
| KeyPairAlgorithm
|
|
76
|
+
| SecretKeyAlgorithm
|
|
77
|
+
| SignVerifyAlgorithm
|
|
78
|
+
| DeriveBitsAlgorithm
|
|
79
|
+
| EncryptDecryptAlgorithm
|
|
80
|
+
| AESAlgorithm
|
|
81
|
+
| 'PBKDF2'
|
|
82
|
+
| 'HKDF'
|
|
83
|
+
| 'unknown';
|
|
84
|
+
|
|
85
|
+
export type NamedCurve = 'P-256' | 'P-384' | 'P-521';
|
|
86
|
+
|
|
87
|
+
export type SubtleAlgorithm = {
|
|
88
|
+
name: AnyAlgorithm;
|
|
89
|
+
salt?: string;
|
|
90
|
+
iterations?: number;
|
|
91
|
+
hash?: HashAlgorithm;
|
|
92
|
+
namedCurve?: NamedCurve;
|
|
93
|
+
length?: number;
|
|
94
|
+
modulusLength?: number;
|
|
95
|
+
publicExponent?: number | Uint8Array;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type KeyUsage =
|
|
99
|
+
| 'encrypt'
|
|
100
|
+
| 'decrypt'
|
|
101
|
+
| 'sign'
|
|
102
|
+
| 'verify'
|
|
103
|
+
| 'deriveKey'
|
|
104
|
+
| 'deriveBits'
|
|
105
|
+
| 'wrapKey'
|
|
106
|
+
| 'unwrapKey';
|
|
107
|
+
|
|
108
|
+
// On node this value is defined on the native side, for now I'm just creating it here in JS
|
|
109
|
+
// TODO(osp) move this into native side to make sure they always match
|
|
110
|
+
export enum KFormatType {
|
|
111
|
+
kKeyFormatDER,
|
|
112
|
+
kKeyFormatPEM,
|
|
113
|
+
kKeyFormatJWK,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Same as KFormatType, this enum needs to be defined on the native side
|
|
117
|
+
export enum KeyType {
|
|
118
|
+
Secret,
|
|
119
|
+
Public,
|
|
120
|
+
Private,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export enum KeyEncoding {
|
|
124
|
+
kKeyEncodingPKCS1,
|
|
125
|
+
kKeyEncodingPKCS8,
|
|
126
|
+
kKeyEncodingSPKI,
|
|
127
|
+
kKeyEncodingSEC1,
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export type AsymmetricKeyType = 'rsa' | 'rsa-pss' | 'dsa' | 'ec';
|
|
131
|
+
|
|
132
|
+
type JWKkty = 'AES' | 'RSA' | 'EC' | 'oct';
|
|
133
|
+
type JWKuse = 'sig' | 'enc';
|
|
134
|
+
|
|
135
|
+
export interface JWK {
|
|
136
|
+
kty?: JWKkty;
|
|
137
|
+
use?: JWKuse;
|
|
138
|
+
key_ops?: KeyUsage[];
|
|
139
|
+
alg?: string; // TODO: enumerate these (RFC-7517)
|
|
140
|
+
crv?: string;
|
|
141
|
+
kid?: string;
|
|
142
|
+
x5u?: string;
|
|
143
|
+
x5c?: string[];
|
|
144
|
+
x5t?: string;
|
|
145
|
+
'x5t#256'?: string;
|
|
146
|
+
n?: string;
|
|
147
|
+
e?: string;
|
|
148
|
+
d?: string;
|
|
149
|
+
p?: string;
|
|
150
|
+
q?: string;
|
|
151
|
+
x?: string;
|
|
152
|
+
y?: string;
|
|
153
|
+
k?: string;
|
|
154
|
+
dp?: string;
|
|
155
|
+
dq?: string;
|
|
156
|
+
qi?: string;
|
|
157
|
+
ext?: boolean;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export type KTypePrivate = 'pkcs1' | 'pkcs8' | 'sec1';
|
|
161
|
+
export type KTypePublic = 'pkcs1' | 'spki';
|
|
162
|
+
export type KType = KTypePrivate | KTypePublic;
|
|
163
|
+
|
|
164
|
+
export type KFormat = 'der' | 'pem' | 'jwk';
|
|
165
|
+
|
|
166
|
+
export type DSAEncoding = 'der' | 'ieee-p1363';
|
|
167
|
+
|
|
168
|
+
export type EncodingOptions = {
|
|
169
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
170
|
+
key?: any;
|
|
171
|
+
type?: KType;
|
|
172
|
+
encoding?: string;
|
|
173
|
+
dsaEncoding?: DSAEncoding;
|
|
174
|
+
format?: KFormat;
|
|
175
|
+
padding?: number;
|
|
176
|
+
cipher?: string;
|
|
177
|
+
passphrase?: BinaryLike;
|
|
178
|
+
saltLength?: number;
|
|
179
|
+
oaepHash?: string;
|
|
180
|
+
oaepLabel?: BinaryLike;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export interface KeyDetail {
|
|
184
|
+
length?: number;
|
|
185
|
+
publicExponent?: number;
|
|
186
|
+
modulusLength?: number;
|
|
187
|
+
hashAlgorithm?: string;
|
|
188
|
+
mgf1HashAlgorithm?: string;
|
|
189
|
+
saltLength?: number;
|
|
190
|
+
namedCurve?: string;
|
|
191
|
+
}
|
package/ios/QuickCryptoOnLoad.mm
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
#include "HybridRandom.hpp"
|
|
3
|
-
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
4
|
-
|
|
5
|
-
@interface QuickCryptoOnLoad : NSObject
|
|
6
|
-
@end
|
|
7
|
-
|
|
8
|
-
@implementation QuickCryptoOnLoad
|
|
9
|
-
|
|
10
|
-
using namespace margelo::nitro;
|
|
11
|
-
using namespace margelo::crypto;
|
|
12
|
-
|
|
13
|
-
+ (void)load {
|
|
14
|
-
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
15
|
-
"Random", []() -> std::shared_ptr<HybridObject> { return std::make_shared<HybridRandom>();
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@end
|