@onekeyfe/react-native-lite-card 6.7.0-20 → 6.7.0-22
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 +9 -1
- package/ReactNativeLiteCard.podspec +25 -2
- package/android/build.gradle +7 -0
- package/android/src/main/cpp/CMakeLists.txt +6 -2
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/ReactNativeLiteCardModule.kt +29 -11
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/gpchannel/GPChannelNatives.kt +7 -7
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/OnekeyLiteCard.kt +14 -3
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/SendResponse.kt +6 -3
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/CommandGenerator.kt +5 -1
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/Connection.kt +36 -17
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/GPCAPDUGenerator.kt +2 -2
- package/ios/Classes/OKLiteCommand/OKLiteCommandTool.m +4 -1
- package/ios/Classes/OKNFCBridge.mm +1 -1
- package/ios/Classes/OKNFTLite/OKLiteV1.m +6 -3
- package/ios/Classes/OKNFTLite/OKLiteV2.m +13 -5
- package/ios/Classes/OKNFTLite/OKNFCManager.m +26 -6
- package/ios/ReactNativeLiteCard.mm +16 -7
- package/package.json +8 -8
- package/sdk/CMakeLists.txt +120 -0
- package/sdk/README.md +175 -0
- package/sdk/android/implJni.cpp +177 -0
- package/sdk/deps/jsoncpp/LICENSE +55 -0
- package/sdk/deps/jsoncpp/include/CMakeLists.txt +2 -0
- package/sdk/deps/jsoncpp/include/json/allocator.h +98 -0
- package/sdk/deps/jsoncpp/include/json/assertions.h +54 -0
- package/sdk/deps/jsoncpp/include/json/autolink.h +25 -0
- package/sdk/deps/jsoncpp/include/json/config.h +187 -0
- package/sdk/deps/jsoncpp/include/json/features.h +61 -0
- package/sdk/deps/jsoncpp/include/json/forwards.h +37 -0
- package/sdk/deps/jsoncpp/include/json/json.h +15 -0
- package/sdk/deps/jsoncpp/include/json/reader.h +411 -0
- package/sdk/deps/jsoncpp/include/json/value.h +888 -0
- package/sdk/deps/jsoncpp/include/json/version.h +20 -0
- package/sdk/deps/jsoncpp/include/json/writer.h +357 -0
- package/sdk/deps/jsoncpp/src/lib_json/CMakeLists.txt +117 -0
- package/sdk/deps/jsoncpp/src/lib_json/json_reader.cpp +2060 -0
- package/sdk/deps/jsoncpp/src/lib_json/json_tool.h +114 -0
- package/sdk/deps/jsoncpp/src/lib_json/json_value.cpp +1661 -0
- package/sdk/deps/jsoncpp/src/lib_json/json_valueiterator.inl +167 -0
- package/sdk/deps/jsoncpp/src/lib_json/json_writer.cpp +1233 -0
- package/sdk/deps/jsoncpp/src/lib_json/version.h.in +20 -0
- package/sdk/deps/trezor-crypto/AUTHORS +2 -0
- package/sdk/deps/trezor-crypto/LICENSE +22 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/TrezorCrypto.h +29 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/address.h +44 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/aes.h +224 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/base32.h +49 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/base58.h +58 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/bignum.h +169 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/bip32.h +114 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/bip39.h +66 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake256.h +61 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake2b.h +50 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake2s.h +49 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/cash_addr.h +109 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-config.h +316 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-sync.h +289 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-types.h +53 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/poly1305-donna.h +28 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305.h +27 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/cmac.h +44 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/curves.h +60 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ecdsa.h +112 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/curve25519-donna-32bit.h +87 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/curve25519-donna-helpers.h +30 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-blake2b.h +21 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-32bit-tables.h +25 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-basepoint-table.h +10 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-impl-base.h +110 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-portable.h +32 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna.h +60 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-keccak.h +21 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-sha3.h +21 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/modm-donna-32bit.h +87 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna.h +60 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519.h +42 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/endian.h +132 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/groestl.h +104 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/hasher.h +90 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/hmac.h +60 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/memzero.h +16 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/base58.h +42 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/monero.h +13 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/range_proof.h +30 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/serialize.h +15 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/xmr.h +67 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/nano.h +56 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/nem.h +199 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/nist256p1.h +35 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/pbkdf2.h +64 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/rand.h +44 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/rc4.h +37 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/rfc6979.h +40 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ripemd160.h +28 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/ripple/base58.h +45 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/schnorr.h +48 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/script.h +30 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/scrypt.h +68 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/secp256k1.h +59 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sha2.h +125 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sha3.h +86 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/keypair.h +20 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/ed25519_ref10.h +85 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/ed25519_ref10_fe_25_5.h +43 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/fe_25_5/constants.h +29 -0
- package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/fe_25_5/fe.h +25 -0
- package/sdk/deps/trezor-crypto/src/address.c +87 -0
- package/sdk/deps/trezor-crypto/src/aes/aes_modes.c +959 -0
- package/sdk/deps/trezor-crypto/src/aes/aescrypt.c +307 -0
- package/sdk/deps/trezor-crypto/src/aes/aeskey.c +560 -0
- package/sdk/deps/trezor-crypto/src/aes/aesopt.h +784 -0
- package/sdk/deps/trezor-crypto/src/aes/aestab.c +418 -0
- package/sdk/deps/trezor-crypto/src/aes/aestab.h +173 -0
- package/sdk/deps/trezor-crypto/src/base32.c +233 -0
- package/sdk/deps/trezor-crypto/src/base58.c +298 -0
- package/sdk/deps/trezor-crypto/src/bignum.c +808 -0
- package/sdk/deps/trezor-crypto/src/bip32.c +852 -0
- package/sdk/deps/trezor-crypto/src/bip39.c +266 -0
- package/sdk/deps/trezor-crypto/src/bip39_english.h +2074 -0
- package/sdk/deps/trezor-crypto/src/blake256.c +235 -0
- package/sdk/deps/trezor-crypto/src/blake2_common.h +39 -0
- package/sdk/deps/trezor-crypto/src/blake2b.c +333 -0
- package/sdk/deps/trezor-crypto/src/blake2s.c +318 -0
- package/sdk/deps/trezor-crypto/src/cash_addr.c +195 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/chacha20poly1305.c +60 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/chacha_merged.c +246 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/ecrypt-machine.h +49 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/ecrypt-portable.h +275 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/poly1305-donna-32.h +219 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/poly1305-donna.c +179 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/rfc7539.c +48 -0
- package/sdk/deps/trezor-crypto/src/chacha20poly1305/rfc7539.h +10 -0
- package/sdk/deps/trezor-crypto/src/check_mem.h +30 -0
- package/sdk/deps/trezor-crypto/src/cmac.c +342 -0
- package/sdk/deps/trezor-crypto/src/curves.c +48 -0
- package/sdk/deps/trezor-crypto/src/ecdsa.c +1355 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/README.md +183 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-32bit.c +681 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-helpers.c +66 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-scalarmult-base.c +67 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-scalarmult-base.h +8 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-blake2b.c +8 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-32bit-tables.c +63 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-basepoint-table.c +261 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-impl-base.c +722 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-blake2b.h +23 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-keccak.h +23 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-sha3.h +23 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom.h +23 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-keccak.c +8 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-sha3.c +8 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519.c +311 -0
- package/sdk/deps/trezor-crypto/src/ed25519-donna/modm-donna-32bit.c +517 -0
- package/sdk/deps/trezor-crypto/src/groestl.c +783 -0
- package/sdk/deps/trezor-crypto/src/groestl_internal.h +419 -0
- package/sdk/deps/trezor-crypto/src/hasher.c +186 -0
- package/sdk/deps/trezor-crypto/src/hmac.c +179 -0
- package/sdk/deps/trezor-crypto/src/memzero.c +6 -0
- package/sdk/deps/trezor-crypto/src/monero/base58.c +245 -0
- package/sdk/deps/trezor-crypto/src/monero/int-util.h +77 -0
- package/sdk/deps/trezor-crypto/src/monero/range_proof.c +115 -0
- package/sdk/deps/trezor-crypto/src/monero/serialize.c +54 -0
- package/sdk/deps/trezor-crypto/src/monero/xmr.c +136 -0
- package/sdk/deps/trezor-crypto/src/nano.c +151 -0
- package/sdk/deps/trezor-crypto/src/nem.c +569 -0
- package/sdk/deps/trezor-crypto/src/nist256p1.c +63 -0
- package/sdk/deps/trezor-crypto/src/nist256p1.table +1664 -0
- package/sdk/deps/trezor-crypto/src/options.h +43 -0
- package/sdk/deps/trezor-crypto/src/pbkdf2.c +177 -0
- package/sdk/deps/trezor-crypto/src/rand.c +51 -0
- package/sdk/deps/trezor-crypto/src/rc4.c +56 -0
- package/sdk/deps/trezor-crypto/src/ripemd160.c +343 -0
- package/sdk/deps/trezor-crypto/src/ripple/base58.c +76 -0
- package/sdk/deps/trezor-crypto/src/schnorr.c +208 -0
- package/sdk/deps/trezor-crypto/src/script.c +64 -0
- package/sdk/deps/trezor-crypto/src/scrypt.c +343 -0
- package/sdk/deps/trezor-crypto/src/secp256k1.c +160 -0
- package/sdk/deps/trezor-crypto/src/secp256k1.table +1664 -0
- package/sdk/deps/trezor-crypto/src/setup.py +38 -0
- package/sdk/deps/trezor-crypto/src/sha2.c +1314 -0
- package/sdk/deps/trezor-crypto/src/sha3.c +395 -0
- package/sdk/deps/trezor-crypto/src/shell.nix +6 -0
- package/sdk/deps/trezor-crypto/src/sodium/keypair.c +63 -0
- package/sdk/deps/trezor-crypto/src/sodium/private/ed25519_ref10.c +481 -0
- package/sdk/deps/trezor-crypto/src/sodium/private/ed25519_ref10_fe_25_5.c +885 -0
- package/sdk/deps/trezor-crypto/src/sodium/private/fe_25_5/fe.c +237 -0
- package/sdk/gpc/include/scp03/scp03.hpp +80 -0
- package/sdk/gpc/include/scp11/scp11.hpp +492 -0
- package/sdk/gpc/include/scp11/scp11c.hpp +58 -0
- package/sdk/gpc/include/tag.h +68 -0
- package/sdk/gpc/include/tlv.hpp +94 -0
- package/sdk/gpc/include/tlvparse.hpp +24 -0
- package/sdk/gpc/src/scp03.cpp +243 -0
- package/sdk/gpc/src/scp11.cpp +798 -0
- package/sdk/gpc/src/scp11c.cpp +136 -0
- package/sdk/gpc/src/tlv.cpp +159 -0
- package/sdk/gpc/src/tlvparse.c +174 -0
- package/{framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers → sdk/include}/GPChannelSDK.h +0 -0
- package/sdk/include/GPChannelSDKCore.h +10 -0
- package/sdk/include/context/BaseContext.h +56 -0
- package/sdk/include/device/ApduBuilder.hpp +72 -0
- package/sdk/include/mSIGNA/stdutils/uchar_vector.h +36 -0
- package/sdk/include/utility/Apdu.hpp +172 -0
- package/sdk/include/utility/Debug.hpp +3 -0
- package/sdk/include/utility/util.h +104 -0
- package/sdk/src/ApduBuilder.cpp +332 -0
- package/sdk/src/GPChannelSDK.cpp +252 -0
- package/sdk/src/random.c +25 -0
- package/sdk/src/version.c +2 -0
- package/sdk/tests/android/GPChannelProxy.java +55 -0
- package/sdk/tests/android_verify.py +121 -0
- package/sdk/tests/safety.cpp +603 -0
- package/sdk/tests/verify.py +267 -0
- package/android/src/main/jniLibs/arm64-v8a/libgpchannelNDK.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libgpchannelNDK.so +0 -0
- package/framework/GPChannelSDKCore.xcframework/Info.plist +0 -52
- package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
- package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +0 -19
- package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Info.plist +0 -0
- package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Modules/module.modulemap +0 -7
- package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/_CodeSignature/CodeResources +0 -147
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDK.h +0 -315
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +0 -19
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Info.plist +0 -0
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Modules/module.modulemap +0 -7
- package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/_CodeSignature/CodeResources +0 -147
package/README.md
CHANGED
|
@@ -5,6 +5,13 @@ wraps native callbacks in promises for card inspection, PIN changes, mnemonic
|
|
|
5
5
|
backup/retrieval and reset. It also exposes native NFC connection UI events.
|
|
6
6
|
The application owns the user flow and handling sensitive card data.
|
|
7
7
|
|
|
8
|
+
## Native SDK source recovery
|
|
9
|
+
|
|
10
|
+
The restored GPChannel source is in [sdk/](sdk/README.md). CocoaPods compiles it
|
|
11
|
+
on iOS, and Android's CMake build produces the JNI library from the same source.
|
|
12
|
+
No precompiled GPChannel framework or JNI library is included. See
|
|
13
|
+
[docs/SPEC.md](docs/SPEC.md) for the native ownership and recovery contract.
|
|
14
|
+
|
|
8
15
|
## Installation
|
|
9
16
|
|
|
10
17
|
```sh
|
|
@@ -63,4 +70,5 @@ Keep mnemonic and PIN values out of diagnostic messages and event logs.
|
|
|
63
70
|
|
|
64
71
|
## License
|
|
65
72
|
|
|
66
|
-
MIT.
|
|
73
|
+
The React Native wrapper is MIT licensed. Vendored SDK sources retain their
|
|
74
|
+
upstream notices and are not relicensed by the wrapper.
|
|
@@ -13,9 +13,32 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.platforms = { :ios => min_ios_version_supported }
|
|
14
14
|
s.source = { :git => "https://github.com/OneKeyHQ/app-modules/onekeyfe-react-native-lite-card.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
trezor_sources = %w[
|
|
17
|
+
bignum ecdsa curves secp256k1 hmac bip32 bip39 pbkdf2 base58 base32 address
|
|
18
|
+
script ripemd160 sha2 sha3 hasher aes/aescrypt aes/aeskey aes/aestab
|
|
19
|
+
aes/aes_modes ed25519-donna/curve25519-donna-32bit
|
|
20
|
+
ed25519-donna/curve25519-donna-helpers ed25519-donna/modm-donna-32bit
|
|
21
|
+
ed25519-donna/ed25519-donna-basepoint-table
|
|
22
|
+
ed25519-donna/ed25519-donna-32bit-tables ed25519-donna/ed25519-donna-impl-base
|
|
23
|
+
ed25519-donna/ed25519 ed25519-donna/curve25519-donna-scalarmult-base
|
|
24
|
+
ed25519-donna/ed25519-sha3 ed25519-donna/ed25519-keccak
|
|
25
|
+
ed25519-donna/ed25519-blake2b sodium/private/fe_25_5/fe
|
|
26
|
+
sodium/private/ed25519_ref10 sodium/private/ed25519_ref10_fe_25_5
|
|
27
|
+
sodium/keypair monero/base58 monero/serialize monero/xmr monero/range_proof
|
|
28
|
+
blake256 blake2b blake2s chacha20poly1305/chacha20poly1305
|
|
29
|
+
chacha20poly1305/chacha_merged chacha20poly1305/poly1305-donna
|
|
30
|
+
chacha20poly1305/rfc7539 rc4 nano nem cash_addr memzero scrypt
|
|
31
|
+
ripple/base58 nist256p1 groestl schnorr cmac
|
|
32
|
+
].map { |name| "sdk/deps/trezor-crypto/src/#{name}.c" }
|
|
33
|
+
|
|
34
|
+
s.source_files = "ios/**/*.{h,m,mm,swift,cpp}", "keys/**/*.{h,c,m,mm,swift,cpp}",
|
|
35
|
+
"sdk/src/*.{c,cpp}", "sdk/gpc/src/*.cpp", *trezor_sources
|
|
18
36
|
s.private_header_files = "ios/**/*.h"
|
|
37
|
+
s.preserve_paths = "sdk/**/*"
|
|
38
|
+
s.libraries = "c++"
|
|
39
|
+
s.pod_target_xcconfig = {
|
|
40
|
+
"HEADER_SEARCH_PATHS" => '$(inherited) "$(PODS_TARGET_SRCROOT)/sdk/include" "$(PODS_TARGET_SRCROOT)/sdk/gpc/include" "$(PODS_TARGET_SRCROOT)/sdk/deps/trezor-crypto/include" "$(PODS_TARGET_SRCROOT)/sdk/deps/trezor-crypto/src"'
|
|
41
|
+
}
|
|
19
42
|
|
|
20
43
|
|
|
21
44
|
s.dependency 'ReactNativeNativeLogger'
|
package/android/build.gradle
CHANGED
|
@@ -39,6 +39,13 @@ android {
|
|
|
39
39
|
defaultConfig {
|
|
40
40
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
41
41
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
42
|
+
|
|
43
|
+
externalNativeBuild {
|
|
44
|
+
cmake {
|
|
45
|
+
arguments "-DBUILD_TESTING=OFF"
|
|
46
|
+
targets "keys", "gpchannelNDK"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
42
49
|
}
|
|
43
50
|
|
|
44
51
|
buildFeatures {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
cmake_minimum_required(VERSION 3.
|
|
1
|
+
cmake_minimum_required(VERSION 3.16)
|
|
2
|
+
project(ReactNativeLiteCard LANGUAGES C CXX)
|
|
2
3
|
|
|
3
4
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Os -Oz")
|
|
4
5
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Os -Oz")
|
|
@@ -9,6 +10,9 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
|
|
9
10
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,max-page-size=16384")
|
|
10
11
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-z,max-page-size=16384")
|
|
11
12
|
|
|
13
|
+
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../../../../sdk"
|
|
14
|
+
"${CMAKE_CURRENT_BINARY_DIR}/gpchannel")
|
|
15
|
+
|
|
12
16
|
add_library(keys SHARED
|
|
13
17
|
../../../../keys/keys.c
|
|
14
18
|
validation.c)
|
|
@@ -16,4 +20,4 @@ add_library(keys SHARED
|
|
|
16
20
|
# Include libraries needed for native-lib lib
|
|
17
21
|
target_link_libraries(keys
|
|
18
22
|
android
|
|
19
|
-
log)
|
|
23
|
+
log)
|
|
@@ -4,6 +4,7 @@ import android.content.Intent
|
|
|
4
4
|
import android.nfc.NfcAdapter
|
|
5
5
|
import android.nfc.Tag
|
|
6
6
|
import android.nfc.tech.IsoDep
|
|
7
|
+
import android.os.SystemClock
|
|
7
8
|
import com.margelo.nitro.nativelogger.OneKeyLog
|
|
8
9
|
import androidx.annotation.IntDef
|
|
9
10
|
import androidx.fragment.app.FragmentActivity
|
|
@@ -67,6 +68,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
67
68
|
|
|
68
69
|
private val mNFCConnectedChannel = Channel<IsoDep?>(1)
|
|
69
70
|
private var lastIsoDep: IsoDep? = null
|
|
71
|
+
private val diagnosticSequence = AtomicInteger(0)
|
|
70
72
|
private val mNFCState = AtomicInteger(NFCState.Dead)
|
|
71
73
|
private val mShowDialogNumber = AtomicInteger(0)
|
|
72
74
|
private var mCurrentCardState: CardState? = null
|
|
@@ -94,7 +96,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
94
96
|
return
|
|
95
97
|
}
|
|
96
98
|
|
|
97
|
-
OneKeyLog.
|
|
99
|
+
OneKeyLog.info("LiteCard", "stage=tag_received wallTimeMs=${System.currentTimeMillis()}")
|
|
98
100
|
launch(Dispatchers.IO) {
|
|
99
101
|
mNFCConnectedChannel.trySend(isoDep)
|
|
100
102
|
try {
|
|
@@ -114,7 +116,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
114
116
|
emitOnNFCActiveConnection(dataMap.copy())
|
|
115
117
|
}
|
|
116
118
|
} catch (e: Exception) {
|
|
117
|
-
OneKeyLog.error("LiteCard", "
|
|
119
|
+
OneKeyLog.error("LiteCard", "stage=connection_failure type=${if (e is NFCExceptions) "nfc" else "other"}")
|
|
118
120
|
// 未知设备或连接失败
|
|
119
121
|
val dataMap = Arguments.createMap().apply {
|
|
120
122
|
putInt("code", -1)
|
|
@@ -156,6 +158,8 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
156
158
|
|
|
157
159
|
@Throws(NFCExceptions::class)
|
|
158
160
|
private suspend fun acquireDevice(): IsoDep? {
|
|
161
|
+
val acquireID = diagnosticSequence.incrementAndGet()
|
|
162
|
+
OneKeyLog.info("LiteCard", "acquireID=$acquireID stage=acquire_begin wallTimeMs=${System.currentTimeMillis()}")
|
|
159
163
|
// 展示连接 ui
|
|
160
164
|
emitOnNFCUIEvent(Arguments.createMap().also {
|
|
161
165
|
it.putInt("code", 1)
|
|
@@ -171,18 +175,22 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
171
175
|
|
|
172
176
|
if (tryReceiveResult.isSuccess) {
|
|
173
177
|
receiveIsoDep = tryReceiveResult.getOrNull()
|
|
178
|
+
OneKeyLog.info("LiteCard", "acquireID=$acquireID stage=acquire_source source=channel connected=${receiveIsoDep.isSafeConnected()}")
|
|
174
179
|
if (!receiveIsoDep.isSafeConnected()) {
|
|
175
180
|
receiveIsoDep = null
|
|
176
181
|
}
|
|
177
182
|
}
|
|
178
183
|
|
|
179
184
|
if (receiveIsoDep == null && lastIsoDep.isSafeConnected()) {
|
|
185
|
+
OneKeyLog.info("LiteCard", "acquireID=$acquireID stage=acquire_source source=last connected=true")
|
|
180
186
|
receiveIsoDep = lastIsoDep
|
|
181
187
|
}
|
|
182
188
|
if (receiveIsoDep == null) {
|
|
189
|
+
OneKeyLog.info("LiteCard", "acquireID=$acquireID stage=acquire_source source=wait")
|
|
183
190
|
receiveIsoDep = mNFCConnectedChannel.receive()
|
|
184
191
|
}
|
|
185
192
|
|
|
193
|
+
OneKeyLog.info("LiteCard", "acquireID=$acquireID stage=acquire_result available=${receiveIsoDep != null} connected=${receiveIsoDep.isSafeConnected()}")
|
|
186
194
|
lastIsoDep = receiveIsoDep
|
|
187
195
|
if (receiveIsoDep == null) {
|
|
188
196
|
// 取消连接
|
|
@@ -191,6 +199,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
191
199
|
val initChannelRequest = OneKeyLiteCard.initRequest(receiveIsoDep)
|
|
192
200
|
|
|
193
201
|
mCurrentCardState = initChannelRequest
|
|
202
|
+
OneKeyLog.info("LiteCard", "acquireID=$acquireID stage=card_state isNewCard=${initChannelRequest.isNewCard} hasBackup=${initChannelRequest.hasBackup}")
|
|
194
203
|
|
|
195
204
|
// 展示连接结束 ui
|
|
196
205
|
emitOnNFCUIEvent(Arguments.createMap().also {
|
|
@@ -203,17 +212,25 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
203
212
|
|
|
204
213
|
private suspend fun <T> handleOperation(
|
|
205
214
|
callback: Callback?,
|
|
215
|
+
operation: String,
|
|
206
216
|
execute: (isoDep: IsoDep) -> T
|
|
207
217
|
) {
|
|
208
|
-
val
|
|
218
|
+
val operationID = diagnosticSequence.incrementAndGet()
|
|
219
|
+
val started = SystemClock.elapsedRealtime()
|
|
220
|
+
OneKeyLog.info("LiteCard", "operation=$operation operationID=$operationID stage=entry wallTimeMs=${System.currentTimeMillis()}")
|
|
221
|
+
val topActivity = Utils.getTopActivity() ?: run {
|
|
222
|
+
OneKeyLog.info("LiteCard", "operation=$operation operationID=$operationID stage=no_activity")
|
|
223
|
+
return
|
|
224
|
+
}
|
|
209
225
|
NfcPermissionUtils.checkPermission(topActivity) {
|
|
210
226
|
try {
|
|
211
227
|
OneKeyLog.debug("LiteCard","NFC permission check success")
|
|
212
228
|
val isoDep = acquireDevice() ?: return
|
|
213
229
|
val executeResult = execute(isoDep)
|
|
230
|
+
OneKeyLog.info("LiteCard", "operation=$operation operationID=$operationID stage=callback code=0 elapsedMs=${SystemClock.elapsedRealtime() - started}")
|
|
214
231
|
callback?.invoke(null, executeResult, mCurrentCardState.createArguments())
|
|
215
232
|
} catch (e: NFCExceptions) {
|
|
216
|
-
OneKeyLog.
|
|
233
|
+
OneKeyLog.info("LiteCard", "operation=$operation operationID=$operationID stage=callback code=${e.code} elapsedMs=${SystemClock.elapsedRealtime() - started}")
|
|
217
234
|
callback?.invoke(e.createArguments(), null, mCurrentCardState.createArguments())
|
|
218
235
|
} finally {
|
|
219
236
|
releaseDevice()
|
|
@@ -222,6 +239,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
222
239
|
}
|
|
223
240
|
// 没有 NFC 使用权限
|
|
224
241
|
OneKeyLog.debug("LiteCard","NFC device not permission")
|
|
242
|
+
OneKeyLog.info("LiteCard", "operation=$operation operationID=$operationID stage=callback code=${NFCExceptions.NotNFCPermission().code}")
|
|
225
243
|
callback?.invoke(NFCExceptions.NotNFCPermission().createArguments(), null, null)
|
|
226
244
|
}
|
|
227
245
|
|
|
@@ -246,7 +264,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
246
264
|
override fun getLiteInfo(callback: Callback?) {
|
|
247
265
|
launch {
|
|
248
266
|
OneKeyLog.debug("LiteCard","getLiteInfo")
|
|
249
|
-
handleOperation<Any>(callback) { isoDep ->
|
|
267
|
+
handleOperation<Any>(callback, "getLiteInfo") { isoDep ->
|
|
250
268
|
OneKeyLog.debug("LiteCard","getLiteInfo Obtain the device")
|
|
251
269
|
val cardInfo = OneKeyLiteCard.getCardInfo(isoDep)
|
|
252
270
|
OneKeyLog.debug("LiteCard","getLiteInfo result obtained")
|
|
@@ -300,7 +318,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
300
318
|
return
|
|
301
319
|
}
|
|
302
320
|
launch {
|
|
303
|
-
handleOperation(callback) { isoDep ->
|
|
321
|
+
handleOperation(callback, "setMnemonic") { isoDep ->
|
|
304
322
|
OneKeyLog.debug("LiteCard","setMnemonic Obtain the device")
|
|
305
323
|
val isSuccess =
|
|
306
324
|
OneKeyLiteCard.setMnemonic(
|
|
@@ -327,7 +345,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
327
345
|
}
|
|
328
346
|
launch {
|
|
329
347
|
OneKeyLog.debug("LiteCard","getMnemonicWithPin")
|
|
330
|
-
handleOperation(callback) { isoDep ->
|
|
348
|
+
handleOperation(callback, "getMnemonicWithPin") { isoDep ->
|
|
331
349
|
OneKeyLog.debug("LiteCard","getMnemonicWithPin Obtain the device")
|
|
332
350
|
OneKeyLiteCard.getMnemonicWithPin(mCurrentCardState, isoDep, pwd)
|
|
333
351
|
}
|
|
@@ -341,7 +359,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
341
359
|
) {
|
|
342
360
|
launch {
|
|
343
361
|
OneKeyLog.debug("LiteCard","changePin")
|
|
344
|
-
handleOperation(callback) { isoDep ->
|
|
362
|
+
handleOperation(callback, "changePin") { isoDep ->
|
|
345
363
|
OneKeyLog.debug("LiteCard","changePin Obtain the device")
|
|
346
364
|
OneKeyLiteCard.changPin(mCurrentCardState, isoDep, oldPin, newPin)
|
|
347
365
|
}
|
|
@@ -351,7 +369,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
351
369
|
override fun reset(callback: Callback?) {
|
|
352
370
|
launch {
|
|
353
371
|
OneKeyLog.debug("LiteCard","reset")
|
|
354
|
-
handleOperation(callback) { isoDep ->
|
|
372
|
+
handleOperation(callback, "reset") { isoDep ->
|
|
355
373
|
OneKeyLog.debug("LiteCard","reset Obtain the device")
|
|
356
374
|
val isSuccess = OneKeyLiteCard.reset(isoDep)
|
|
357
375
|
if (!isSuccess) throw NFCExceptions.ExecFailureException()
|
|
@@ -416,7 +434,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
416
434
|
OneKeyLog.debug("LiteCard","NFC starting success")
|
|
417
435
|
}
|
|
418
436
|
} catch (e: Exception) {
|
|
419
|
-
OneKeyLog.error("LiteCard", "
|
|
437
|
+
OneKeyLog.error("LiteCard", "stage=start_nfc_failure")
|
|
420
438
|
}
|
|
421
439
|
}
|
|
422
440
|
}
|
|
@@ -430,7 +448,7 @@ class ReactNativeLiteCardModule(val reactContext: ReactApplicationContext) :
|
|
|
430
448
|
mNFCState.set(NFCState.Dead)
|
|
431
449
|
OneKeyLog.debug("LiteCard","NFC 已关闭")
|
|
432
450
|
} catch (e: Exception) {
|
|
433
|
-
OneKeyLog.error("LiteCard", "
|
|
451
|
+
OneKeyLog.error("LiteCard", "stage=stop_nfc_failure")
|
|
434
452
|
}
|
|
435
453
|
}
|
|
436
454
|
}
|
package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/gpchannel/GPChannelNatives.kt
CHANGED
|
@@ -11,20 +11,20 @@ object GPChannelNatives {
|
|
|
11
11
|
external fun nativeGetErrorCode(): Int
|
|
12
12
|
external fun nativeGPCInitialize(json: String?): Int
|
|
13
13
|
external fun nativeGPCFinalize(): Int
|
|
14
|
-
external fun nativeGPCBuildMutualAuthData(): String
|
|
14
|
+
external fun nativeGPCBuildMutualAuthData(): String?
|
|
15
15
|
external fun nativeGPCOpenSecureChannel(response: String?): Int
|
|
16
16
|
external fun nativeGPCBuildAPDU(
|
|
17
17
|
cla: Long, ins: Long, p1: Long, p2: Long, data: String = ""
|
|
18
|
-
): String
|
|
18
|
+
): String?
|
|
19
19
|
|
|
20
20
|
external fun nativeGPCBuildSafeAPDU(
|
|
21
21
|
cla: Long, ins: Long, p1: Long, p2: Long, data: String = ""
|
|
22
|
-
): String
|
|
22
|
+
): String?
|
|
23
23
|
|
|
24
|
-
external fun nativeGPCParseSafeAPDUResponse(response: String?): String
|
|
25
|
-
external fun nativeGPCParseAPDUResponse(response: String?): String
|
|
26
|
-
external fun nativeGPCTLVDecode(apdu: String?): String
|
|
27
|
-
external fun nativeGPCParseCertificate(cert: String?): String
|
|
24
|
+
external fun nativeGPCParseSafeAPDUResponse(response: String?): String?
|
|
25
|
+
external fun nativeGPCParseAPDUResponse(response: String?): String?
|
|
26
|
+
external fun nativeGPCTLVDecode(apdu: String?): String?
|
|
27
|
+
external fun nativeGPCParseCertificate(cert: String?): String?
|
|
28
28
|
|
|
29
29
|
init {
|
|
30
30
|
System.loadLibrary("gpchannelNDK")
|
|
@@ -111,18 +111,21 @@ object OneKeyLiteCard {
|
|
|
111
111
|
): Boolean {
|
|
112
112
|
if (cardState == null) throw NFCExceptions.ConnectionFailException()
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=card_state isNewCard=${cardState.isNewCard} hasBackup=${cardState.hasBackup} overwrite=$overwrite wallTimeMs=${System.currentTimeMillis()}")
|
|
115
115
|
|
|
116
116
|
if (!overwrite) {
|
|
117
117
|
// 不是覆写要验证是否已经已经存有备份
|
|
118
118
|
if (!cardState.isNewCard || cardState.hasBackup) {
|
|
119
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=already_initialized")
|
|
119
120
|
throw NFCExceptions.InitializedException()
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
if (overwrite && mCardConnection?.getCardType() == AppleCardType.V2) {
|
|
124
125
|
// Verify the password before clearing the card
|
|
126
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=overwrite_verify_begin")
|
|
125
127
|
val verifyPin = verifyPinBackupRequest(isoDep, pwd)
|
|
128
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=overwrite_verify_result success=${verifyPin == NfcConstant.VERIFY_SUCCESS}")
|
|
126
129
|
if (verifyPin != NfcConstant.VERIFY_SUCCESS) {
|
|
127
130
|
handlerVerifyPinError(cardState, verifyPin)
|
|
128
131
|
}
|
|
@@ -133,12 +136,17 @@ object OneKeyLiteCard {
|
|
|
133
136
|
|
|
134
137
|
if (cardState.isNewCard) {
|
|
135
138
|
// 如果是新卡设置密码
|
|
136
|
-
|
|
139
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=set_pin_begin")
|
|
140
|
+
val setupSuccess = setupNewPinRequest(isoDep, pwd)
|
|
141
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=set_pin_result success=$setupSuccess")
|
|
142
|
+
if (!setupSuccess) {
|
|
137
143
|
throw NFCExceptions.InitPasswordException()
|
|
138
144
|
}
|
|
139
145
|
}
|
|
140
146
|
|
|
147
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=verify_pin_begin")
|
|
141
148
|
val verifyPin = verifyPinBackupRequest(isoDep, pwd)
|
|
149
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=verify_pin_result success=${verifyPin == NfcConstant.VERIFY_SUCCESS}")
|
|
142
150
|
if (verifyPin != NfcConstant.VERIFY_SUCCESS) {
|
|
143
151
|
if (overwrite) {
|
|
144
152
|
handlerVerifyPinError(cardState, verifyPin)
|
|
@@ -148,7 +156,10 @@ object OneKeyLiteCard {
|
|
|
148
156
|
}
|
|
149
157
|
|
|
150
158
|
if (mnemonic.isNullOrEmpty()) throw NFCExceptions.ExecFailureException()
|
|
151
|
-
|
|
159
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=backup_begin")
|
|
160
|
+
val backupSuccess = mCardConnection?.backupData(mnemonic) == true
|
|
161
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=backup_result success=$backupSuccess")
|
|
162
|
+
return backupSuccess
|
|
152
163
|
}
|
|
153
164
|
|
|
154
165
|
@Throws(NFCExceptions::class)
|
package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/SendResponse.kt
CHANGED
|
@@ -9,11 +9,14 @@ data class SendResponse(
|
|
|
9
9
|
val sw2: Byte,
|
|
10
10
|
val data: String? = null,
|
|
11
11
|
// Processed result
|
|
12
|
-
var result: String? = null
|
|
12
|
+
var result: String? = null,
|
|
13
|
+
var parseSuccess: Boolean = true
|
|
13
14
|
) {
|
|
14
|
-
fun isSuccess() = sw1 == 0x90.toByte() && sw2 == 0x00.toByte()
|
|
15
|
+
fun isSuccess() = parseSuccess && sw1 == 0x90.toByte() && sw2 == 0x00.toByte()
|
|
15
16
|
|
|
16
|
-
fun isConnectFailure() =
|
|
17
|
+
fun isConnectFailure() =
|
|
18
|
+
(sw1 == 0x6F.toByte() && sw2 == 0x00.toByte()) ||
|
|
19
|
+
(sw1 == 0xFF.toByte() && sw2 == 0xFF.toByte())
|
|
17
20
|
|
|
18
21
|
fun isEmptyData() = data.isNullOrEmpty()
|
|
19
22
|
|
package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/CommandGenerator.kt
CHANGED
|
@@ -97,7 +97,7 @@ class Command(
|
|
|
97
97
|
)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
private fun parseResponse(response: String): String {
|
|
100
|
+
private fun parseResponse(response: String): String? {
|
|
101
101
|
return if (useSafeChannel || (useSafeChannelWhenOpen && hasOpenSafeChannel)) {
|
|
102
102
|
nativeGPCParseSafeAPDUResponse(response)
|
|
103
103
|
} else {
|
|
@@ -109,9 +109,13 @@ class Command(
|
|
|
109
109
|
beforeConnecting(connection)
|
|
110
110
|
// buildApdu && parseResponse Use in pairs
|
|
111
111
|
val apdu = buildApdu()
|
|
112
|
+
if (apdu.isEmpty()) {
|
|
113
|
+
return SendResponse("0xFFFF", 0xFF.toByte(), 0xFF.toByte(), parseSuccess = false)
|
|
114
|
+
}
|
|
112
115
|
val result = Connection.send(connection.isoDep, apdu)
|
|
113
116
|
val resultObject = CardResponse.objectFromData(parseResponse(result.rawResponse))
|
|
114
117
|
result.result = resultObject?.response ?: ""
|
|
118
|
+
result.parseSuccess = resultObject != null && resultObject.wRet == 0x9000
|
|
115
119
|
return result
|
|
116
120
|
}
|
|
117
121
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.onekeyfe.reactnativelitecard.onekeyLite.nfc
|
|
2
2
|
|
|
3
3
|
import android.nfc.TagLostException
|
|
4
|
+
import com.margelo.nitro.nativelogger.OneKeyLog
|
|
4
5
|
import android.nfc.tech.IsoDep
|
|
5
6
|
import org.haobtc.onekey.card.gpchannel.GPChannelNatives
|
|
6
7
|
import org.haobtc.onekey.card.gpchannel.GPChannelNatives.nativeGPCFinalize
|
|
@@ -49,9 +50,11 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
49
50
|
|
|
50
51
|
return SendResponse(byteArr2HexStr(response), sw1, sw2, byteArr2HexStr(resp))
|
|
51
52
|
} catch (e: TagLostException) {
|
|
53
|
+
OneKeyLog.info("LiteCard", "stage=transport_failure type=tag_lost")
|
|
52
54
|
// throw NFCExceptions.InterruptException()
|
|
53
55
|
return SendResponse("0xFFFF", 0xFF.toByte(), 0xFF.toByte())
|
|
54
56
|
} catch (e: IOException) {
|
|
57
|
+
OneKeyLog.info("LiteCard", "stage=transport_failure type=io")
|
|
55
58
|
// e.printStackTrace()
|
|
56
59
|
return SendResponse("0xFFFF", 0xFF.toByte(), 0xFF.toByte())
|
|
57
60
|
}
|
|
@@ -84,7 +87,7 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
84
87
|
)
|
|
85
88
|
val res = command.send(this)
|
|
86
89
|
printLog(
|
|
87
|
-
TAG, "<--- selectPrimarySafety end: ${res.getCode()}
|
|
90
|
+
TAG, "<--- selectPrimarySafety end: ${res.getCode()} area:${mCommandArea}"
|
|
88
91
|
)
|
|
89
92
|
|
|
90
93
|
if (res.isSuccess() && !res.isEmptyData()) {
|
|
@@ -104,7 +107,7 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
104
107
|
)
|
|
105
108
|
val res = command.send(this)
|
|
106
109
|
|
|
107
|
-
printLog(TAG, "<--- selectApplet end: ${res.getCode()}
|
|
110
|
+
printLog(TAG, "<--- selectApplet end: ${res.getCode()} area:${mCommandArea}")
|
|
108
111
|
|
|
109
112
|
if (res.isSuccess()) {
|
|
110
113
|
mCommandArea = CommandArea.BackupApplet
|
|
@@ -117,16 +120,21 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
117
120
|
printLog(TAG, "---> getDeviceCertificate begin")
|
|
118
121
|
// #1.NFC:GET CERT.SD.ECKA 获取智能卡证书
|
|
119
122
|
val apdu = buildGPCAPDU(APDUParam(0x80, 0xCA, 0xBF, 0x21, "A60483021518"))
|
|
123
|
+
if (apdu.isEmpty()) return null
|
|
120
124
|
val rawCert = send(isoDep, apdu)
|
|
121
125
|
printLog(
|
|
122
126
|
TAG,
|
|
123
|
-
"<--- getDeviceCertificate end: ${rawCert.getCode()}
|
|
127
|
+
"<--- getDeviceCertificate end: ${rawCert.getCode()} area:${mCommandArea}"
|
|
124
128
|
)
|
|
129
|
+
if (!rawCert.isSuccess() || rawCert.isEmptyData()) {
|
|
130
|
+
return null
|
|
131
|
+
}
|
|
125
132
|
|
|
126
|
-
val cert = GPChannelNatives.nativeGPCTLVDecode(rawCert.data)
|
|
127
|
-
val certificate = CardResponse.objectFromData(cert)
|
|
133
|
+
val cert = GPChannelNatives.nativeGPCTLVDecode(rawCert.data) ?: return null
|
|
134
|
+
val certificate = CardResponse.objectFromData(cert)?.response
|
|
135
|
+
if (certificate.isNullOrEmpty()) return null
|
|
128
136
|
|
|
129
|
-
val certInfo = GPChannelNatives.nativeGPCParseCertificate(certificate)
|
|
137
|
+
val certInfo = GPChannelNatives.nativeGPCParseCertificate(certificate) ?: return null
|
|
130
138
|
return ParsedCertInfo.objectFromData(certInfo)
|
|
131
139
|
}
|
|
132
140
|
|
|
@@ -140,12 +148,18 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
140
148
|
|
|
141
149
|
printLog(TAG, "0. ---> getDeviceCertificate begin")
|
|
142
150
|
val certInfo = getDeviceCertificate() ?: return false
|
|
151
|
+
if (certInfo.subjectID.isNullOrEmpty() || certInfo.sn.isNullOrEmpty()) {
|
|
152
|
+
return false
|
|
153
|
+
}
|
|
154
|
+
if (mCardSerialNumber != NfcConstant.NOT_MATCH_DEVICE && certInfo.sn != mCardSerialNumber) {
|
|
155
|
+
return false
|
|
156
|
+
}
|
|
143
157
|
printLog(TAG, "0. <--- getDeviceCertificate end")
|
|
144
158
|
|
|
145
159
|
printLog(TAG, "1. ---> nativeGPCInitialize begin")
|
|
146
160
|
val param = SecureChanelParam.objectFromData(
|
|
147
161
|
KeysNativeProvider().getLiteSecureChannelInitParams(Utils.getApp())
|
|
148
|
-
)
|
|
162
|
+
) ?: return false
|
|
149
163
|
param.cardGroupID = certInfo.subjectID
|
|
150
164
|
printLog(TAG, "nativeGPCInitialize read param done")
|
|
151
165
|
val initializeStatus = GPChannelNatives.nativeGPCInitialize(param.toString())
|
|
@@ -161,7 +175,7 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
161
175
|
val securityRes = command.send(this)
|
|
162
176
|
printLog(
|
|
163
177
|
TAG,
|
|
164
|
-
"2. <--- Perform security operation end: ${securityRes.getCode()}
|
|
178
|
+
"2. <--- Perform security operation end: ${securityRes.getCode()}"
|
|
165
179
|
)
|
|
166
180
|
if (!securityRes.isSuccess()) {
|
|
167
181
|
return false
|
|
@@ -169,6 +183,9 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
169
183
|
|
|
170
184
|
printLog(TAG, "3. ---> mutual authenticate begin")
|
|
171
185
|
val authData = GPChannelNatives.nativeGPCBuildMutualAuthData()
|
|
186
|
+
if (authData.isNullOrEmpty()) {
|
|
187
|
+
return false
|
|
188
|
+
}
|
|
172
189
|
printLog(TAG, "mutual authenticate data")
|
|
173
190
|
val authCommand = mCommandGenerator.generalCommand(
|
|
174
191
|
mCardType, CommandType.VERIFY_AUTH_DATA, hasOpenSafeChannel, authData
|
|
@@ -206,7 +223,7 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
206
223
|
mCardType, CommandType.GET_BACKUP_STATUS, hasOpenSafeChannel
|
|
207
224
|
)
|
|
208
225
|
val res = command.send(this)
|
|
209
|
-
printLog(TAG, "<--- getBackupStatus end: ${res.getCode()}
|
|
226
|
+
printLog(TAG, "<--- getBackupStatus end: ${res.getCode()} area:${mCommandArea}")
|
|
210
227
|
|
|
211
228
|
if (!res.isSuccess()) {
|
|
212
229
|
return false
|
|
@@ -221,7 +238,7 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
221
238
|
mCardType, CommandType.GET_PIN_STATUS, hasOpenSafeChannel, "DFFF028105"
|
|
222
239
|
)
|
|
223
240
|
val res = command.send(this)
|
|
224
|
-
printLog(TAG, "<--- getPinStatus end: ${res.getCode()}
|
|
241
|
+
printLog(TAG, "<--- getPinStatus end: ${res.getCode()} area:${mCommandArea}")
|
|
225
242
|
|
|
226
243
|
if (!res.isSuccess()) {
|
|
227
244
|
return false
|
|
@@ -239,7 +256,7 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
239
256
|
)
|
|
240
257
|
val res = command.send(this)
|
|
241
258
|
|
|
242
|
-
printLog(TAG, "<--- getSerialNumber end: ${res.getCode()}
|
|
259
|
+
printLog(TAG, "<--- getSerialNumber end: ${res.getCode()} area:${mCommandArea}")
|
|
243
260
|
if (!res.isSuccess()) {
|
|
244
261
|
return NfcConstant.NOT_MATCH_DEVICE
|
|
245
262
|
}
|
|
@@ -256,7 +273,7 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
256
273
|
)
|
|
257
274
|
val res = command.send(this)
|
|
258
275
|
|
|
259
|
-
printLog(TAG, "<--- getRetryNum end: ${res.getCode()}
|
|
276
|
+
printLog(TAG, "<--- getRetryNum end: ${res.getCode()} area:${mCommandArea}")
|
|
260
277
|
|
|
261
278
|
if (res.isEmptyData() || !res.isSuccess()) {
|
|
262
279
|
return NfcConstant.GET_RETRY_NUM_INTERRUPT_STATUS
|
|
@@ -277,7 +294,7 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
277
294
|
}
|
|
278
295
|
}
|
|
279
296
|
} catch (e: NFCExceptions) {
|
|
280
|
-
printLog(TAG, "
|
|
297
|
+
printLog(TAG, "stage=init_channel_failure type=nfc")
|
|
281
298
|
}
|
|
282
299
|
|
|
283
300
|
loadPinStatus()
|
|
@@ -328,7 +345,7 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
328
345
|
|
|
329
346
|
printLog(TAG, "<--- changePin end: ${res.getCode()} area:${mCommandArea}")
|
|
330
347
|
|
|
331
|
-
return if (res.isConnectFailure()) {
|
|
348
|
+
return if (res.isConnectFailure() || (!res.parseSuccess && res.sw1 == 0x90.toByte() && res.sw2 == 0x00.toByte())) {
|
|
332
349
|
NfcConstant.INTERRUPT_STATUS
|
|
333
350
|
} else if (res.isSuccess()) {
|
|
334
351
|
printLog(TAG, "--- verify success")
|
|
@@ -358,7 +375,7 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
358
375
|
val res = command.send(this)
|
|
359
376
|
printLog(TAG, "<--- startVerifyPin end: ${res.getCode()} area:${mCommandArea}")
|
|
360
377
|
|
|
361
|
-
return if (res.isConnectFailure()) {
|
|
378
|
+
return if (res.isConnectFailure() || (!res.parseSuccess && res.sw1 == 0x90.toByte() && res.sw2 == 0x00.toByte())) {
|
|
362
379
|
NfcConstant.INTERRUPT_STATUS
|
|
363
380
|
} else if (res.isSuccess()) {
|
|
364
381
|
printLog(TAG, "--- verify success")
|
|
@@ -384,7 +401,9 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
384
401
|
val command = mCommandGenerator.generalCommand(
|
|
385
402
|
mCardType, CommandType.BACKUP_DATA, hasOpenSafeChannel, mnemonic
|
|
386
403
|
)
|
|
404
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=backup_command_begin wallTimeMs=${System.currentTimeMillis()}")
|
|
387
405
|
val res = command.send(this)
|
|
406
|
+
OneKeyLog.info("LiteCard", "operation=setMnemonic stage=backup_command_result sw1=${res.sw1.toInt() and 0xFF} sw2=${res.sw2.toInt() and 0xFF} parseSuccess=${res.parseSuccess} success=${res.isSuccess()}")
|
|
388
407
|
printLog(TAG, "<--- backupData end: ${res.getCode()} area:${mCommandArea}")
|
|
389
408
|
|
|
390
409
|
if (!res.isSuccess()) {
|
|
@@ -428,9 +447,9 @@ class Connection(val isoDep: IsoDep, private val mCommandGenerator: CommandGener
|
|
|
428
447
|
)
|
|
429
448
|
val res = command.send(this)
|
|
430
449
|
|
|
431
|
-
printLog(TAG, "<--- resetCard end: ${res.getCode()}
|
|
450
|
+
printLog(TAG, "<--- resetCard end: ${res.getCode()} area:${mCommandArea}")
|
|
432
451
|
|
|
433
|
-
return if (res.
|
|
452
|
+
return if (!res.isSuccess()) {
|
|
434
453
|
NfcConstant.RESET_INTERRUPT_STATUS
|
|
435
454
|
} else {
|
|
436
455
|
NfcConstant.RESET_PIN_SUCCESS
|
package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/GPCAPDUGenerator.kt
CHANGED
|
@@ -11,7 +11,7 @@ object GPCAPDUGenerator {
|
|
|
11
11
|
@JvmStatic
|
|
12
12
|
fun buildGPCAPDU(param: APDUParam, safeChannel: Boolean = false): String {
|
|
13
13
|
printLog(TAG, " --->> BuildGPCAPDU begin")
|
|
14
|
-
return if (safeChannel) {
|
|
14
|
+
return (if (safeChannel) {
|
|
15
15
|
GPChannelNatives.nativeGPCBuildSafeAPDU(
|
|
16
16
|
param.cla,
|
|
17
17
|
param.ins,
|
|
@@ -27,7 +27,7 @@ object GPCAPDUGenerator {
|
|
|
27
27
|
param.p2,
|
|
28
28
|
param.data
|
|
29
29
|
)
|
|
30
|
-
}.also {
|
|
30
|
+
} ?: "").also {
|
|
31
31
|
printLog(TAG, " <<--- BuildGPCAPDU done: safeChannel:$safeChannel")
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -18,8 +18,11 @@
|
|
|
18
18
|
id<NFCISO7816Tag> tag = [self.delegate getNFCsessionTag];
|
|
19
19
|
[tag sendCommandAPDU:apdu completionHandler:^(NSData *responseData, uint8_t sw1, uint8_t sw2, NSError *error) {
|
|
20
20
|
NSString *parseRespon = nil;
|
|
21
|
-
if(modal.parseResp
|
|
21
|
+
if (modal.parseResp) {
|
|
22
22
|
parseRespon = [OKNFCBridge parseSafeAPDUResponse:responseData sw1:sw1 sw2:sw2];
|
|
23
|
+
if (sw1 == OKNFC_SW1_OK && parseRespon == nil) {
|
|
24
|
+
sw1 = 0x00;
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
[OKNFCUtility logAPDU:modal.desc response:responseData sw1:sw1 sw2:sw2 error:error];
|
|
@@ -415,10 +415,13 @@
|
|
|
415
415
|
if (sw1 != OKNFC_SW1_OK) {
|
|
416
416
|
if (sw1 == FailedVerificationCode) {
|
|
417
417
|
self.pinRTL = sw2 & PinRTLBitMask;
|
|
418
|
+
result = OKNFCLitePINVerifyResultNotMatch;
|
|
418
419
|
} else if (sw1 == AuthenticationLockCode) {
|
|
419
420
|
self.pinRTL = 0;
|
|
421
|
+
result = OKNFCLitePINVerifyResultNotMatch;
|
|
422
|
+
} else {
|
|
423
|
+
result = OKNFCLitePINVerifyResultError;
|
|
420
424
|
}
|
|
421
|
-
result = OKNFCLitePINVerifyResultNotMatch;
|
|
422
425
|
dispatch_semaphore_signal(sema);
|
|
423
426
|
return;
|
|
424
427
|
}
|
|
@@ -518,7 +521,7 @@
|
|
|
518
521
|
__block BOOL success = NO;
|
|
519
522
|
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
|
|
520
523
|
OKLiteCommandModal *modal = [[OKLiteCommandModal alloc] initWithCommand:OKLiteCommandImportMnemonic version:self.version];
|
|
521
|
-
modal.parseResp =
|
|
524
|
+
modal.parseResp = self.version == OKNFCLiteVersionV2;
|
|
522
525
|
[self.commandTool sendCommandWithAPDU:[modal importMnemonic:mnc] modal:modal completionHandler:^(NSData * _Nonnull responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error, NSString * _Nonnull parseRespon) {
|
|
523
526
|
if (sw1 != OKNFC_SW1_OK) {
|
|
524
527
|
dispatch_semaphore_signal(sema);
|
|
@@ -537,7 +540,7 @@
|
|
|
537
540
|
__block NSString *mnc = nil;
|
|
538
541
|
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
|
|
539
542
|
OKLiteCommandModal *modal = [[OKLiteCommandModal alloc] initWithCommand:OKLiteCommandExportMnemonic version:self.version];
|
|
540
|
-
modal.parseResp =
|
|
543
|
+
modal.parseResp = self.version == OKNFCLiteVersionV2;
|
|
541
544
|
[self.commandTool sendCommandWithAPDU:[modal buildAPDU] modal:modal completionHandler:^(NSData * _Nonnull responseData, uint8_t sw1, uint8_t sw2, NSError * _Nullable error, NSString * _Nonnull parseRespon) {
|
|
542
545
|
if (sw1 != OKNFC_SW1_OK) {
|
|
543
546
|
dispatch_semaphore_signal(sema);
|