react-native-quick-crypto 0.7.11 → 1.0.0-beta.10
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 +47 -0
- package/README.md +6 -4
- package/android/CMakeLists.txt +26 -55
- package/android/build.gradle +70 -112
- package/android/gradle.properties +3 -3
- package/android/src/main/cpp/cpp-adapter.cpp +3 -64
- package/android/src/main/java/com/margelo/nitro/quickcrypto/QuickCryptoPackage.java +43 -0
- package/cpp/ed25519/HybridEdKeyPair.cpp +268 -0
- package/cpp/ed25519/HybridEdKeyPair.hpp +85 -0
- package/cpp/pbkdf2/HybridPbkdf2.cpp +72 -0
- package/cpp/pbkdf2/HybridPbkdf2.hpp +35 -0
- package/cpp/random/HybridRandom.cpp +59 -0
- package/cpp/random/HybridRandom.hpp +33 -0
- package/cpp/utils/Utils.hpp +20 -0
- package/lib/commonjs/ed.js +42 -0
- package/lib/commonjs/ed.js.map +1 -0
- package/lib/commonjs/index.js +90 -39
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/keys/classes.js +191 -0
- package/lib/commonjs/keys/classes.js.map +1 -0
- package/lib/commonjs/keys/generateKeyPair.js +148 -0
- package/lib/commonjs/keys/generateKeyPair.js.map +1 -0
- package/lib/commonjs/keys/index.js +62 -0
- package/lib/commonjs/keys/index.js.map +1 -0
- package/lib/commonjs/keys/signVerify.js +41 -0
- package/lib/commonjs/keys/signVerify.js.map +1 -0
- package/lib/commonjs/keys/utils.js +118 -0
- package/lib/commonjs/keys/utils.js.map +1 -0
- package/lib/commonjs/pbkdf2.js +29 -19
- package/lib/commonjs/pbkdf2.js.map +1 -1
- package/lib/commonjs/random.js +27 -11
- package/lib/commonjs/random.js.map +1 -1
- package/lib/commonjs/{NativeQuickCrypto/aes.js → specs/edKeyPair.nitro.js} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/aes.js.map → specs/edKeyPair.nitro.js.map} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/keygen.js → specs/keyObjectHandle.nitro.js} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/hash.js.map → specs/keyObjectHandle.nitro.js.map} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/rsa.js → specs/pbkdf2.nitro.js} +1 -1
- package/lib/{module/NativeQuickCrypto/aes.js.map → commonjs/specs/pbkdf2.nitro.js.map} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/webcrypto.js → specs/random.nitro.js} +1 -1
- package/lib/{module/NativeQuickCrypto/rsa.js.map → commonjs/specs/random.nitro.js.map} +1 -1
- package/lib/commonjs/utils/conversion.js +117 -0
- package/lib/commonjs/utils/conversion.js.map +1 -0
- package/lib/commonjs/utils/errors.js +14 -0
- package/lib/commonjs/utils/errors.js.map +1 -0
- package/lib/commonjs/{Hashnames.js → utils/hashnames.js} +2 -5
- package/lib/commonjs/utils/hashnames.js.map +1 -0
- package/lib/commonjs/utils/index.js +61 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/commonjs/utils/types.js +40 -0
- package/lib/commonjs/utils/types.js.map +1 -0
- package/lib/commonjs/utils/validation.js +25 -0
- package/lib/commonjs/utils/validation.js.map +1 -0
- package/lib/module/ed.js +37 -0
- package/lib/module/ed.js.map +1 -0
- package/lib/module/index.js +44 -37
- package/lib/module/index.js.map +1 -1
- package/lib/module/keys/classes.js +182 -0
- package/lib/module/keys/classes.js.map +1 -0
- package/lib/module/keys/generateKeyPair.js +148 -0
- package/lib/module/keys/generateKeyPair.js.map +1 -0
- package/lib/module/keys/index.js +29 -0
- package/lib/module/keys/index.js.map +1 -0
- package/lib/module/keys/signVerify.js +41 -0
- package/lib/module/keys/signVerify.js.map +1 -0
- package/lib/module/keys/utils.js +110 -0
- package/lib/module/keys/utils.js.map +1 -0
- package/lib/module/pbkdf2.js +17 -7
- package/lib/module/pbkdf2.js.map +1 -1
- package/lib/module/random.js +26 -10
- package/lib/module/random.js.map +1 -1
- package/lib/module/specs/edKeyPair.nitro.js +4 -0
- package/lib/{commonjs/NativeQuickCrypto/rsa.js.map → module/specs/edKeyPair.nitro.js.map} +1 -1
- package/lib/module/specs/keyObjectHandle.nitro.js +4 -0
- package/lib/{commonjs/NativeQuickCrypto/hmac.js.map → module/specs/keyObjectHandle.nitro.js.map} +1 -1
- package/lib/module/specs/pbkdf2.nitro.js +4 -0
- package/lib/module/specs/pbkdf2.nitro.js.map +1 -0
- package/lib/module/specs/random.nitro.js +4 -0
- package/lib/module/specs/random.nitro.js.map +1 -0
- package/lib/module/utils/conversion.js +107 -0
- package/lib/module/utils/conversion.js.map +1 -0
- package/lib/module/utils/errors.js +10 -0
- package/lib/module/utils/errors.js.map +1 -0
- package/lib/module/{Hashnames.js → utils/hashnames.js} +2 -5
- package/lib/module/utils/hashnames.js.map +1 -0
- package/lib/module/utils/index.js +8 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/utils/types.js +42 -0
- package/lib/module/utils/types.js.map +1 -0
- package/lib/module/utils/validation.js +19 -0
- package/lib/module/utils/validation.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/typescript/ed.d.ts +17 -0
- package/lib/typescript/ed.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +74 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/keys/classes.d.ts +38 -0
- package/lib/typescript/keys/classes.d.ts.map +1 -0
- package/lib/typescript/keys/generateKeyPair.d.ts +1 -0
- package/lib/typescript/keys/generateKeyPair.d.ts.map +1 -0
- package/lib/typescript/keys/index.d.ts +4 -0
- package/lib/typescript/keys/index.d.ts.map +1 -0
- package/lib/typescript/keys/signVerify.d.ts +1 -0
- package/lib/typescript/keys/signVerify.d.ts.map +1 -0
- package/lib/typescript/keys/utils.d.ts +32 -0
- package/lib/typescript/keys/utils.d.ts.map +1 -0
- package/lib/typescript/{src/pbkdf2.d.ts → pbkdf2.d.ts} +4 -3
- package/lib/typescript/pbkdf2.d.ts.map +1 -0
- package/lib/typescript/{src/random.d.ts → random.d.ts} +4 -4
- package/lib/typescript/random.d.ts.map +1 -0
- package/lib/typescript/specs/edKeyPair.nitro.d.ts +16 -0
- package/lib/typescript/specs/edKeyPair.nitro.d.ts.map +1 -0
- 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/specs/random.nitro.d.ts +9 -0
- package/lib/typescript/specs/random.nitro.d.ts.map +1 -0
- package/lib/typescript/utils/conversion.d.ts +25 -0
- package/lib/typescript/utils/conversion.d.ts.map +1 -0
- package/lib/typescript/utils/errors.d.ts +7 -0
- package/lib/typescript/utils/errors.d.ts.map +1 -0
- package/lib/typescript/{src/Hashnames.d.ts → utils/hashnames.d.ts} +3 -3
- package/lib/typescript/utils/hashnames.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +6 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/lib/typescript/utils/types.d.ts +162 -0
- package/lib/typescript/utils/types.d.ts.map +1 -0
- package/lib/typescript/utils/validation.d.ts +8 -0
- package/lib/typescript/utils/validation.d.ts.map +1 -0
- package/nitrogen/generated/android/QuickCrypto+autolinking.cmake +65 -0
- package/nitrogen/generated/android/QuickCrypto+autolinking.gradle +27 -0
- package/nitrogen/generated/android/QuickCryptoOnLoad.cpp +64 -0
- package/nitrogen/generated/android/QuickCryptoOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/QuickCrypto+autolinking.rb +58 -0
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/QuickCryptoAutolinking.mm +55 -0
- package/nitrogen/generated/ios/QuickCryptoAutolinking.swift +12 -0
- package/nitrogen/generated/shared/c++/CFRGKeyPairType.hpp +86 -0
- package/nitrogen/generated/shared/c++/HybridEdKeyPairSpec.cpp +29 -0
- package/nitrogen/generated/shared/c++/HybridEdKeyPairSpec.hpp +74 -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 +22 -0
- package/nitrogen/generated/shared/c++/HybridRandomSpec.hpp +65 -0
- 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 +57 -51
- package/src/ed.ts +79 -0
- package/src/index.ts +43 -47
- package/src/keys/classes.ts +211 -0
- package/src/keys/generateKeyPair.ts +146 -0
- package/src/keys/index.ts +42 -0
- package/src/keys/signVerify.ts +39 -0
- package/src/keys/utils.ts +184 -0
- package/src/pbkdf2.ts +26 -15
- package/src/random.ts +33 -20
- package/src/specs/edKeyPair.nitro.ts +41 -0
- package/src/specs/keyObjectHandle.nitro.ts +32 -0
- package/src/{NativeQuickCrypto/pbkdf2.ts → specs/pbkdf2.nitro.ts} +8 -6
- package/src/specs/random.nitro.ts +14 -0
- package/src/utils/conversion.ts +123 -0
- package/src/utils/errors.ts +15 -0
- package/src/{Hashnames.ts → utils/hashnames.ts} +4 -7
- package/src/utils/index.ts +5 -0
- package/src/utils/types.ts +275 -0
- package/src/utils/validation.ts +35 -0
- package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoModule.java +0 -70
- package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoPackage.java +0 -25
- package/cpp/Cipher/MGLCipherHostObject.cpp +0 -663
- package/cpp/Cipher/MGLCipherHostObject.h +0 -90
- package/cpp/Cipher/MGLCreateCipherInstaller.cpp +0 -75
- package/cpp/Cipher/MGLCreateCipherInstaller.h +0 -22
- package/cpp/Cipher/MGLCreateDecipherInstaller.cpp +0 -77
- package/cpp/Cipher/MGLCreateDecipherInstaller.h +0 -17
- package/cpp/Cipher/MGLGenerateKeyPairInstaller.cpp +0 -134
- package/cpp/Cipher/MGLGenerateKeyPairInstaller.h +0 -35
- package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.cpp +0 -63
- package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.h +0 -37
- package/cpp/Cipher/MGLPublicCipher.h +0 -124
- package/cpp/Cipher/MGLPublicCipherInstaller.h +0 -107
- package/cpp/Cipher/MGLRsa.cpp +0 -573
- package/cpp/Cipher/MGLRsa.h +0 -109
- package/cpp/HMAC/MGLHmacHostObject.cpp +0 -95
- package/cpp/HMAC/MGLHmacHostObject.h +0 -39
- package/cpp/HMAC/MGLHmacInstaller.cpp +0 -43
- package/cpp/HMAC/MGLHmacInstaller.h +0 -20
- package/cpp/Hash/MGLHashHostObject.cpp +0 -147
- package/cpp/Hash/MGLHashHostObject.h +0 -53
- package/cpp/Hash/MGLHashInstaller.cpp +0 -44
- package/cpp/Hash/MGLHashInstaller.h +0 -20
- package/cpp/JSIUtils/MGLJSIMacros.h +0 -110
- package/cpp/JSIUtils/MGLJSIUtils.h +0 -41
- package/cpp/JSIUtils/MGLSmartHostObject.cpp +0 -43
- package/cpp/JSIUtils/MGLSmartHostObject.h +0 -46
- package/cpp/JSIUtils/MGLThreadAwareHostObject.cpp +0 -24
- package/cpp/JSIUtils/MGLThreadAwareHostObject.h +0 -43
- package/cpp/JSIUtils/MGLTypedArray.cpp +0 -352
- package/cpp/JSIUtils/MGLTypedArray.h +0 -179
- package/cpp/MGLKeys.cpp +0 -1426
- package/cpp/MGLKeys.h +0 -203
- package/cpp/MGLQuickCryptoHostObject.cpp +0 -127
- package/cpp/MGLQuickCryptoHostObject.h +0 -30
- package/cpp/Random/MGLRandomHostObject.cpp +0 -96
- package/cpp/Random/MGLRandomHostObject.h +0 -27
- package/cpp/Sig/MGLSignHostObjects.cpp +0 -757
- package/cpp/Sig/MGLSignHostObjects.h +0 -128
- package/cpp/Sig/MGLSignInstaller.cpp +0 -24
- package/cpp/Sig/MGLSignInstaller.h +0 -29
- package/cpp/Sig/MGLVerifyInstaller.cpp +0 -24
- package/cpp/Sig/MGLVerifyInstaller.h +0 -22
- package/cpp/Utils/MGLDispatchQueue.cpp +0 -75
- package/cpp/Utils/MGLDispatchQueue.h +0 -55
- package/cpp/Utils/MGLUtils.cpp +0 -295
- package/cpp/Utils/MGLUtils.h +0 -358
- package/cpp/Utils/base64.h +0 -320
- package/cpp/Utils/logs.h +0 -38
- package/cpp/Utils/node.h +0 -13
- package/cpp/fastpbkdf2/MGLPbkdf2HostObject.cpp +0 -164
- package/cpp/fastpbkdf2/MGLPbkdf2HostObject.h +0 -29
- package/cpp/webcrypto/MGLWebCrypto.cpp +0 -125
- package/cpp/webcrypto/MGLWebCrypto.h +0 -32
- package/cpp/webcrypto/crypto_aes.cpp +0 -516
- package/cpp/webcrypto/crypto_aes.h +0 -79
- package/cpp/webcrypto/crypto_ec.cpp +0 -424
- package/cpp/webcrypto/crypto_ec.h +0 -78
- package/cpp/webcrypto/crypto_keygen.cpp +0 -86
- package/cpp/webcrypto/crypto_keygen.h +0 -38
- package/ios/QuickCrypto.xcodeproj/project.pbxproj +0 -274
- package/ios/QuickCrypto.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/QuickCrypto.xcodeproj/project.xcworkspace/xcuserdata/brad.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/QuickCrypto.xcodeproj/xcuserdata/brad.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/QuickCryptoModule.h +0 -5
- package/ios/QuickCryptoModule.mm +0 -57
- package/lib/commonjs/Algorithms.js +0 -224
- package/lib/commonjs/Algorithms.js.map +0 -1
- package/lib/commonjs/Cipher.js +0 -504
- package/lib/commonjs/Cipher.js.map +0 -1
- package/lib/commonjs/Hash.js +0 -102
- package/lib/commonjs/Hash.js.map +0 -1
- package/lib/commonjs/Hashnames.js.map +0 -1
- package/lib/commonjs/Hmac.js +0 -81
- package/lib/commonjs/Hmac.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/Cipher.js +0 -30
- package/lib/commonjs/NativeQuickCrypto/Cipher.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js +0 -59
- package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/hash.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/hmac.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/keygen.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/pbkdf2.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/pbkdf2.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/random.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/random.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/sig.js +0 -19
- package/lib/commonjs/NativeQuickCrypto/sig.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/webcrypto.js.map +0 -1
- package/lib/commonjs/Utils.js +0 -437
- package/lib/commonjs/Utils.js.map +0 -1
- package/lib/commonjs/aes.js +0 -282
- package/lib/commonjs/aes.js.map +0 -1
- package/lib/commonjs/constants.js +0 -85
- package/lib/commonjs/constants.js.map +0 -1
- package/lib/commonjs/ec.js +0 -275
- package/lib/commonjs/ec.js.map +0 -1
- package/lib/commonjs/keygen.js +0 -58
- package/lib/commonjs/keygen.js.map +0 -1
- package/lib/commonjs/keys.js +0 -497
- package/lib/commonjs/keys.js.map +0 -1
- package/lib/commonjs/rsa.js +0 -248
- package/lib/commonjs/rsa.js.map +0 -1
- package/lib/commonjs/sig.js +0 -128
- package/lib/commonjs/sig.js.map +0 -1
- package/lib/commonjs/subtle.js +0 -450
- package/lib/commonjs/subtle.js.map +0 -1
- package/lib/commonjs/webcrypto.js +0 -14
- package/lib/commonjs/webcrypto.js.map +0 -1
- package/lib/module/Algorithms.js +0 -219
- package/lib/module/Algorithms.js.map +0 -1
- package/lib/module/Cipher.js +0 -493
- package/lib/module/Cipher.js.map +0 -1
- package/lib/module/Hash.js +0 -96
- package/lib/module/Hash.js.map +0 -1
- package/lib/module/Hashnames.js.map +0 -1
- package/lib/module/Hmac.js +0 -76
- package/lib/module/Hmac.js.map +0 -1
- package/lib/module/NativeQuickCrypto/Cipher.js +0 -26
- package/lib/module/NativeQuickCrypto/Cipher.js.map +0 -1
- package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js +0 -56
- package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js.map +0 -1
- package/lib/module/NativeQuickCrypto/aes.js +0 -4
- package/lib/module/NativeQuickCrypto/hash.js +0 -2
- package/lib/module/NativeQuickCrypto/hash.js.map +0 -1
- package/lib/module/NativeQuickCrypto/hmac.js +0 -2
- package/lib/module/NativeQuickCrypto/hmac.js.map +0 -1
- package/lib/module/NativeQuickCrypto/keygen.js +0 -4
- package/lib/module/NativeQuickCrypto/keygen.js.map +0 -1
- package/lib/module/NativeQuickCrypto/pbkdf2.js +0 -2
- package/lib/module/NativeQuickCrypto/pbkdf2.js.map +0 -1
- package/lib/module/NativeQuickCrypto/random.js +0 -2
- package/lib/module/NativeQuickCrypto/random.js.map +0 -1
- package/lib/module/NativeQuickCrypto/rsa.js +0 -4
- package/lib/module/NativeQuickCrypto/sig.js +0 -17
- package/lib/module/NativeQuickCrypto/sig.js.map +0 -1
- package/lib/module/NativeQuickCrypto/webcrypto.js +0 -4
- package/lib/module/NativeQuickCrypto/webcrypto.js.map +0 -1
- package/lib/module/Utils.js +0 -369
- package/lib/module/Utils.js.map +0 -1
- package/lib/module/aes.js +0 -275
- package/lib/module/aes.js.map +0 -1
- package/lib/module/constants.js +0 -81
- package/lib/module/constants.js.map +0 -1
- package/lib/module/ec.js +0 -266
- package/lib/module/ec.js.map +0 -1
- package/lib/module/keygen.js +0 -51
- package/lib/module/keygen.js.map +0 -1
- package/lib/module/keys.js +0 -482
- package/lib/module/keys.js.map +0 -1
- package/lib/module/rsa.js +0 -242
- package/lib/module/rsa.js.map +0 -1
- package/lib/module/sig.js +0 -123
- package/lib/module/sig.js.map +0 -1
- package/lib/module/subtle.js +0 -445
- package/lib/module/subtle.js.map +0 -1
- package/lib/module/webcrypto.js +0 -10
- package/lib/module/webcrypto.js.map +0 -1
- package/lib/typescript/src/Algorithms.d.ts +0 -4
- package/lib/typescript/src/Algorithms.d.ts.map +0 -1
- package/lib/typescript/src/Cipher.d.ts +0 -85
- package/lib/typescript/src/Cipher.d.ts.map +0 -1
- package/lib/typescript/src/Hash.d.ts +0 -44
- package/lib/typescript/src/Hash.d.ts.map +0 -1
- package/lib/typescript/src/Hashnames.d.ts.map +0 -1
- package/lib/typescript/src/Hmac.d.ts +0 -37
- package/lib/typescript/src/Hmac.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/Cipher.d.ts +0 -44
- package/lib/typescript/src/NativeQuickCrypto/Cipher.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/NativeQuickCrypto.d.ts +0 -33
- package/lib/typescript/src/NativeQuickCrypto/NativeQuickCrypto.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/aes.d.ts +0 -5
- package/lib/typescript/src/NativeQuickCrypto/aes.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/hash.d.ts +0 -7
- package/lib/typescript/src/NativeQuickCrypto/hash.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/hmac.d.ts +0 -6
- package/lib/typescript/src/NativeQuickCrypto/hmac.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/keygen.d.ts +0 -4
- package/lib/typescript/src/NativeQuickCrypto/keygen.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/pbkdf2.d.ts +0 -5
- package/lib/typescript/src/NativeQuickCrypto/pbkdf2.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/random.d.ts +0 -5
- package/lib/typescript/src/NativeQuickCrypto/random.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/rsa.d.ts +0 -5
- package/lib/typescript/src/NativeQuickCrypto/rsa.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/sig.d.ts +0 -23
- package/lib/typescript/src/NativeQuickCrypto/sig.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/webcrypto.d.ts +0 -40
- package/lib/typescript/src/NativeQuickCrypto/webcrypto.d.ts.map +0 -1
- package/lib/typescript/src/Utils.d.ts +0 -71
- package/lib/typescript/src/Utils.d.ts.map +0 -1
- package/lib/typescript/src/aes.d.ts +0 -22
- package/lib/typescript/src/aes.d.ts.map +0 -1
- package/lib/typescript/src/constants.d.ts +0 -76
- package/lib/typescript/src/constants.d.ts.map +0 -1
- package/lib/typescript/src/ec.d.ts +0 -7
- package/lib/typescript/src/ec.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -139
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/keygen.d.ts +0 -6
- package/lib/typescript/src/keygen.d.ts.map +0 -1
- package/lib/typescript/src/keys.d.ts +0 -211
- package/lib/typescript/src/keys.d.ts.map +0 -1
- package/lib/typescript/src/pbkdf2.d.ts.map +0 -1
- package/lib/typescript/src/random.d.ts.map +0 -1
- package/lib/typescript/src/rsa.d.ts +0 -12
- package/lib/typescript/src/rsa.d.ts.map +0 -1
- package/lib/typescript/src/sig.d.ts +0 -21
- package/lib/typescript/src/sig.d.ts.map +0 -1
- package/lib/typescript/src/subtle.d.ts +0 -15
- package/lib/typescript/src/subtle.d.ts.map +0 -1
- package/lib/typescript/src/webcrypto.d.ts +0 -9
- package/lib/typescript/src/webcrypto.d.ts.map +0 -1
- package/react-native-quick-crypto.podspec +0 -40
- package/src/Algorithms.ts +0 -247
- package/src/Cipher.ts +0 -890
- package/src/Hash.ts +0 -139
- package/src/Hmac.ts +0 -107
- package/src/NativeQuickCrypto/Cipher.ts +0 -103
- package/src/NativeQuickCrypto/NativeQuickCrypto.ts +0 -106
- package/src/NativeQuickCrypto/aes.ts +0 -14
- package/src/NativeQuickCrypto/hash.ts +0 -10
- package/src/NativeQuickCrypto/hmac.ts +0 -9
- package/src/NativeQuickCrypto/keygen.ts +0 -7
- package/src/NativeQuickCrypto/random.ts +0 -12
- package/src/NativeQuickCrypto/rsa.ts +0 -12
- package/src/NativeQuickCrypto/sig.ts +0 -46
- package/src/NativeQuickCrypto/webcrypto.ts +0 -73
- package/src/Utils.ts +0 -628
- package/src/aes.ts +0 -402
- package/src/constants.ts +0 -79
- package/src/ec.ts +0 -374
- package/src/keygen.ts +0 -80
- package/src/keys.ts +0 -797
- package/src/rsa.ts +0 -372
- package/src/sig.ts +0 -163
- package/src/subtle.ts +0 -643
- package/src/webcrypto.ts +0 -8
- /package/android/src/main/{AndroidManifestNew.xml → AndroidManifest.xml} +0 -0
- /package/{cpp → deps}/fastpbkdf2/fastpbkdf2.c +0 -0
- /package/{cpp → deps}/fastpbkdf2/fastpbkdf2.h +0 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
export interface Pbkdf2 extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
4
|
+
pbkdf2(
|
|
3
5
|
password: ArrayBuffer,
|
|
4
6
|
salt: ArrayBuffer,
|
|
5
7
|
iterations: number,
|
|
6
8
|
keylen: number,
|
|
7
9
|
digest: string,
|
|
8
|
-
)
|
|
9
|
-
pbkdf2Sync
|
|
10
|
+
): Promise<ArrayBuffer>;
|
|
11
|
+
pbkdf2Sync(
|
|
10
12
|
password: ArrayBuffer,
|
|
11
13
|
salt: ArrayBuffer,
|
|
12
14
|
iterations: number,
|
|
13
15
|
keylen: number,
|
|
14
16
|
digest: string,
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
+
): ArrayBuffer;
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
export interface Random extends HybridObject<{ ios: 'c++'; android: 'c++' }> {
|
|
4
|
+
randomFill(
|
|
5
|
+
buffer: ArrayBuffer,
|
|
6
|
+
offset: number,
|
|
7
|
+
size: number,
|
|
8
|
+
): Promise<ArrayBuffer>;
|
|
9
|
+
randomFillSync(
|
|
10
|
+
buffer: ArrayBuffer,
|
|
11
|
+
offset: number,
|
|
12
|
+
size: number,
|
|
13
|
+
): ArrayBuffer;
|
|
14
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Buffer as CraftzdogBuffer } from '@craftzdog/react-native-buffer';
|
|
2
|
+
import { Buffer as SafeBuffer } from 'safe-buffer';
|
|
3
|
+
import type { ABV, BinaryLikeNode, BufferLike } from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts supplied argument to an ArrayBuffer. Note this does not copy the
|
|
7
|
+
* data so it is faster than toArrayBuffer. Not copying is important for
|
|
8
|
+
* functions like randomFill which need to be able to write to the underlying
|
|
9
|
+
* buffer.
|
|
10
|
+
* @param buf
|
|
11
|
+
* @returns ArrayBuffer
|
|
12
|
+
*/
|
|
13
|
+
export const abvToArrayBuffer = (buf: ABV) => {
|
|
14
|
+
if (CraftzdogBuffer.isBuffer(buf)) {
|
|
15
|
+
return buf.buffer as ArrayBuffer;
|
|
16
|
+
}
|
|
17
|
+
if (ArrayBuffer.isView(buf)) {
|
|
18
|
+
return buf.buffer as ArrayBuffer;
|
|
19
|
+
}
|
|
20
|
+
return buf as ArrayBuffer;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Converts supplied argument to an ArrayBuffer. Note this copies data if the
|
|
25
|
+
* supplied buffer has the .slice() method, so can be a bit slow.
|
|
26
|
+
* @param buf
|
|
27
|
+
* @returns ArrayBuffer
|
|
28
|
+
*/
|
|
29
|
+
export function toArrayBuffer(
|
|
30
|
+
buf: CraftzdogBuffer | SafeBuffer | ArrayBufferView,
|
|
31
|
+
): ArrayBuffer {
|
|
32
|
+
if (CraftzdogBuffer.isBuffer(buf) || ArrayBuffer.isView(buf)) {
|
|
33
|
+
if (buf?.buffer?.slice) {
|
|
34
|
+
return buf.buffer.slice(
|
|
35
|
+
buf.byteOffset,
|
|
36
|
+
buf.byteOffset + buf.byteLength,
|
|
37
|
+
) as ArrayBuffer;
|
|
38
|
+
} else {
|
|
39
|
+
return buf.buffer as ArrayBuffer;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const ab = new ArrayBuffer(buf.length);
|
|
43
|
+
const view = new Uint8Array(ab);
|
|
44
|
+
for (let i = 0; i < buf.length; ++i) {
|
|
45
|
+
view[i] = SafeBuffer.isBuffer(buf) ? buf.readUInt8(i) : buf[i]!;
|
|
46
|
+
}
|
|
47
|
+
return ab;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function bufferLikeToArrayBuffer(buf: BufferLike): ArrayBuffer {
|
|
51
|
+
// Buffer
|
|
52
|
+
if (CraftzdogBuffer.isBuffer(buf) || SafeBuffer.isBuffer(buf)) {
|
|
53
|
+
return toArrayBuffer(buf);
|
|
54
|
+
}
|
|
55
|
+
// ArrayBufferView
|
|
56
|
+
if (ArrayBuffer.isView(buf)) {
|
|
57
|
+
return toArrayBuffer(buf);
|
|
58
|
+
}
|
|
59
|
+
// ArrayBuffer
|
|
60
|
+
return buf;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function binaryLikeToArrayBuffer(
|
|
64
|
+
input: BinaryLikeNode, // CipherKey adds compat with node types
|
|
65
|
+
encoding: string = 'utf-8',
|
|
66
|
+
): ArrayBuffer {
|
|
67
|
+
// string
|
|
68
|
+
if (typeof input === 'string') {
|
|
69
|
+
if (encoding === 'buffer') {
|
|
70
|
+
throw new Error(
|
|
71
|
+
'Cannot create a buffer from a string with a buffer encoding',
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const buffer = CraftzdogBuffer.from(input, encoding);
|
|
76
|
+
|
|
77
|
+
return buffer.buffer.slice(
|
|
78
|
+
buffer.byteOffset,
|
|
79
|
+
buffer.byteOffset + buffer.byteLength,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Buffer
|
|
84
|
+
if (CraftzdogBuffer.isBuffer(input) || SafeBuffer.isBuffer(input)) {
|
|
85
|
+
return toArrayBuffer(input);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ArrayBufferView
|
|
89
|
+
// TODO add further binary types to BinaryLike, UInt8Array and so for have this array as property
|
|
90
|
+
if (ArrayBuffer.isView(input)) {
|
|
91
|
+
return toArrayBuffer(input);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ArrayBuffer
|
|
95
|
+
if (input instanceof ArrayBuffer) {
|
|
96
|
+
return input;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// if (!(input instanceof ArrayBuffer)) {
|
|
100
|
+
// try {
|
|
101
|
+
// // this is a strange fallback case and input is unknown at this point
|
|
102
|
+
// const buffer = Buffer.from(input as unknown as string);
|
|
103
|
+
// return buffer.buffer.slice(
|
|
104
|
+
// buffer.byteOffset,
|
|
105
|
+
// buffer.byteOffset + buffer.byteLength
|
|
106
|
+
// );
|
|
107
|
+
// } catch(e: unknown) {
|
|
108
|
+
// console.log('throwing 1');
|
|
109
|
+
// const err = e as Error;
|
|
110
|
+
// throw new Error(err.message);
|
|
111
|
+
// }
|
|
112
|
+
// }
|
|
113
|
+
|
|
114
|
+
// TODO: handle if input is KeyObject?
|
|
115
|
+
|
|
116
|
+
throw new Error('input could not be converted to ArrayBuffer');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function ab2str(buf: ArrayBuffer, encoding: string = 'hex') {
|
|
120
|
+
return CraftzdogBuffer.from(buf).toString(encoding);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const kEmptyObject = Object.freeze(Object.create(null));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type DOMName =
|
|
2
|
+
| string
|
|
3
|
+
| {
|
|
4
|
+
name: string;
|
|
5
|
+
cause: unknown;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function lazyDOMException(message: string, domName: DOMName): Error {
|
|
9
|
+
let cause = '';
|
|
10
|
+
if (typeof domName !== 'string') {
|
|
11
|
+
cause = `\nCaused by: ${domName.cause}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return new Error(`[${domName}]: ${message}${cause}`);
|
|
15
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HashAlgorithm } from '.';
|
|
2
2
|
|
|
3
3
|
export enum HashContext {
|
|
4
4
|
Node,
|
|
@@ -79,20 +79,17 @@ const kHashNames: HashNames = {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export function normalizeHashName(
|
|
82
|
-
algo: string | HashAlgorithm |
|
|
82
|
+
algo: string | HashAlgorithm | undefined,
|
|
83
83
|
context: HashContext = HashContext.Node,
|
|
84
84
|
): HashAlgorithm {
|
|
85
85
|
if (typeof algo !== 'undefined') {
|
|
86
|
-
if (typeof algo === 'object') {
|
|
87
|
-
algo = algo.name;
|
|
88
|
-
}
|
|
89
86
|
const normAlgo = algo.toString().toLowerCase();
|
|
90
87
|
try {
|
|
91
88
|
const alias = kHashNames[normAlgo]![context] as HashAlgorithm;
|
|
92
89
|
if (alias) return alias;
|
|
93
90
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
94
|
-
} catch (_e
|
|
95
|
-
|
|
91
|
+
} catch (_e) {
|
|
92
|
+
// ignore
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
95
|
throw new Error(`Invalid Hash Algorithm: ${algo}`);
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import type { Buffer as CraftzdogBuffer } from '@craftzdog/react-native-buffer';
|
|
2
|
+
import type { Buffer as SafeBuffer } from 'safe-buffer';
|
|
3
|
+
import type { CipherKey } from 'crypto'; // @types/node
|
|
4
|
+
import type { KeyObjectHandle } from '../specs/keyObjectHandle.nitro';
|
|
5
|
+
|
|
6
|
+
export type ABV = TypedArray | DataView | ArrayBufferLike | CraftzdogBuffer;
|
|
7
|
+
|
|
8
|
+
export type TypedArray =
|
|
9
|
+
| Uint8Array
|
|
10
|
+
| Uint8ClampedArray
|
|
11
|
+
| Uint16Array
|
|
12
|
+
| Uint32Array
|
|
13
|
+
| Int8Array
|
|
14
|
+
| Int16Array
|
|
15
|
+
| Int32Array
|
|
16
|
+
| Float32Array
|
|
17
|
+
| Float64Array;
|
|
18
|
+
|
|
19
|
+
export type RandomCallback<T> = (err: Error | null, value: T) => void;
|
|
20
|
+
|
|
21
|
+
export type BufferLike =
|
|
22
|
+
| ArrayBuffer
|
|
23
|
+
| CraftzdogBuffer
|
|
24
|
+
| SafeBuffer
|
|
25
|
+
| ArrayBufferView;
|
|
26
|
+
|
|
27
|
+
export type BinaryLike =
|
|
28
|
+
| string
|
|
29
|
+
| ArrayBuffer
|
|
30
|
+
| CraftzdogBuffer
|
|
31
|
+
| SafeBuffer
|
|
32
|
+
| TypedArray
|
|
33
|
+
| DataView;
|
|
34
|
+
|
|
35
|
+
export type BinaryLikeNode = CipherKey | BinaryLike;
|
|
36
|
+
|
|
37
|
+
export type DigestAlgorithm = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
38
|
+
|
|
39
|
+
export type HashAlgorithm = DigestAlgorithm | 'SHA-224' | 'RIPEMD-160';
|
|
40
|
+
|
|
41
|
+
export type RSAKeyPairAlgorithm = 'RSASSA-PKCS1-v1_5' | 'RSA-PSS' | 'RSA-OAEP';
|
|
42
|
+
|
|
43
|
+
export type ECKeyPairAlgorithm = 'ECDSA' | 'ECDH';
|
|
44
|
+
|
|
45
|
+
export type CFRGKeyPairAlgorithm = 'Ed25519' | 'Ed448' | 'X25519' | 'X448';
|
|
46
|
+
export type CFRGKeyPairType = 'ed25519' | 'ed448' | 'x25519' | 'x448';
|
|
47
|
+
|
|
48
|
+
export type KeyPairAlgorithm =
|
|
49
|
+
| RSAKeyPairAlgorithm
|
|
50
|
+
| ECKeyPairAlgorithm
|
|
51
|
+
| CFRGKeyPairAlgorithm;
|
|
52
|
+
|
|
53
|
+
export type AESAlgorithm = 'AES-CTR' | 'AES-CBC' | 'AES-GCM' | 'AES-KW';
|
|
54
|
+
|
|
55
|
+
export type SecretKeyAlgorithm = 'HMAC' | AESAlgorithm;
|
|
56
|
+
|
|
57
|
+
export type SignVerifyAlgorithm =
|
|
58
|
+
| 'RSASSA-PKCS1-v1_5'
|
|
59
|
+
| 'RSA-PSS'
|
|
60
|
+
| 'ECDSA'
|
|
61
|
+
| 'HMAC'
|
|
62
|
+
| 'Ed25519'
|
|
63
|
+
| 'Ed448';
|
|
64
|
+
|
|
65
|
+
export type DeriveBitsAlgorithm =
|
|
66
|
+
| 'PBKDF2'
|
|
67
|
+
| 'HKDF'
|
|
68
|
+
| 'ECDH'
|
|
69
|
+
| 'X25519'
|
|
70
|
+
| 'X448';
|
|
71
|
+
|
|
72
|
+
export type EncryptDecryptAlgorithm =
|
|
73
|
+
| 'RSA-OAEP'
|
|
74
|
+
| 'AES-CTR'
|
|
75
|
+
| 'AES-CBC'
|
|
76
|
+
| 'AES-GCM';
|
|
77
|
+
|
|
78
|
+
export type AnyAlgorithm =
|
|
79
|
+
| DigestAlgorithm
|
|
80
|
+
| HashAlgorithm
|
|
81
|
+
| KeyPairAlgorithm
|
|
82
|
+
| SecretKeyAlgorithm
|
|
83
|
+
| SignVerifyAlgorithm
|
|
84
|
+
| DeriveBitsAlgorithm
|
|
85
|
+
| EncryptDecryptAlgorithm
|
|
86
|
+
| AESAlgorithm
|
|
87
|
+
| 'PBKDF2'
|
|
88
|
+
| 'HKDF'
|
|
89
|
+
| 'unknown';
|
|
90
|
+
|
|
91
|
+
export type NamedCurve = 'P-256' | 'P-384' | 'P-521';
|
|
92
|
+
|
|
93
|
+
export type SubtleAlgorithm = {
|
|
94
|
+
name: AnyAlgorithm;
|
|
95
|
+
salt?: string;
|
|
96
|
+
iterations?: number;
|
|
97
|
+
hash?: HashAlgorithm;
|
|
98
|
+
namedCurve?: NamedCurve;
|
|
99
|
+
length?: number;
|
|
100
|
+
modulusLength?: number;
|
|
101
|
+
publicExponent?: number | Uint8Array;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type KeyPairType = CFRGKeyPairType;
|
|
105
|
+
|
|
106
|
+
export type KeyUsage =
|
|
107
|
+
| 'encrypt'
|
|
108
|
+
| 'decrypt'
|
|
109
|
+
| 'sign'
|
|
110
|
+
| 'verify'
|
|
111
|
+
| 'deriveKey'
|
|
112
|
+
| 'deriveBits'
|
|
113
|
+
| 'wrapKey'
|
|
114
|
+
| 'unwrapKey';
|
|
115
|
+
|
|
116
|
+
// On node this value is defined on the native side, for now I'm just creating it here in JS
|
|
117
|
+
// TODO(osp) move this into native side to make sure they always match
|
|
118
|
+
export enum KFormatType {
|
|
119
|
+
kKeyFormatDER,
|
|
120
|
+
kKeyFormatPEM,
|
|
121
|
+
kKeyFormatJWK,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Same as KFormatType, this enum needs to be defined on the native side
|
|
125
|
+
export enum KeyType {
|
|
126
|
+
Secret,
|
|
127
|
+
Public,
|
|
128
|
+
Private,
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export enum KeyEncoding {
|
|
132
|
+
kKeyEncodingPKCS1,
|
|
133
|
+
kKeyEncodingPKCS8,
|
|
134
|
+
kKeyEncodingSPKI,
|
|
135
|
+
kKeyEncodingSEC1,
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export type KeyPairGenConfig = {
|
|
139
|
+
publicFormat?: KFormatType;
|
|
140
|
+
publicType?: KeyEncoding;
|
|
141
|
+
privateFormat?: KFormatType;
|
|
142
|
+
privateType?: KeyEncoding;
|
|
143
|
+
cipher?: string;
|
|
144
|
+
passphrase?: ArrayBuffer;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export type AsymmetricKeyType =
|
|
148
|
+
// 'rsa' |
|
|
149
|
+
// 'rsa-pss' |
|
|
150
|
+
// 'dsa' |
|
|
151
|
+
// 'ec' |
|
|
152
|
+
// 'dh' |
|
|
153
|
+
CFRGKeyPairType;
|
|
154
|
+
|
|
155
|
+
type JWKkty = 'AES' | 'RSA' | 'EC' | 'oct';
|
|
156
|
+
type JWKuse = 'sig' | 'enc';
|
|
157
|
+
|
|
158
|
+
export interface JWK {
|
|
159
|
+
kty?: JWKkty;
|
|
160
|
+
use?: JWKuse;
|
|
161
|
+
key_ops?: KeyUsage[];
|
|
162
|
+
alg?: string; // TODO: enumerate these (RFC-7517)
|
|
163
|
+
crv?: string;
|
|
164
|
+
kid?: string;
|
|
165
|
+
x5u?: string;
|
|
166
|
+
x5c?: string[];
|
|
167
|
+
x5t?: string;
|
|
168
|
+
'x5t#256'?: string;
|
|
169
|
+
n?: string;
|
|
170
|
+
e?: string;
|
|
171
|
+
d?: string;
|
|
172
|
+
p?: string;
|
|
173
|
+
q?: string;
|
|
174
|
+
x?: string;
|
|
175
|
+
y?: string;
|
|
176
|
+
k?: string;
|
|
177
|
+
dp?: string;
|
|
178
|
+
dq?: string;
|
|
179
|
+
qi?: string;
|
|
180
|
+
ext?: boolean;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export type KTypePrivate = 'pkcs1' | 'pkcs8' | 'sec1';
|
|
184
|
+
export type KTypePublic = 'pkcs1' | 'spki';
|
|
185
|
+
export type KType = KTypePrivate | KTypePublic;
|
|
186
|
+
|
|
187
|
+
export type KFormat = 'der' | 'pem' | 'jwk';
|
|
188
|
+
|
|
189
|
+
export type DSAEncoding = 'der' | 'ieee-p1363';
|
|
190
|
+
|
|
191
|
+
export type EncodingOptions = {
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
193
|
+
key?: any;
|
|
194
|
+
type?: KType;
|
|
195
|
+
encoding?: string;
|
|
196
|
+
dsaEncoding?: DSAEncoding;
|
|
197
|
+
format?: KFormat;
|
|
198
|
+
padding?: number;
|
|
199
|
+
cipher?: string;
|
|
200
|
+
passphrase?: BinaryLike;
|
|
201
|
+
saltLength?: number;
|
|
202
|
+
oaepHash?: string;
|
|
203
|
+
oaepLabel?: BinaryLike;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export interface KeyDetail {
|
|
207
|
+
length?: number;
|
|
208
|
+
publicExponent?: number;
|
|
209
|
+
modulusLength?: number;
|
|
210
|
+
hashAlgorithm?: string;
|
|
211
|
+
mgf1HashAlgorithm?: string;
|
|
212
|
+
saltLength?: number;
|
|
213
|
+
namedCurve?: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export type GenerateKeyPairOptions = {
|
|
217
|
+
modulusLength?: number; // Key size in bits (RSA, DSA).
|
|
218
|
+
publicExponent?: number; // Public exponent (RSA). Default: 0x10001.
|
|
219
|
+
hashAlgorithm?: string; // Name of the message digest (RSA-PSS).
|
|
220
|
+
mgf1HashAlgorithm?: string; // string Name of the message digest used by MGF1 (RSA-PSS).
|
|
221
|
+
saltLength?: number; // Minimal salt length in bytes (RSA-PSS).
|
|
222
|
+
divisorLength?: number; // Size of q in bits (DSA).
|
|
223
|
+
namedCurve?: string; // Name of the curve to use (EC).
|
|
224
|
+
prime?: CraftzdogBuffer; // The prime parameter (DH).
|
|
225
|
+
primeLength?: number; // Prime length in bits (DH).
|
|
226
|
+
generator?: number; // Custom generator (DH). Default: 2.
|
|
227
|
+
groupName?: string; // Diffie-Hellman group name (DH). See crypto.getDiffieHellman().
|
|
228
|
+
publicKeyEncoding?: EncodingOptions; // See keyObject.export().
|
|
229
|
+
privateKeyEncoding?: EncodingOptions; // See keyObject.export().
|
|
230
|
+
paramEncoding?: string;
|
|
231
|
+
hash?: string;
|
|
232
|
+
mgf1Hash?: string;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// Note: removed CryptoKey class from this type (from 0.x) because Nitro doesn't
|
|
236
|
+
// handle custom JS objects. We might need to make it a JS object.
|
|
237
|
+
export type KeyPairKey = ArrayBuffer | KeyObjectHandle | undefined;
|
|
238
|
+
|
|
239
|
+
export type GenerateKeyPairReturn = [
|
|
240
|
+
error?: Error,
|
|
241
|
+
privateKey?: KeyPairKey,
|
|
242
|
+
publicKey?: KeyPairKey,
|
|
243
|
+
];
|
|
244
|
+
|
|
245
|
+
export type GenerateKeyPairCallback = (
|
|
246
|
+
error?: Error,
|
|
247
|
+
publicKey?: KeyPairKey,
|
|
248
|
+
privateKey?: KeyPairKey,
|
|
249
|
+
) => GenerateKeyPairReturn | void;
|
|
250
|
+
|
|
251
|
+
export type KeyPair = {
|
|
252
|
+
publicKey?: KeyPairKey;
|
|
253
|
+
privateKey?: KeyPairKey;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
export type GenerateKeyPairPromiseReturn = [error?: Error, keypair?: KeyPair];
|
|
257
|
+
|
|
258
|
+
export type CryptoKeyPair = {
|
|
259
|
+
publicKey: KeyPairKey;
|
|
260
|
+
privateKey: KeyPairKey;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
export enum KeyVariant {
|
|
264
|
+
RSA_SSA_PKCS1_v1_5,
|
|
265
|
+
RSA_PSS,
|
|
266
|
+
RSA_OAEP,
|
|
267
|
+
DSA,
|
|
268
|
+
EC,
|
|
269
|
+
NID,
|
|
270
|
+
DH,
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export type SignCallback = (err: Error | null, signature?: ArrayBuffer) => void;
|
|
274
|
+
|
|
275
|
+
export type VerifyCallback = (err: Error | null, valid?: boolean) => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function validateFunction(f: unknown): boolean {
|
|
2
|
+
return f !== null && typeof f === 'function';
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function isStringOrBuffer(val: unknown): val is string | ArrayBuffer {
|
|
6
|
+
return (
|
|
7
|
+
typeof val === 'string' ||
|
|
8
|
+
ArrayBuffer.isView(val) ||
|
|
9
|
+
val instanceof ArrayBuffer
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function validateObject<T>(
|
|
14
|
+
value: unknown,
|
|
15
|
+
name: string,
|
|
16
|
+
options?: {
|
|
17
|
+
allowArray: boolean;
|
|
18
|
+
allowFunction: boolean;
|
|
19
|
+
nullable: boolean;
|
|
20
|
+
} | null,
|
|
21
|
+
): value is T {
|
|
22
|
+
const useDefaultOptions = options == null;
|
|
23
|
+
const allowArray = useDefaultOptions ? false : options.allowArray;
|
|
24
|
+
const allowFunction = useDefaultOptions ? false : options.allowFunction;
|
|
25
|
+
const nullable = useDefaultOptions ? false : options.nullable;
|
|
26
|
+
if (
|
|
27
|
+
(!nullable && value === null) ||
|
|
28
|
+
(!allowArray && Array.isArray(value)) ||
|
|
29
|
+
(typeof value !== 'object' &&
|
|
30
|
+
(!allowFunction || typeof value !== 'function'))
|
|
31
|
+
) {
|
|
32
|
+
throw new Error(`${name} is not a valid object $${value}`);
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
package com.margelo.quickcrypto;
|
|
2
|
-
|
|
3
|
-
import android.util.Log;
|
|
4
|
-
|
|
5
|
-
import androidx.annotation.NonNull;
|
|
6
|
-
|
|
7
|
-
import com.facebook.jni.HybridData;
|
|
8
|
-
import com.facebook.proguard.annotations.DoNotStrip;
|
|
9
|
-
import com.facebook.react.bridge.JavaScriptContextHolder;
|
|
10
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
13
|
-
import com.facebook.react.module.annotations.ReactModule;
|
|
14
|
-
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
|
|
15
|
-
|
|
16
|
-
@ReactModule(name = QuickCryptoModule.NAME)
|
|
17
|
-
public class QuickCryptoModule extends ReactContextBaseJavaModule {
|
|
18
|
-
public static final String NAME = "QuickCrypto";
|
|
19
|
-
|
|
20
|
-
@DoNotStrip
|
|
21
|
-
private HybridData mHybridData;
|
|
22
|
-
|
|
23
|
-
private native HybridData initHybrid();
|
|
24
|
-
|
|
25
|
-
public QuickCryptoModule(ReactApplicationContext reactContext) {
|
|
26
|
-
super(reactContext);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@NonNull
|
|
30
|
-
@Override
|
|
31
|
-
public String getName() {
|
|
32
|
-
return NAME;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
36
|
-
public boolean install() {
|
|
37
|
-
try {
|
|
38
|
-
if (mHybridData != null) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
Log.i(NAME, "Loading C++ library...");
|
|
42
|
-
System.loadLibrary("reactnativequickcrypto");
|
|
43
|
-
|
|
44
|
-
JavaScriptContextHolder jsContext = getReactApplicationContext().getJavaScriptContextHolder();
|
|
45
|
-
CallInvokerHolderImpl jsCallInvokerHolder = (CallInvokerHolderImpl) getReactApplicationContext()
|
|
46
|
-
.getCatalystInstance()
|
|
47
|
-
.getJSCallInvokerHolder();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Log.i(NAME, "Installing JSI Bindings for react-native-quick-crypto...");
|
|
51
|
-
mHybridData = initHybrid();
|
|
52
|
-
nativeInstall(jsContext.get(), jsCallInvokerHolder);
|
|
53
|
-
Log.i(NAME, "Successfully installed JSI Bindings for react-native-quick-crypto!");
|
|
54
|
-
|
|
55
|
-
return true;
|
|
56
|
-
} catch (Exception exception) {
|
|
57
|
-
Log.e(NAME, "Failed to install JSI Bindings for react-native-quick-crypto!", exception);
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public void destroy() {
|
|
63
|
-
if (mHybridData == null) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
mHybridData.resetNative();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private native void nativeInstall(long jsiPtr, CallInvokerHolderImpl jsCallInvokerHolder);
|
|
70
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package com.margelo.quickcrypto;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.ReactPackage;
|
|
6
|
-
import com.facebook.react.bridge.NativeModule;
|
|
7
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
-
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
-
|
|
10
|
-
import java.util.Collections;
|
|
11
|
-
import java.util.List;
|
|
12
|
-
|
|
13
|
-
public class QuickCryptoPackage implements ReactPackage {
|
|
14
|
-
@NonNull
|
|
15
|
-
@Override
|
|
16
|
-
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
17
|
-
return Collections.singletonList(new QuickCryptoModule(reactContext));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@NonNull
|
|
21
|
-
@Override
|
|
22
|
-
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
23
|
-
return Collections.emptyList();
|
|
24
|
-
}
|
|
25
|
-
}
|