react-native-quick-crypto 0.3.0 → 0.4.0
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/README.md +25 -14
- package/android/CMakeLists.txt +10 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoModule.java +70 -0
- package/android/src/main/java/com/{reactnativequickcrypto → margelo/quickcrypto}/QuickCryptoPackage.java +11 -12
- package/cpp/Cipher/MGLCipherHostObject.cpp +4 -5
- package/cpp/Cipher/MGLCreateCipherInstaller.cpp +1 -3
- package/cpp/Cipher/MGLGenerateKeyPairInstaller.h +6 -3
- package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.h +5 -3
- package/cpp/Cipher/MGLPublicCipher.h +1 -1
- package/cpp/Cipher/MGLPublicCipherInstaller.h +1 -1
- package/cpp/Cipher/MGLRsa.h +5 -1
- package/cpp/JSIUtils/MGLJSIMacros.h +69 -6
- package/cpp/{Cipher/MGLCipherKeys.cpp → MGLKeys.cpp} +47 -49
- package/cpp/{Cipher/MGLCipherKeys.h → MGLKeys.h} +29 -30
- package/cpp/MGLQuickCryptoHostObject.cpp +12 -0
- package/cpp/Sig/MGLSignHostObjects.cpp +889 -0
- package/cpp/Sig/MGLSignHostObjects.h +88 -0
- package/cpp/Sig/MGLSignInstaller.cpp +24 -0
- package/cpp/Sig/MGLSignInstaller.h +29 -0
- package/cpp/Sig/MGLVerifyInstaller.cpp +24 -0
- package/cpp/Sig/MGLVerifyInstaller.h +22 -0
- package/cpp/Utils/MGLUtils.cpp +67 -29
- package/cpp/Utils/MGLUtils.h +17 -17
- package/lib/commonjs/@types/crypto-browserify.d.js +2 -0
- package/lib/commonjs/@types/crypto-browserify.d.js.map +1 -0
- package/lib/commonjs/@types/stream-browserify.d.js +2 -0
- package/lib/commonjs/@types/stream-browserify.d.js.map +1 -0
- package/lib/commonjs/Cipher.js +3 -2
- package/lib/commonjs/Cipher.js.map +1 -1
- package/lib/commonjs/Hash.js +2 -2
- package/lib/commonjs/Hash.js.map +1 -1
- package/lib/commonjs/Hmac.js +2 -2
- package/lib/commonjs/Hmac.js.map +1 -1
- package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js.map +1 -1
- package/lib/commonjs/NativeQuickCrypto/sig.js +2 -0
- package/lib/commonjs/NativeQuickCrypto/sig.js.map +1 -0
- package/lib/commonjs/QuickCrypto.js +4 -0
- package/lib/commonjs/QuickCrypto.js.map +1 -1
- package/lib/commonjs/index.js +16 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/keys.js +1 -4
- package/lib/commonjs/keys.js.map +1 -1
- package/lib/commonjs/sig.js +170 -0
- package/lib/commonjs/sig.js.map +1 -0
- package/lib/module/@types/crypto-browserify.d.js +2 -0
- package/lib/module/@types/crypto-browserify.d.js.map +1 -0
- package/lib/module/@types/stream-browserify.d.js +2 -0
- package/lib/module/@types/stream-browserify.d.js.map +1 -0
- package/lib/module/Cipher.js +2 -1
- package/lib/module/Cipher.js.map +1 -1
- package/lib/module/Hash.js +1 -1
- package/lib/module/Hash.js.map +1 -1
- package/lib/module/Hmac.js +1 -1
- package/lib/module/Hmac.js.map +1 -1
- package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js.map +1 -1
- package/lib/module/NativeQuickCrypto/sig.js +2 -0
- package/lib/module/NativeQuickCrypto/sig.js.map +1 -0
- package/lib/module/QuickCrypto.js +3 -0
- package/lib/module/QuickCrypto.js.map +1 -1
- package/lib/module/index.js +12 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/keys.js +1 -4
- package/lib/module/keys.js.map +1 -1
- package/lib/module/sig.js +155 -0
- package/lib/module/sig.js.map +1 -0
- package/lib/typescript/Cipher.d.ts +1 -1
- package/lib/typescript/Hash.d.ts +1 -1
- package/lib/typescript/Hmac.d.ts +1 -1
- package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts +3 -0
- package/lib/typescript/NativeQuickCrypto/sig.d.ts +12 -0
- package/lib/typescript/QuickCrypto.d.ts +3 -0
- package/lib/typescript/index.d.ts +207 -3
- package/lib/typescript/sig.d.ts +35 -0
- package/package.json +5 -3
- package/src/@types/crypto-browserify.d.ts +4 -0
- package/src/@types/stream-browserify.d.ts +4 -0
- package/src/Cipher.ts +2 -1
- package/src/Hash.ts +1 -1
- package/src/Hmac.ts +1 -1
- package/src/NativeQuickCrypto/NativeQuickCrypto.ts +3 -0
- package/src/NativeQuickCrypto/sig.ts +17 -0
- package/src/QuickCrypto.ts +3 -0
- package/src/index.ts +12 -2
- package/src/keys.ts +18 -13
- package/src/sig.ts +179 -0
- package/android/src/main/java/com/reactnativequickcrypto/QuickCryptoModule.java +0 -70
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
//
|
|
2
|
-
// MGLCipherKeys.
|
|
3
|
-
// react-native-
|
|
2
|
+
// MGLCipherKeys.h
|
|
3
|
+
// react-native-quick-crypto
|
|
4
4
|
//
|
|
5
5
|
// Created by Oscar on 20.06.22.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
#ifndef
|
|
9
|
-
#define
|
|
8
|
+
#ifndef MGLCipherKeys_h
|
|
9
|
+
#define MGLCipherKeys_h
|
|
10
10
|
|
|
11
11
|
#include <jsi/jsi.h>
|
|
12
12
|
#include <openssl/evp.h>
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
#include <string>
|
|
17
17
|
|
|
18
18
|
#ifdef ANDROID
|
|
19
|
-
#include "
|
|
19
|
+
#include "Utils/MGLUtils.h"
|
|
20
20
|
#else
|
|
21
21
|
#include "MGLUtils.h"
|
|
22
22
|
#endif
|
|
@@ -62,7 +62,7 @@ struct AsymmetricKeyEncodingConfig {
|
|
|
62
62
|
using PublicKeyEncodingConfig = AsymmetricKeyEncodingConfig;
|
|
63
63
|
|
|
64
64
|
struct PrivateKeyEncodingConfig : public AsymmetricKeyEncodingConfig {
|
|
65
|
-
const EVP_CIPHER*
|
|
65
|
+
const EVP_CIPHER *cipher_;
|
|
66
66
|
// The ByteSource alone is not enough to distinguish between "no passphrase"
|
|
67
67
|
// and a zero-length passphrase (which can be a null pointer), therefore, we
|
|
68
68
|
// use a NonCopyableMaybe.
|
|
@@ -75,50 +75,49 @@ struct PrivateKeyEncodingConfig : public AsymmetricKeyEncodingConfig {
|
|
|
75
75
|
class ManagedEVPPKey {
|
|
76
76
|
public:
|
|
77
77
|
ManagedEVPPKey() {}
|
|
78
|
-
explicit ManagedEVPPKey(EVPKeyPointer&&
|
|
79
|
-
ManagedEVPPKey(const ManagedEVPPKey&
|
|
80
|
-
ManagedEVPPKey&
|
|
78
|
+
explicit ManagedEVPPKey(EVPKeyPointer &&pkey);
|
|
79
|
+
ManagedEVPPKey(const ManagedEVPPKey &that);
|
|
80
|
+
ManagedEVPPKey &operator=(const ManagedEVPPKey &that);
|
|
81
81
|
|
|
82
82
|
operator bool() const;
|
|
83
|
-
EVP_PKEY*
|
|
83
|
+
EVP_PKEY *get() const;
|
|
84
84
|
|
|
85
85
|
static PublicKeyEncodingConfig GetPublicKeyEncodingFromJs(
|
|
86
|
-
jsi::Runtime&
|
|
86
|
+
jsi::Runtime &runtime, const jsi::Value *arguments, unsigned int *offset,
|
|
87
87
|
KeyEncodingContext context);
|
|
88
88
|
|
|
89
89
|
static NonCopyableMaybe<PrivateKeyEncodingConfig> GetPrivateKeyEncodingFromJs(
|
|
90
|
-
jsi::Runtime&
|
|
90
|
+
jsi::Runtime &runtime, const jsi::Value *arguments, unsigned int *offset,
|
|
91
91
|
KeyEncodingContext context);
|
|
92
92
|
//
|
|
93
|
-
static ManagedEVPPKey GetParsedKey(jsi::Runtime&
|
|
94
|
-
EVPKeyPointer&&
|
|
95
|
-
const char*
|
|
93
|
+
static ManagedEVPPKey GetParsedKey(jsi::Runtime &runtime,
|
|
94
|
+
EVPKeyPointer &&pkey, ParseKeyResult ret,
|
|
95
|
+
const char *default_msg);
|
|
96
96
|
|
|
97
|
-
static ManagedEVPPKey GetPublicOrPrivateKeyFromJs(jsi::Runtime&
|
|
98
|
-
const jsi::Value*
|
|
99
|
-
unsigned int*
|
|
97
|
+
static ManagedEVPPKey GetPublicOrPrivateKeyFromJs(jsi::Runtime &runtime,
|
|
98
|
+
const jsi::Value *args,
|
|
99
|
+
unsigned int *offset);
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// allow_key_object);
|
|
101
|
+
static ManagedEVPPKey GetPrivateKeyFromJs(jsi::Runtime &runtime,
|
|
102
|
+
const jsi::Value *args,
|
|
103
|
+
unsigned int *offset,
|
|
104
|
+
bool allow_key_object);
|
|
106
105
|
|
|
107
106
|
static std::optional<StringOrBuffer> ToEncodedPublicKey(
|
|
108
|
-
jsi::Runtime&
|
|
109
|
-
const PublicKeyEncodingConfig&
|
|
107
|
+
jsi::Runtime &runtime, ManagedEVPPKey key,
|
|
108
|
+
const PublicKeyEncodingConfig &config);
|
|
110
109
|
|
|
111
110
|
static std::optional<StringOrBuffer> ToEncodedPrivateKey(
|
|
112
|
-
jsi::Runtime&
|
|
113
|
-
const PrivateKeyEncodingConfig&
|
|
111
|
+
jsi::Runtime &runtime, ManagedEVPPKey key,
|
|
112
|
+
const PrivateKeyEncodingConfig &config);
|
|
114
113
|
|
|
115
114
|
private:
|
|
116
|
-
size_t size_of_private_key() const;
|
|
117
|
-
size_t size_of_public_key() const;
|
|
115
|
+
// size_t size_of_private_key() const;
|
|
116
|
+
// size_t size_of_public_key() const;
|
|
118
117
|
|
|
119
118
|
EVPKeyPointer pkey_;
|
|
120
119
|
};
|
|
121
120
|
|
|
122
121
|
} // namespace margelo
|
|
123
122
|
|
|
124
|
-
#endif /*
|
|
123
|
+
#endif /* MGLCipherKeys_h */
|
|
@@ -11,11 +11,15 @@
|
|
|
11
11
|
#ifdef ANDROID
|
|
12
12
|
#include "Cipher/MGLCreateCipherInstaller.h"
|
|
13
13
|
#include "Cipher/MGLCreateDecipherInstaller.h"
|
|
14
|
+
#include "Cipher/MGLGenerateKeyPairInstaller.h"
|
|
15
|
+
#include "Cipher/MGLGenerateKeyPairSyncInstaller.h"
|
|
14
16
|
#include "Cipher/MGLPublicCipher.h"
|
|
15
17
|
#include "Cipher/MGLPublicCipherInstaller.h"
|
|
16
18
|
#include "HMAC/MGLHmacInstaller.h"
|
|
17
19
|
#include "Hash/MGLHashInstaller.h"
|
|
18
20
|
#include "Random/MGLRandomHostObject.h"
|
|
21
|
+
#include "Sig/MGLSignInstaller.h"
|
|
22
|
+
#include "Sig/MGLVerifyInstaller.h"
|
|
19
23
|
#include "fastpbkdf2/MGLPbkdf2HostObject.h"
|
|
20
24
|
#else
|
|
21
25
|
#include "MGLCreateCipherInstaller.h"
|
|
@@ -28,6 +32,8 @@
|
|
|
28
32
|
#include "MGLPublicCipher.h"
|
|
29
33
|
#include "MGLPublicCipherInstaller.h"
|
|
30
34
|
#include "MGLRandomHostObject.h"
|
|
35
|
+
#include "MGLSignInstaller.h"
|
|
36
|
+
#include "MGLVerifyInstaller.h"
|
|
31
37
|
#endif
|
|
32
38
|
|
|
33
39
|
namespace margelo {
|
|
@@ -98,6 +104,12 @@ MGLQuickCryptoHostObject::MGLQuickCryptoHostObject(
|
|
|
98
104
|
std::make_shared<MGLRandomHostObject>(jsCallInvoker, workerQueue);
|
|
99
105
|
return jsi::Object::createFromHostObject(runtime, hostObject);
|
|
100
106
|
}));
|
|
107
|
+
|
|
108
|
+
// createSign
|
|
109
|
+
this->fields.push_back(getSignFieldDefinition(jsCallInvoker, workerQueue));
|
|
110
|
+
|
|
111
|
+
// createVerify
|
|
112
|
+
this->fields.push_back(getVerifyFieldDefinition(jsCallInvoker, workerQueue));
|
|
101
113
|
}
|
|
102
114
|
|
|
103
115
|
} // namespace margelo
|