react-native-quick-crypto 0.7.0-rc.9 → 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.
Files changed (155) hide show
  1. package/android/CMakeLists.txt +2 -0
  2. package/cpp/Cipher/MGLGenerateKeyPairInstaller.cpp +51 -14
  3. package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.cpp +25 -9
  4. package/cpp/Cipher/MGLRsa.cpp +192 -15
  5. package/cpp/Cipher/MGLRsa.h +36 -2
  6. package/cpp/JSIUtils/MGLJSIUtils.h +17 -0
  7. package/cpp/MGLKeys.cpp +210 -187
  8. package/cpp/MGLKeys.h +25 -13
  9. package/cpp/MGLQuickCryptoHostObject.cpp +6 -6
  10. package/cpp/Sig/MGLSignHostObjects.cpp +284 -421
  11. package/cpp/Sig/MGLSignHostObjects.h +40 -0
  12. package/cpp/Utils/MGLUtils.cpp +71 -42
  13. package/cpp/Utils/MGLUtils.h +81 -6
  14. package/cpp/webcrypto/MGLWebCrypto.cpp +97 -35
  15. package/cpp/webcrypto/MGLWebCrypto.h +5 -7
  16. package/cpp/webcrypto/crypto_aes.cpp +516 -0
  17. package/cpp/webcrypto/crypto_aes.h +79 -0
  18. package/cpp/webcrypto/crypto_ec.cpp +110 -20
  19. package/cpp/webcrypto/crypto_ec.h +18 -5
  20. package/cpp/webcrypto/crypto_keygen.cpp +86 -0
  21. package/cpp/webcrypto/crypto_keygen.h +38 -0
  22. package/lib/commonjs/Cipher.js +140 -95
  23. package/lib/commonjs/Cipher.js.map +1 -1
  24. package/lib/commonjs/Hashnames.js +20 -8
  25. package/lib/commonjs/Hashnames.js.map +1 -1
  26. package/lib/commonjs/NativeQuickCrypto/Cipher.js +23 -8
  27. package/lib/commonjs/NativeQuickCrypto/Cipher.js.map +1 -1
  28. package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js.map +1 -1
  29. package/lib/commonjs/NativeQuickCrypto/aes.js +6 -0
  30. package/lib/commonjs/NativeQuickCrypto/aes.js.map +1 -0
  31. package/lib/commonjs/NativeQuickCrypto/keygen.js +6 -0
  32. package/lib/commonjs/NativeQuickCrypto/keygen.js.map +1 -0
  33. package/lib/commonjs/NativeQuickCrypto/rsa.js +6 -0
  34. package/lib/commonjs/NativeQuickCrypto/rsa.js.map +1 -0
  35. package/lib/commonjs/NativeQuickCrypto/sig.js +17 -0
  36. package/lib/commonjs/NativeQuickCrypto/sig.js.map +1 -1
  37. package/lib/commonjs/Utils.js +45 -7
  38. package/lib/commonjs/Utils.js.map +1 -1
  39. package/lib/commonjs/aes.js +184 -227
  40. package/lib/commonjs/aes.js.map +1 -1
  41. package/lib/commonjs/ec.js +79 -91
  42. package/lib/commonjs/ec.js.map +1 -1
  43. package/lib/commonjs/index.js +12 -2
  44. package/lib/commonjs/index.js.map +1 -1
  45. package/lib/commonjs/keygen.js +56 -0
  46. package/lib/commonjs/keygen.js.map +1 -0
  47. package/lib/commonjs/keys.js +84 -29
  48. package/lib/commonjs/keys.js.map +1 -1
  49. package/lib/commonjs/random.js +6 -0
  50. package/lib/commonjs/random.js.map +1 -1
  51. package/lib/commonjs/rsa.js +115 -196
  52. package/lib/commonjs/rsa.js.map +1 -1
  53. package/lib/commonjs/sig.js.map +1 -1
  54. package/lib/commonjs/subtle.js +205 -29
  55. package/lib/commonjs/subtle.js.map +1 -1
  56. package/lib/commonjs/webcrypto.js +14 -0
  57. package/lib/commonjs/webcrypto.js.map +1 -0
  58. package/lib/module/Cipher.js +138 -93
  59. package/lib/module/Cipher.js.map +1 -1
  60. package/lib/module/Hashnames.js +20 -8
  61. package/lib/module/Hashnames.js.map +1 -1
  62. package/lib/module/NativeQuickCrypto/Cipher.js +22 -7
  63. package/lib/module/NativeQuickCrypto/Cipher.js.map +1 -1
  64. package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js.map +1 -1
  65. package/lib/module/NativeQuickCrypto/aes.js +2 -0
  66. package/lib/module/NativeQuickCrypto/aes.js.map +1 -0
  67. package/lib/module/NativeQuickCrypto/keygen.js +2 -0
  68. package/lib/module/NativeQuickCrypto/keygen.js.map +1 -0
  69. package/lib/module/NativeQuickCrypto/rsa.js +2 -0
  70. package/lib/module/NativeQuickCrypto/rsa.js.map +1 -0
  71. package/lib/module/NativeQuickCrypto/sig.js +13 -0
  72. package/lib/module/NativeQuickCrypto/sig.js.map +1 -1
  73. package/lib/module/Utils.js +38 -5
  74. package/lib/module/Utils.js.map +1 -1
  75. package/lib/module/aes.js +183 -228
  76. package/lib/module/aes.js.map +1 -1
  77. package/lib/module/ec.js +76 -93
  78. package/lib/module/ec.js.map +1 -1
  79. package/lib/module/index.js +11 -2
  80. package/lib/module/index.js.map +1 -1
  81. package/lib/module/keygen.js +47 -0
  82. package/lib/module/keygen.js.map +1 -0
  83. package/lib/module/keys.js +76 -28
  84. package/lib/module/keys.js.map +1 -1
  85. package/lib/module/random.js +6 -0
  86. package/lib/module/random.js.map +1 -1
  87. package/lib/module/rsa.js +115 -198
  88. package/lib/module/rsa.js.map +1 -1
  89. package/lib/module/sig.js.map +1 -1
  90. package/lib/module/subtle.js +209 -34
  91. package/lib/module/subtle.js.map +1 -1
  92. package/lib/module/webcrypto.js +8 -0
  93. package/lib/module/webcrypto.js.map +1 -0
  94. package/lib/typescript/Cipher.d.ts +23 -14
  95. package/lib/typescript/Cipher.d.ts.map +1 -1
  96. package/lib/typescript/Hash.d.ts.map +1 -1
  97. package/lib/typescript/Hashnames.d.ts +2 -2
  98. package/lib/typescript/Hashnames.d.ts.map +1 -1
  99. package/lib/typescript/NativeQuickCrypto/Cipher.d.ts +16 -6
  100. package/lib/typescript/NativeQuickCrypto/Cipher.d.ts.map +1 -1
  101. package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts +4 -1
  102. package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts.map +1 -1
  103. package/lib/typescript/NativeQuickCrypto/aes.d.ts +5 -0
  104. package/lib/typescript/NativeQuickCrypto/aes.d.ts.map +1 -0
  105. package/lib/typescript/NativeQuickCrypto/keygen.d.ts +4 -0
  106. package/lib/typescript/NativeQuickCrypto/keygen.d.ts.map +1 -0
  107. package/lib/typescript/NativeQuickCrypto/rsa.d.ts +5 -0
  108. package/lib/typescript/NativeQuickCrypto/rsa.d.ts.map +1 -0
  109. package/lib/typescript/NativeQuickCrypto/sig.d.ts +10 -0
  110. package/lib/typescript/NativeQuickCrypto/sig.d.ts.map +1 -1
  111. package/lib/typescript/NativeQuickCrypto/webcrypto.d.ts +14 -2
  112. package/lib/typescript/NativeQuickCrypto/webcrypto.d.ts.map +1 -1
  113. package/lib/typescript/Utils.d.ts +5 -4
  114. package/lib/typescript/Utils.d.ts.map +1 -1
  115. package/lib/typescript/aes.d.ts +18 -1
  116. package/lib/typescript/aes.d.ts.map +1 -1
  117. package/lib/typescript/ec.d.ts +3 -1
  118. package/lib/typescript/ec.d.ts.map +1 -1
  119. package/lib/typescript/index.d.ts +30 -24
  120. package/lib/typescript/index.d.ts.map +1 -1
  121. package/lib/typescript/keygen.d.ts +6 -0
  122. package/lib/typescript/keygen.d.ts.map +1 -0
  123. package/lib/typescript/keys.d.ts +67 -18
  124. package/lib/typescript/keys.d.ts.map +1 -1
  125. package/lib/typescript/random.d.ts +2 -1
  126. package/lib/typescript/random.d.ts.map +1 -1
  127. package/lib/typescript/rsa.d.ts +9 -1
  128. package/lib/typescript/rsa.d.ts.map +1 -1
  129. package/lib/typescript/sig.d.ts +3 -17
  130. package/lib/typescript/sig.d.ts.map +1 -1
  131. package/lib/typescript/subtle.d.ts +8 -4
  132. package/lib/typescript/subtle.d.ts.map +1 -1
  133. package/lib/typescript/webcrypto.d.ts +9 -0
  134. package/lib/typescript/webcrypto.d.ts.map +1 -0
  135. package/package.json +2 -2
  136. package/src/Cipher.ts +139 -75
  137. package/src/Hashnames.ts +23 -21
  138. package/src/NativeQuickCrypto/Cipher.ts +46 -14
  139. package/src/NativeQuickCrypto/NativeQuickCrypto.ts +6 -0
  140. package/src/NativeQuickCrypto/aes.ts +14 -0
  141. package/src/NativeQuickCrypto/keygen.ts +7 -0
  142. package/src/NativeQuickCrypto/rsa.ts +12 -0
  143. package/src/NativeQuickCrypto/sig.ts +27 -0
  144. package/src/NativeQuickCrypto/webcrypto.ts +28 -2
  145. package/src/Utils.ts +49 -8
  146. package/src/aes.ts +259 -222
  147. package/src/ec.ts +114 -90
  148. package/src/index.ts +10 -1
  149. package/src/keygen.ts +80 -0
  150. package/src/keys.ts +165 -61
  151. package/src/random.ts +12 -1
  152. package/src/rsa.ts +161 -187
  153. package/src/sig.ts +7 -23
  154. package/src/subtle.ts +309 -35
  155. package/src/webcrypto.ts +8 -0
