react-native-quick-crypto 0.3.1 → 0.4.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.
Files changed (66) hide show
  1. package/README.md +10 -6
  2. package/android/CMakeLists.txt +10 -2
  3. package/android/gradle.properties +1 -1
  4. package/android/src/main/AndroidManifest.xml +1 -1
  5. package/android/src/main/cpp/cpp-adapter.cpp +1 -1
  6. package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoModule.java +70 -0
  7. package/android/src/main/java/com/{reactnativequickcrypto → margelo/quickcrypto}/QuickCryptoPackage.java +11 -12
  8. package/cpp/Cipher/MGLCipherHostObject.cpp +4 -5
  9. package/cpp/Cipher/MGLCreateCipherInstaller.cpp +1 -3
  10. package/cpp/Cipher/MGLGenerateKeyPairInstaller.h +6 -3
  11. package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.h +5 -3
  12. package/cpp/Cipher/MGLPublicCipher.h +1 -1
  13. package/cpp/Cipher/MGLPublicCipherInstaller.h +1 -1
  14. package/cpp/Cipher/MGLRsa.h +5 -1
  15. package/cpp/JSIUtils/MGLJSIMacros.h +69 -6
  16. package/cpp/{Cipher/MGLCipherKeys.cpp → MGLKeys.cpp} +47 -49
  17. package/cpp/{Cipher/MGLCipherKeys.h → MGLKeys.h} +29 -30
  18. package/cpp/MGLQuickCryptoHostObject.cpp +12 -0
  19. package/cpp/Sig/MGLSignHostObjects.cpp +889 -0
  20. package/cpp/Sig/MGLSignHostObjects.h +88 -0
  21. package/cpp/Sig/MGLSignInstaller.cpp +24 -0
  22. package/cpp/Sig/MGLSignInstaller.h +29 -0
  23. package/cpp/Sig/MGLVerifyInstaller.cpp +24 -0
  24. package/cpp/Sig/MGLVerifyInstaller.h +22 -0
  25. package/cpp/Utils/MGLUtils.cpp +67 -29
  26. package/cpp/Utils/MGLUtils.h +17 -17
  27. package/lib/commonjs/@types/crypto-browserify.d.js +2 -0
  28. package/lib/commonjs/@types/crypto-browserify.d.js.map +1 -0
  29. package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js.map +1 -1
  30. package/lib/commonjs/NativeQuickCrypto/sig.js +2 -0
  31. package/lib/commonjs/NativeQuickCrypto/sig.js.map +1 -0
  32. package/lib/commonjs/QuickCrypto.js +4 -0
  33. package/lib/commonjs/QuickCrypto.js.map +1 -1
  34. package/lib/commonjs/index.js +7 -7
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/commonjs/keys.js +1 -4
  37. package/lib/commonjs/keys.js.map +1 -1
  38. package/lib/commonjs/sig.js +170 -0
  39. package/lib/commonjs/sig.js.map +1 -0
  40. package/lib/module/@types/crypto-browserify.d.js +2 -0
  41. package/lib/module/@types/crypto-browserify.d.js.map +1 -0
  42. package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js.map +1 -1
  43. package/lib/module/NativeQuickCrypto/sig.js +2 -0
  44. package/lib/module/NativeQuickCrypto/sig.js.map +1 -0
  45. package/lib/module/QuickCrypto.js +3 -0
  46. package/lib/module/QuickCrypto.js.map +1 -1
  47. package/lib/module/index.js +6 -9
  48. package/lib/module/index.js.map +1 -1
  49. package/lib/module/keys.js +1 -4
  50. package/lib/module/keys.js.map +1 -1
  51. package/lib/module/sig.js +155 -0
  52. package/lib/module/sig.js.map +1 -0
  53. package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts +3 -0
  54. package/lib/typescript/NativeQuickCrypto/sig.d.ts +12 -0
  55. package/lib/typescript/QuickCrypto.d.ts +3 -0
  56. package/lib/typescript/index.d.ts +206 -1
  57. package/lib/typescript/sig.d.ts +35 -0
  58. package/package.json +3 -2
  59. package/src/@types/crypto-browserify.d.ts +4 -0
  60. package/src/NativeQuickCrypto/NativeQuickCrypto.ts +3 -0
  61. package/src/NativeQuickCrypto/sig.ts +17 -0
  62. package/src/QuickCrypto.ts +3 -0
  63. package/src/index.ts +6 -5
  64. package/src/keys.ts +18 -13
  65. package/src/sig.ts +179 -0
  66. package/android/src/main/java/com/reactnativequickcrypto/QuickCryptoModule.java +0 -70
@@ -1,12 +1,12 @@
1
1
  //
2
- // MGLCipherKeys.hpp
3
- // react-native-fast-crypto
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 MGLCipherKeys_hpp
9
- #define MGLCipherKeys_hpp
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 "JSIUtils/MGLUtils.h"
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* 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&& pkey);
79
- ManagedEVPPKey(const ManagedEVPPKey& that);
80
- ManagedEVPPKey& operator=(const ManagedEVPPKey& that);
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* get() const;
83
+ EVP_PKEY *get() const;
84
84
 
85
85
  static PublicKeyEncodingConfig GetPublicKeyEncodingFromJs(
86
- jsi::Runtime& runtime, const jsi::Value* arguments, unsigned int* offset,
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& runtime, const jsi::Value* arguments, unsigned int* offset,
90
+ jsi::Runtime &runtime, const jsi::Value *arguments, unsigned int *offset,
91
91
  KeyEncodingContext context);
92
92
  //
93
- static ManagedEVPPKey GetParsedKey(jsi::Runtime& runtime,
94
- EVPKeyPointer&& pkey, ParseKeyResult ret,
95
- const char* default_msg);
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& runtime,
98
- const jsi::Value* args,
99
- unsigned int* offset);
97
+ static ManagedEVPPKey GetPublicOrPrivateKeyFromJs(jsi::Runtime &runtime,
98
+ const jsi::Value *args,
99
+ unsigned int *offset);
100
100
 
101
- // static ManagedEVPPKey GetPrivateKeyFromJs(
102
- // const
103
- // v8::FunctionCallbackInfo<v8::Value>&
104
- // args, unsigned int* offset, bool
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& runtime, ManagedEVPPKey key,
109
- const PublicKeyEncodingConfig& config);
107
+ jsi::Runtime &runtime, ManagedEVPPKey key,
108
+ const PublicKeyEncodingConfig &config);
110
109
 
111
110
  static std::optional<StringOrBuffer> ToEncodedPrivateKey(
112
- jsi::Runtime& runtime, ManagedEVPPKey key,
113
- const PrivateKeyEncodingConfig& config);
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 /* MGLCipherKeys_hpp */
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