package/cpp/MGLKeys.h CHANGED
@@ -101,7 +101,8 @@ class ManagedEVPPKey {
101
101
  KeyEncodingContext context);
102
102
  //
103
103
  static ManagedEVPPKey GetParsedKey(jsi::Runtime &runtime,
104
- EVPKeyPointer &&pkey, ParseKeyResult ret,
104
+ EVPKeyPointer &&pkey,
105
+ ParseKeyResult ret,
105
106
  const char *default_msg);
106
107
 
107
108
  static ManagedEVPPKey GetPublicOrPrivateKeyFromJs(jsi::Runtime &runtime,
@@ -113,17 +114,17 @@ class ManagedEVPPKey {
113
114
  unsigned int *offset,
114
115
  bool allow_key_object);
115
116
 
116
- static OptionJSVariant ToEncodedPublicKey(
117
- jsi::Runtime &runtime, ManagedEVPPKey key,
118
- const PublicKeyEncodingConfig &config);
117
+ static jsi::Value ToEncodedPublicKey(jsi::Runtime &runtime,
118
+ ManagedEVPPKey key,
119
+ const PublicKeyEncodingConfig &config);
119
120
 
120
- static OptionJSVariant ToEncodedPrivateKey(
121
- jsi::Runtime &runtime, ManagedEVPPKey key,
122
- const PrivateKeyEncodingConfig &config);
121
+ static jsi::Value ToEncodedPrivateKey(jsi::Runtime &runtime,
122
+ ManagedEVPPKey key,
123
+ const PrivateKeyEncodingConfig &config);
123
124
 
124
125
  private:
125
- // size_t size_of_private_key() const;
126
- // size_t size_of_public_key() const;
126
+ size_t size_of_private_key() const;
127
+ size_t size_of_public_key() const;
127
128
 
128
129
  EVPKeyPointer pkey_;
129
130
  };
@@ -167,25 +168,36 @@ class JSI_EXPORT KeyObjectHandle: public jsi::HostObject {
167
168
  jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propNameID);
168
169
  const std::shared_ptr<KeyObjectData>& Data();
169
170
 
171
+ static std::shared_ptr<KeyObjectHandle> Create(std::shared_ptr<KeyObjectData> data);
172
+
170
173
  protected:
171
174
  jsi::Value Export(jsi::Runtime &rt);
172
175
  jsi::Value ExportJWK(jsi::Runtime &rt);
173
- OptionJSVariant ExportPublicKey(
176
+ jsi::Value ExportPublicKey(
174
177
  jsi::Runtime& rt,
175
178
  const PublicKeyEncodingConfig& config) const;
176
- OptionJSVariant ExportPrivateKey(
179
+ jsi::Value ExportPrivateKey(
177
180
  jsi::Runtime& rt,
178
181
  const PrivateKeyEncodingConfig& config) const;
179
- OptionJSVariant ExportSecretKey(jsi::Runtime& rt) const;
182
+ jsi::Value ExportSecretKey(jsi::Runtime& rt) const;
183
+ jsi::Value GetKeyDetail(jsi::Runtime &rt);
184
+ jsi::Value GetAsymmetricKeyType(jsi::Runtime &rt) const;
180
185
  jsi::Value Init(jsi::Runtime &rt);
181
186
  jsi::Value InitECRaw(jsi::Runtime &rt);
182
187
  jsi::Value InitJWK(jsi::Runtime &rt);
183
- jsi::Value GetKeyDetail(jsi::Runtime &rt);
184
188
 
185
189
  private:
186
190
  std::shared_ptr<KeyObjectData> data_;
187
191
  };
188
192
 
193
+ WebCryptoKeyExportStatus PKEY_SPKI_Export(
194
+ KeyObjectData* key_data,
195
+ ByteSource* out);
196
+
197
+ WebCryptoKeyExportStatus PKEY_PKCS8_Export(
198
+ KeyObjectData* key_data,
199
+ ByteSource* out);
200
+
189
201
  } // namespace margelo
190
202
 
191
203
  #endif /* MGLCipherKeys_h */
@@ -113,12 +113,12 @@ MGLQuickCryptoHostObject::MGLQuickCryptoHostObject(
113
113
  // createVerify
114
114
  this->fields.push_back(getVerifyFieldDefinition(jsCallInvoker, workerQueue));
115
115
 
116
- // subtle API created from a simple jsi::Object
117
- // because this FieldDefinition is only good for returning
118
- // objects and too convoluted
119
- this->fields.push_back(JSI_VALUE("webcrypto", {
120
- return createWebCryptoObject(runtime);
121
- }));
116
+ // subtle API
117
+ this->fields.push_back(JSI_VALUE("webcrypto", {
118
+ auto hostObject = std::make_shared<MGLWebCryptoHostObject>(
119
+ jsCallInvoker, workerQueue);
120
+ return jsi::Object::createFromHostObject(runtime, hostObject);
121
+ }));
122
122
  }
123
123
 
124
124
  } // namespace margelo