@onekeyfe/react-native-lite-card 6.7.0-alpha.407 → 6.7.0-alpha.411

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +9 -1
  2. package/ReactNativeLiteCard.podspec +25 -2
  3. package/android/build.gradle +7 -0
  4. package/android/src/main/cpp/CMakeLists.txt +6 -2
  5. package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/gpchannel/GPChannelNatives.kt +7 -7
  6. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/SendResponse.kt +6 -3
  7. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/CommandGenerator.kt +5 -1
  8. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/Connection.kt +21 -7
  9. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/GPCAPDUGenerator.kt +2 -2
  10. package/ios/Classes/OKLiteCommand/OKLiteCommandTool.m +4 -1
  11. package/ios/Classes/OKNFCBridge.mm +1 -1
  12. package/ios/Classes/OKNFTLite/OKLiteV1.m +6 -3
  13. package/ios/Classes/OKNFTLite/OKLiteV2.m +13 -5
  14. package/package.json +2 -2
  15. package/sdk/CMakeLists.txt +120 -0
  16. package/sdk/README.md +175 -0
  17. package/sdk/android/implJni.cpp +177 -0
  18. package/sdk/deps/jsoncpp/LICENSE +55 -0
  19. package/sdk/deps/jsoncpp/include/CMakeLists.txt +2 -0
  20. package/sdk/deps/jsoncpp/include/json/allocator.h +98 -0
  21. package/sdk/deps/jsoncpp/include/json/assertions.h +54 -0
  22. package/sdk/deps/jsoncpp/include/json/autolink.h +25 -0
  23. package/sdk/deps/jsoncpp/include/json/config.h +187 -0
  24. package/sdk/deps/jsoncpp/include/json/features.h +61 -0
  25. package/sdk/deps/jsoncpp/include/json/forwards.h +37 -0
  26. package/sdk/deps/jsoncpp/include/json/json.h +15 -0
  27. package/sdk/deps/jsoncpp/include/json/reader.h +411 -0
  28. package/sdk/deps/jsoncpp/include/json/value.h +888 -0
  29. package/sdk/deps/jsoncpp/include/json/version.h +20 -0
  30. package/sdk/deps/jsoncpp/include/json/writer.h +357 -0
  31. package/sdk/deps/jsoncpp/src/lib_json/CMakeLists.txt +117 -0
  32. package/sdk/deps/jsoncpp/src/lib_json/json_reader.cpp +2060 -0
  33. package/sdk/deps/jsoncpp/src/lib_json/json_tool.h +114 -0
  34. package/sdk/deps/jsoncpp/src/lib_json/json_value.cpp +1661 -0
  35. package/sdk/deps/jsoncpp/src/lib_json/json_valueiterator.inl +167 -0
  36. package/sdk/deps/jsoncpp/src/lib_json/json_writer.cpp +1233 -0
  37. package/sdk/deps/jsoncpp/src/lib_json/version.h.in +20 -0
  38. package/sdk/deps/trezor-crypto/AUTHORS +2 -0
  39. package/sdk/deps/trezor-crypto/LICENSE +22 -0
  40. package/sdk/deps/trezor-crypto/include/TrezorCrypto/TrezorCrypto.h +29 -0
  41. package/sdk/deps/trezor-crypto/include/TrezorCrypto/address.h +44 -0
  42. package/sdk/deps/trezor-crypto/include/TrezorCrypto/aes.h +224 -0
  43. package/sdk/deps/trezor-crypto/include/TrezorCrypto/base32.h +49 -0
  44. package/sdk/deps/trezor-crypto/include/TrezorCrypto/base58.h +58 -0
  45. package/sdk/deps/trezor-crypto/include/TrezorCrypto/bignum.h +169 -0
  46. package/sdk/deps/trezor-crypto/include/TrezorCrypto/bip32.h +114 -0
  47. package/sdk/deps/trezor-crypto/include/TrezorCrypto/bip39.h +66 -0
  48. package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake256.h +61 -0
  49. package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake2b.h +50 -0
  50. package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake2s.h +49 -0
  51. package/sdk/deps/trezor-crypto/include/TrezorCrypto/cash_addr.h +109 -0
  52. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-config.h +316 -0
  53. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-sync.h +289 -0
  54. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-types.h +53 -0
  55. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/poly1305-donna.h +28 -0
  56. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305.h +27 -0
  57. package/sdk/deps/trezor-crypto/include/TrezorCrypto/cmac.h +44 -0
  58. package/sdk/deps/trezor-crypto/include/TrezorCrypto/curves.h +60 -0
  59. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ecdsa.h +112 -0
  60. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/curve25519-donna-32bit.h +87 -0
  61. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/curve25519-donna-helpers.h +30 -0
  62. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-blake2b.h +21 -0
  63. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-32bit-tables.h +25 -0
  64. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-basepoint-table.h +10 -0
  65. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-impl-base.h +110 -0
  66. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-portable.h +32 -0
  67. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna.h +60 -0
  68. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-keccak.h +21 -0
  69. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-sha3.h +21 -0
  70. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/modm-donna-32bit.h +87 -0
  71. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna.h +60 -0
  72. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519.h +42 -0
  73. package/sdk/deps/trezor-crypto/include/TrezorCrypto/endian.h +132 -0
  74. package/sdk/deps/trezor-crypto/include/TrezorCrypto/groestl.h +104 -0
  75. package/sdk/deps/trezor-crypto/include/TrezorCrypto/hasher.h +90 -0
  76. package/sdk/deps/trezor-crypto/include/TrezorCrypto/hmac.h +60 -0
  77. package/sdk/deps/trezor-crypto/include/TrezorCrypto/memzero.h +16 -0
  78. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/base58.h +42 -0
  79. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/monero.h +13 -0
  80. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/range_proof.h +30 -0
  81. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/serialize.h +15 -0
  82. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/xmr.h +67 -0
  83. package/sdk/deps/trezor-crypto/include/TrezorCrypto/nano.h +56 -0
  84. package/sdk/deps/trezor-crypto/include/TrezorCrypto/nem.h +199 -0
  85. package/sdk/deps/trezor-crypto/include/TrezorCrypto/nist256p1.h +35 -0
  86. package/sdk/deps/trezor-crypto/include/TrezorCrypto/pbkdf2.h +64 -0
  87. package/sdk/deps/trezor-crypto/include/TrezorCrypto/rand.h +44 -0
  88. package/sdk/deps/trezor-crypto/include/TrezorCrypto/rc4.h +37 -0
  89. package/sdk/deps/trezor-crypto/include/TrezorCrypto/rfc6979.h +40 -0
  90. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ripemd160.h +28 -0
  91. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ripple/base58.h +45 -0
  92. package/sdk/deps/trezor-crypto/include/TrezorCrypto/schnorr.h +48 -0
  93. package/sdk/deps/trezor-crypto/include/TrezorCrypto/script.h +30 -0
  94. package/sdk/deps/trezor-crypto/include/TrezorCrypto/scrypt.h +68 -0
  95. package/sdk/deps/trezor-crypto/include/TrezorCrypto/secp256k1.h +59 -0
  96. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sha2.h +125 -0
  97. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sha3.h +86 -0
  98. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/keypair.h +20 -0
  99. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/ed25519_ref10.h +85 -0
  100. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/ed25519_ref10_fe_25_5.h +43 -0
  101. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/fe_25_5/constants.h +29 -0
  102. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/fe_25_5/fe.h +25 -0
  103. package/sdk/deps/trezor-crypto/src/address.c +87 -0
  104. package/sdk/deps/trezor-crypto/src/aes/aes_modes.c +959 -0
  105. package/sdk/deps/trezor-crypto/src/aes/aescrypt.c +307 -0
  106. package/sdk/deps/trezor-crypto/src/aes/aeskey.c +560 -0
  107. package/sdk/deps/trezor-crypto/src/aes/aesopt.h +784 -0
  108. package/sdk/deps/trezor-crypto/src/aes/aestab.c +418 -0
  109. package/sdk/deps/trezor-crypto/src/aes/aestab.h +173 -0
  110. package/sdk/deps/trezor-crypto/src/base32.c +233 -0
  111. package/sdk/deps/trezor-crypto/src/base58.c +298 -0
  112. package/sdk/deps/trezor-crypto/src/bignum.c +808 -0
  113. package/sdk/deps/trezor-crypto/src/bip32.c +852 -0
  114. package/sdk/deps/trezor-crypto/src/bip39.c +266 -0
  115. package/sdk/deps/trezor-crypto/src/bip39_english.h +2074 -0
  116. package/sdk/deps/trezor-crypto/src/blake256.c +235 -0
  117. package/sdk/deps/trezor-crypto/src/blake2_common.h +39 -0
  118. package/sdk/deps/trezor-crypto/src/blake2b.c +333 -0
  119. package/sdk/deps/trezor-crypto/src/blake2s.c +318 -0
  120. package/sdk/deps/trezor-crypto/src/cash_addr.c +195 -0
  121. package/sdk/deps/trezor-crypto/src/chacha20poly1305/chacha20poly1305.c +60 -0
  122. package/sdk/deps/trezor-crypto/src/chacha20poly1305/chacha_merged.c +246 -0
  123. package/sdk/deps/trezor-crypto/src/chacha20poly1305/ecrypt-machine.h +49 -0
  124. package/sdk/deps/trezor-crypto/src/chacha20poly1305/ecrypt-portable.h +275 -0
  125. package/sdk/deps/trezor-crypto/src/chacha20poly1305/poly1305-donna-32.h +219 -0
  126. package/sdk/deps/trezor-crypto/src/chacha20poly1305/poly1305-donna.c +179 -0
  127. package/sdk/deps/trezor-crypto/src/chacha20poly1305/rfc7539.c +48 -0
  128. package/sdk/deps/trezor-crypto/src/chacha20poly1305/rfc7539.h +10 -0
  129. package/sdk/deps/trezor-crypto/src/check_mem.h +30 -0
  130. package/sdk/deps/trezor-crypto/src/cmac.c +342 -0
  131. package/sdk/deps/trezor-crypto/src/curves.c +48 -0
  132. package/sdk/deps/trezor-crypto/src/ecdsa.c +1355 -0
  133. package/sdk/deps/trezor-crypto/src/ed25519-donna/README.md +183 -0
  134. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-32bit.c +681 -0
  135. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-helpers.c +66 -0
  136. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-scalarmult-base.c +67 -0
  137. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-scalarmult-base.h +8 -0
  138. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-blake2b.c +8 -0
  139. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-32bit-tables.c +63 -0
  140. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-basepoint-table.c +261 -0
  141. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-impl-base.c +722 -0
  142. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-blake2b.h +23 -0
  143. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-keccak.h +23 -0
  144. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-sha3.h +23 -0
  145. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom.h +23 -0
  146. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-keccak.c +8 -0
  147. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-sha3.c +8 -0
  148. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519.c +311 -0
  149. package/sdk/deps/trezor-crypto/src/ed25519-donna/modm-donna-32bit.c +517 -0
  150. package/sdk/deps/trezor-crypto/src/groestl.c +783 -0
  151. package/sdk/deps/trezor-crypto/src/groestl_internal.h +419 -0
  152. package/sdk/deps/trezor-crypto/src/hasher.c +186 -0
  153. package/sdk/deps/trezor-crypto/src/hmac.c +179 -0
  154. package/sdk/deps/trezor-crypto/src/memzero.c +6 -0
  155. package/sdk/deps/trezor-crypto/src/monero/base58.c +245 -0
  156. package/sdk/deps/trezor-crypto/src/monero/int-util.h +77 -0
  157. package/sdk/deps/trezor-crypto/src/monero/range_proof.c +115 -0
  158. package/sdk/deps/trezor-crypto/src/monero/serialize.c +54 -0
  159. package/sdk/deps/trezor-crypto/src/monero/xmr.c +136 -0
  160. package/sdk/deps/trezor-crypto/src/nano.c +151 -0
  161. package/sdk/deps/trezor-crypto/src/nem.c +569 -0
  162. package/sdk/deps/trezor-crypto/src/nist256p1.c +63 -0
  163. package/sdk/deps/trezor-crypto/src/nist256p1.table +1664 -0
  164. package/sdk/deps/trezor-crypto/src/options.h +43 -0
  165. package/sdk/deps/trezor-crypto/src/pbkdf2.c +177 -0
  166. package/sdk/deps/trezor-crypto/src/rand.c +51 -0
  167. package/sdk/deps/trezor-crypto/src/rc4.c +56 -0
  168. package/sdk/deps/trezor-crypto/src/ripemd160.c +343 -0
  169. package/sdk/deps/trezor-crypto/src/ripple/base58.c +76 -0
  170. package/sdk/deps/trezor-crypto/src/schnorr.c +208 -0
  171. package/sdk/deps/trezor-crypto/src/script.c +64 -0
  172. package/sdk/deps/trezor-crypto/src/scrypt.c +343 -0
  173. package/sdk/deps/trezor-crypto/src/secp256k1.c +160 -0
  174. package/sdk/deps/trezor-crypto/src/secp256k1.table +1664 -0
  175. package/sdk/deps/trezor-crypto/src/setup.py +38 -0
  176. package/sdk/deps/trezor-crypto/src/sha2.c +1314 -0
  177. package/sdk/deps/trezor-crypto/src/sha3.c +395 -0
  178. package/sdk/deps/trezor-crypto/src/shell.nix +6 -0
  179. package/sdk/deps/trezor-crypto/src/sodium/keypair.c +63 -0
  180. package/sdk/deps/trezor-crypto/src/sodium/private/ed25519_ref10.c +481 -0
  181. package/sdk/deps/trezor-crypto/src/sodium/private/ed25519_ref10_fe_25_5.c +885 -0
  182. package/sdk/deps/trezor-crypto/src/sodium/private/fe_25_5/fe.c +237 -0
  183. package/sdk/gpc/include/scp03/scp03.hpp +80 -0
  184. package/sdk/gpc/include/scp11/scp11.hpp +492 -0
  185. package/sdk/gpc/include/scp11/scp11c.hpp +58 -0
  186. package/sdk/gpc/include/tag.h +68 -0
  187. package/sdk/gpc/include/tlv.hpp +94 -0
  188. package/sdk/gpc/include/tlvparse.hpp +24 -0
  189. package/sdk/gpc/src/scp03.cpp +243 -0
  190. package/sdk/gpc/src/scp11.cpp +798 -0
  191. package/sdk/gpc/src/scp11c.cpp +136 -0
  192. package/sdk/gpc/src/tlv.cpp +159 -0
  193. package/sdk/gpc/src/tlvparse.c +174 -0
  194. package/{framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers → sdk/include}/GPChannelSDK.h +0 -0
  195. package/sdk/include/GPChannelSDKCore.h +10 -0
  196. package/sdk/include/context/BaseContext.h +56 -0
  197. package/sdk/include/device/ApduBuilder.hpp +72 -0
  198. package/sdk/include/mSIGNA/stdutils/uchar_vector.h +36 -0
  199. package/sdk/include/utility/Apdu.hpp +172 -0
  200. package/sdk/include/utility/Debug.hpp +3 -0
  201. package/sdk/include/utility/util.h +104 -0
  202. package/sdk/src/ApduBuilder.cpp +332 -0
  203. package/sdk/src/GPChannelSDK.cpp +252 -0
  204. package/sdk/src/random.c +25 -0
  205. package/sdk/src/version.c +2 -0
  206. package/sdk/tests/android/GPChannelProxy.java +55 -0
  207. package/sdk/tests/android_verify.py +121 -0
  208. package/sdk/tests/safety.cpp +603 -0
  209. package/sdk/tests/verify.py +267 -0
  210. package/android/src/main/jniLibs/arm64-v8a/libgpchannelNDK.so +0 -0
  211. package/android/src/main/jniLibs/armeabi-v7a/libgpchannelNDK.so +0 -0
  212. package/framework/GPChannelSDKCore.xcframework/Info.plist +0 -52
  213. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
  214. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +0 -19
  215. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Info.plist +0 -0
  216. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Modules/module.modulemap +0 -7
  217. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/_CodeSignature/CodeResources +0 -147
  218. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
  219. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDK.h +0 -315
  220. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +0 -19
  221. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Info.plist +0 -0
  222. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Modules/module.modulemap +0 -7
  223. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/_CodeSignature/CodeResources +0 -147
package/sdk/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # OneKey Lite GPChannel SDK source recovery
2
+
3
+ A standalone, buildable reconstruction of the binary GPChannel core used by
4
+ `@onekeyfe/react-native-lite-card`. The native NFC transport and React Native
5
+ wrapper already have source in the parent package. This directory restores the
6
+ missing C++ core, its JNI adapter, source dependencies and documentation.
7
+
8
+ **Status:** source recovery integrated into the package's native builds and
9
+ release file list. CocoaPods compiles the core on iOS; Android CMake builds the
10
+ JNI library. Source, simulator/JNI and cryptographic vector evidence are separate
11
+ from physical-card and wallet-app acceptance.
12
+
13
+ See the package [behavior contract](../docs/SPEC.md).
14
+
15
+ ## Build from source
16
+
17
+ Prerequisites: CMake 3.16+, a C/C++ compiler, Xcode for Apple targets and an Android
18
+ NDK for Android targets. All SDK source dependencies are checked in; no vendor
19
+ `.a`, `.so`, framework or network download participates in compilation.
20
+ Run these commands from this directory, with output directories of your choice.
21
+
22
+ Host library and focused native checks:
23
+
24
+ ```sh
25
+ cmake -S . -B build-host -DCMAKE_BUILD_TYPE=Release
26
+ cmake --build build-host -j 4
27
+ ctest --test-dir build-host --output-on-failure
28
+ ```
29
+
30
+ Android (set `ANDROID_NDK` to your installed NDK directory; repeat for
31
+ `armeabi-v7a` when needed):
32
+
33
+ ```sh
34
+ cmake -S . -B build-android-arm64 \
35
+ -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
36
+ -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-24 \
37
+ -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
38
+ cmake --build build-android-arm64 -j 4
39
+ ```
40
+
41
+ `libgpchannelNDK.so` embeds the recovered core and retains the original JNI class,
42
+ method names, signatures and JSON fields. It does not depend on a second
43
+ `libGPChannelSDKCore.so`. The latter is also produced for standalone core users.
44
+ Strip copies of release artifacts as needed; preserve unstripped files for debug
45
+ symbols. The React Native package builds `keys` and `gpchannelNDK` directly from
46
+ its Android CMake entry point.
47
+
48
+ Apple frameworks (device and both simulator architectures):
49
+
50
+ ```sh
51
+ cmake -S . -B build-ios-device -G Xcode \
52
+ -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos \
53
+ -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=15.0 \
54
+ -DBUILD_TESTING=OFF
55
+ cmake --build build-ios-device --config Release -j 4
56
+ cmake -S . -B build-ios-simulator -G Xcode \
57
+ -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator \
58
+ '-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64' \
59
+ -DCMAKE_OSX_DEPLOYMENT_TARGET=15.0 -DBUILD_TESTING=OFF
60
+ cmake --build build-ios-simulator --config Release -j 4
61
+ xcodebuild -create-xcframework \
62
+ -framework build-ios-device/Release-iphoneos/GPChannelSDKCore.framework \
63
+ -framework build-ios-simulator/Release-iphonesimulator/GPChannelSDKCore.framework \
64
+ -output build-artifacts/GPChannelSDKCore.xcframework
65
+ ```
66
+
67
+ Use an output path that does not already exist for `-create-xcframework`.
68
+ `GPChannelSDK.h` retains the vendor ABI, including its C++ reference parameter;
69
+ include it from C++/Objective-C++, not a pure C translation unit.
70
+
71
+ ## API and lifecycle
72
+
73
+ | API | Contract |
74
+ | --- | --- |
75
+ | `JUB_GPC_TLVDecode` | Decode one supported vendor TLV; return numeric tag and hex value. |
76
+ | `JUB_GPC_ParseCertificate` | Parse the ASCII serial and hex subject identifier. Parsing does not authenticate a certificate or check its dates. |
77
+ | `JUB_GPC_Initialize` | Configure SCP11c, OCE certificate/key, host/group identifiers; generate a fresh ephemeral key pair. The recovered entry point accepts the existing AES-128 parameters. |
78
+ | `JUB_GPC_BuildMutualAuthData` | Build the mutual-authentication data after initialization. |
79
+ | `JUB_GPC_OpenSecureChannel` | Derive session keys and verify the card receipt; open only on success. |
80
+ | `JUB_GPC_BuildAPDU` / `JUB_GPC_ParseAPDUResponse` | Encode a plain command / separate response data and the status word. |
81
+ | `JUB_GPC_BuildSafeAPDU` / `JUB_GPC_ParseSafeAPDUResponse` | Encrypt/authenticate a command and authenticate/decrypt its response using the session state. |
82
+ | `JUB_GPC_Finalize` | Clear/release the session. Repeated finalization succeeds. |
83
+ | `JUB_FreeMemory` | Release an SDK output exactly once, including empty strings. |
84
+
85
+ Library return code `0` means the SDK operation succeeded. An APDU status word is
86
+ separate: callers must still check `wRet`, including PIN-retry status words.
87
+ All hexadecimal outputs use lowercase. The public header defines the error codes:
88
+ `1` operation error, `3` bad arguments, `5` null pointer, `6` unavailable session,
89
+ `8` invalid allocation pointer, and `10` response buffer too small.
90
+
91
+ The normal operation sequence is:
92
+
93
+ 1. Read the card certificate using the existing transport. Parse it and check the
94
+ device serial/identity using the existing caller policy.
95
+ 2. Initialize and send the OCE certificate with the existing PSO command.
96
+ 3. Build/send the mutual-authentication command; open using the returned receipt.
97
+ 4. Call safe command/response functions in pairs. They mutate shared MAC/counter
98
+ state. Serialize entire card sessions, not merely individual SDK calls.
99
+ 5. Finalize on completion, NFC disconnect, cancellation or a SELECT command.
100
+ After a failed operation, finalize and reopen before starting a new operation.
101
+
102
+ The native core owns one process-wide session per loaded library instance. It is
103
+ shared underneath separate main/background JS runtimes on iOS and Android.
104
+ The API has per-call locking; it does not support concurrent independent sessions.
105
+ There is no persistent cache. Returned allocations remain caller-owned across
106
+ finalization and must be freed separately.
107
+
108
+ ## Preserved platform differences
109
+
110
+ These were observed against the installed binaries and retained explicitly:
111
+
112
+ | Behavior | iOS / host reference | Android |
113
+ | --- | --- | --- |
114
+ | Plain response with 1–5 data bytes plus SW | Rejected by the vendor parser | Accepted |
115
+ | SCP03 ICV counter encoding | Low eight bits in the last byte | Full 32-bit big-endian value in the last four bytes |
116
+ | Non-success protected SW | Advance counter; recovered output is empty | Require valid MAC and decrypt the authenticated payload |
117
+
118
+ The recovery does not silently change the legacy iOS counter behavior. Reference
119
+ checks include exchanges across counter 255/256 to prevent collapsing the two
120
+ platform implementations into an incorrect common behavior. A future protocol
121
+ change requires its own card compatibility and cryptographic review.
122
+
123
+ ## Deliberate safety differences
124
+
125
+ These are reconstruction decisions, not claims of byte-for-byte original source:
126
+
127
+ - Missing contexts and null pointers return errors instead of assertion aborts.
128
+ - Hex and TLV lengths are bounded and validated before memory reads. Certificate
129
+ inputs are limited to 1024 bytes, plain command data to 65535 bytes, and safe
130
+ command data to 65511 bytes. Parsed plaintext uses the vendor's 1024-byte buffer.
131
+ - Incomplete certificates/receipts, unsupported public TLV tags and malformed
132
+ protected responses are rejected. A non-success SW is returned only according to the platform authentication rules above.
133
+ - On iOS a safe error-only response returns empty data; the iOS vendor wrapper could
134
+ instead return its entire zero-filled 1024-byte scratch buffer.
135
+ - Empty outputs enter the allocation registry and can be freed. Finalization and
136
+ reinitialization release context objects instead of losing their pointers.
137
+ - JNI UTF strings have scoped ownership; the initialization key-length string
138
+ remains alive for the complete native call.
139
+ - Debug logging is always disabled. Interrupted/short entropy reads are handled;
140
+ entropy failure terminates instead of returning partially initialized bytes.
141
+
142
+ The upstream cryptographic primitives remain unchanged. Existing vendor protocol
143
+ choices, certificate trust policy and sensitive-memory clearing still require a
144
+ separate production security review; passing vectors do not prove those policies.
145
+
146
+ ## Verification
147
+
148
+ `tests/verify.py` checks each SDK transcript against an independent implementation
149
+ of P-256 ECDH, SHA-1 preprocessing, KDF2/SHA-256, AES-CMAC and AES-CBC. It compares
150
+ plain APDU/TLV/certificate outputs, fresh sessions, bad receipts, modified response
151
+ MACs, encrypted payload boundaries, response limits and counter rollover. Reference
152
+ and recovery use independent random ephemeral keys; protocol code and entropy
153
+ functions in the reference are not patched.
154
+
155
+ ```sh
156
+ python3 -m venv .venv
157
+ .venv/bin/pip install cryptography
158
+ .venv/bin/python tests/verify.py \
159
+ --library build-host/libGPChannelSDKCore.dylib \
160
+ --reference /path/to/disposable-host-reference.dylib \
161
+ --report /path/to/verification.json
162
+ ```
163
+
164
+ On Linux use the `.so` filename. Omit `--reference` for oracle-only verification.
165
+ The Python dependency is a test tool, not an application/SDK dependency.
166
+ `tests/safety.cpp` exercises 5000 malformed inputs and allocation/lifecycle checks;
167
+ run it with AddressSanitizer/UBSan compiler and linker flags when supported.
168
+
169
+ `tests/android/GPChannelProxy.java` and `tests/android_verify.py` run the same oracle
170
+ against real Android ART/JNI and a separately loaded original `.so` in an isolated
171
+ emulator.
172
+
173
+ Physical Lite cards, NFC transport, real PIN/backup operations, the React Native
174
+ app flow and Android armv7 runtime remain separate acceptance requirements. No
175
+ production credentials are included or read by these tests.
@@ -0,0 +1,177 @@
1
+ // Recovered JNI contract from ziancube/GPChannel-test.
2
+ #include <jni.h>
3
+ #include <atomic>
4
+ #include <string>
5
+ #include "GPChannelSDK.h"
6
+ #include "json/json.h"
7
+
8
+ namespace {
9
+ std::atomic<int> errorCode{0};
10
+ class UtfChars {
11
+ public:
12
+ UtfChars(JNIEnv* env, jstring value) : env(env), value(value),
13
+ chars(value ? env->GetStringUTFChars(value, nullptr) : nullptr) {}
14
+ ~UtfChars() { if (chars) env->ReleaseStringUTFChars(value, chars); }
15
+ const char* get() const { return chars; }
16
+ private:
17
+ JNIEnv* env;
18
+ jstring value;
19
+ const char* chars;
20
+ };
21
+ class Output {
22
+ public:
23
+ char* value = nullptr;
24
+ ~Output() { if (value) JUB_FreeMemory(value); }
25
+ };
26
+ jstring json(JNIEnv* env, const Json::Value& value) {
27
+ return env->NewStringUTF(Json::FastWriter().write(value).c_str());
28
+ }
29
+ jstring result(JNIEnv* env, JUB_RV code, const Output& output) {
30
+ if (code != JUBR_OK) { errorCode.store(static_cast<int>(code)); return nullptr; }
31
+ return env->NewStringUTF(output.value);
32
+ }
33
+ jint getError(JNIEnv*, jobject) { return errorCode.load(); }
34
+ jint initialize(JNIEnv* env, jobject, jstring input) {
35
+ try {
36
+ UtfChars text(env, input);
37
+ if (!text.get()) return JUBR_ARGUMENTS_BAD;
38
+ Json::Value root;
39
+ Json::Reader reader;
40
+ if (!reader.parse(text.get(), root) || !root.isObject()) return JUBR_ARGUMENTS_BAD;
41
+ const char* fields[] = {"scpID", "keyUsage", "keyType", "hostID", "cardGroupID", "crt", "sk"};
42
+ for (const char* name : fields) if (!root[name].isString()) return JUBR_ARGUMENTS_BAD;
43
+ if (!root["keyLength"].isUInt() || root["keyLength"].asUInt() != 16) return JUBR_ARGUMENTS_BAD;
44
+ GPC_SCP11_SHAREDINFO info{
45
+ const_cast<char*>(root["scpID"].asCString()),
46
+ const_cast<char*>(root["keyUsage"].asCString()),
47
+ const_cast<char*>(root["keyType"].asCString()),
48
+ const_cast<char*>("10"),
49
+ const_cast<char*>(root["hostID"].asCString()),
50
+ const_cast<char*>(root["cardGroupID"].asCString())};
51
+ return static_cast<jint>(JUB_GPC_Initialize(info, root["crt"].asCString(), root["sk"].asCString()));
52
+ } catch (...) {
53
+ errorCode.store(static_cast<int>(JUBR_ARGUMENTS_BAD));
54
+ return JUBR_ARGUMENTS_BAD;
55
+ }
56
+ }
57
+ jint finalize(JNIEnv*, jobject) {
58
+ try {
59
+ return static_cast<jint>(JUB_GPC_Finalize());
60
+ } catch (...) {
61
+ return JUBR_ERROR;
62
+ }
63
+ }
64
+ jint open(JNIEnv* env, jobject, jstring input) {
65
+ try {
66
+ UtfChars text(env, input);
67
+ if (!text.get()) return JUBR_ARGUMENTS_BAD;
68
+ return static_cast<jint>(JUB_GPC_OpenSecureChannel(text.get()));
69
+ } catch (...) {
70
+ errorCode.store(static_cast<int>(JUBR_ARGUMENTS_BAD));
71
+ return JUBR_ARGUMENTS_BAD;
72
+ }
73
+ }
74
+ jstring mutual(JNIEnv* env, jobject) {
75
+ try {
76
+ Output output;
77
+ auto code = JUB_GPC_BuildMutualAuthData(&output.value);
78
+ return result(env, code, output);
79
+ } catch (...) {
80
+ errorCode.store(static_cast<int>(JUBR_ERROR));
81
+ return nullptr;
82
+ }
83
+ }
84
+ jstring build(JNIEnv* env, bool safe, jlong cla, jlong ins, jlong p1, jlong p2, jstring input) {
85
+ try {
86
+ UtfChars text(env, input);
87
+ Output output;
88
+ auto code = safe ? JUB_GPC_BuildSafeAPDU(cla, ins, p1, p2, text.get(), &output.value)
89
+ : JUB_GPC_BuildAPDU(cla, ins, p1, p2, text.get(), &output.value);
90
+ return result(env, code, output);
91
+ } catch (...) {
92
+ errorCode.store(static_cast<int>(JUBR_ERROR));
93
+ return nullptr;
94
+ }
95
+ }
96
+ jstring buildPlain(JNIEnv* env, jobject, jlong cla, jlong ins, jlong p1, jlong p2, jstring input) {
97
+ return build(env, false, cla, ins, p1, p2, input);
98
+ }
99
+ jstring buildSafe(JNIEnv* env, jobject, jlong cla, jlong ins, jlong p1, jlong p2, jstring input) {
100
+ return build(env, true, cla, ins, p1, p2, input);
101
+ }
102
+ jstring parse(JNIEnv* env, bool safe, jstring input) {
103
+ try {
104
+ UtfChars text(env, input);
105
+ Output output;
106
+ JUB_UINT16 word = 0;
107
+ auto code = safe ? JUB_GPC_ParseSafeAPDUResponse(text.get(), &word, &output.value)
108
+ : JUB_GPC_ParseAPDUResponse(text.get(), &word, &output.value);
109
+ if (code != JUBR_OK) { errorCode.store(static_cast<int>(code)); return nullptr; }
110
+ Json::Value root;
111
+ root["wRet"] = word;
112
+ root["response"] = output.value;
113
+ return json(env, root);
114
+ } catch (...) {
115
+ errorCode.store(static_cast<int>(JUBR_ERROR));
116
+ return nullptr;
117
+ }
118
+ }
119
+ jstring parsePlain(JNIEnv* env, jobject, jstring input) { return parse(env, false, input); }
120
+ jstring parseSafe(JNIEnv* env, jobject, jstring input) { return parse(env, true, input); }
121
+ jstring decodeTLV(JNIEnv* env, jobject, jstring input) {
122
+ try {
123
+ UtfChars text(env, input);
124
+ Output output;
125
+ JUB_ULONG tag = 0;
126
+ auto code = JUB_GPC_TLVDecode(text.get(), &tag, &output.value);
127
+ if (code != JUBR_OK) { errorCode.store(static_cast<int>(code)); return nullptr; }
128
+ Json::Value root;
129
+ root["tag"] = static_cast<Json::Int64>(tag);
130
+ root["value"] = output.value;
131
+ return json(env, root);
132
+ } catch (...) {
133
+ errorCode.store(static_cast<int>(JUBR_ERROR));
134
+ return nullptr;
135
+ }
136
+ }
137
+ jstring parseCertificate(JNIEnv* env, jobject, jstring input) {
138
+ try {
139
+ UtfChars text(env, input);
140
+ Output serial, subject;
141
+ auto code = JUB_GPC_ParseCertificate(text.get(), &serial.value, &subject.value);
142
+ if (code != JUBR_OK) { errorCode.store(static_cast<int>(code)); return nullptr; }
143
+ Json::Value root;
144
+ root["sn"] = serial.value;
145
+ root["subjectID"] = subject.value;
146
+ return json(env, root);
147
+ } catch (...) {
148
+ errorCode.store(static_cast<int>(JUBR_ERROR));
149
+ return nullptr;
150
+ }
151
+ }
152
+ #define METHOD(name, signature, function) \
153
+ {const_cast<char*>(name), const_cast<char*>(signature), reinterpret_cast<void*>(function)}
154
+ JNINativeMethod methods[] = {
155
+ METHOD("nativeGetErrorCode", "()I", getError),
156
+ METHOD("nativeGPCInitialize", "(Ljava/lang/String;)I", initialize),
157
+ METHOD("nativeGPCFinalize", "()I", finalize),
158
+ METHOD("nativeGPCBuildMutualAuthData", "()Ljava/lang/String;", mutual),
159
+ METHOD("nativeGPCOpenSecureChannel", "(Ljava/lang/String;)I", open),
160
+ METHOD("nativeGPCBuildAPDU", "(JJJJLjava/lang/String;)Ljava/lang/String;", buildPlain),
161
+ METHOD("nativeGPCBuildSafeAPDU", "(JJJJLjava/lang/String;)Ljava/lang/String;", buildSafe),
162
+ METHOD("nativeGPCParseSafeAPDUResponse", "(Ljava/lang/String;)Ljava/lang/String;", parseSafe),
163
+ METHOD("nativeGPCParseAPDUResponse", "(Ljava/lang/String;)Ljava/lang/String;", parsePlain),
164
+ METHOD("nativeGPCTLVDecode", "(Ljava/lang/String;)Ljava/lang/String;", decodeTLV),
165
+ METHOD("nativeGPCParseCertificate", "(Ljava/lang/String;)Ljava/lang/String;", parseCertificate)
166
+ };
167
+ #undef METHOD
168
+ }
169
+ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
170
+ JNIEnv* env = nullptr;
171
+ if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) return JNI_ERR;
172
+ jclass type = env->FindClass("org/haobtc/onekey/card/gpchannel/GPChannelNatives");
173
+ if (!type) return JNI_ERR;
174
+ auto code = env->RegisterNatives(type, methods, sizeof(methods) / sizeof(methods[0]));
175
+ env->DeleteLocalRef(type);
176
+ return code < 0 ? JNI_ERR : JNI_VERSION_1_6;
177
+ }
@@ -0,0 +1,55 @@
1
+ The JsonCpp library's source code, including accompanying documentation,
2
+ tests and demonstration applications, are licensed under the following
3
+ conditions...
4
+
5
+ Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
6
+ jurisdictions which recognize such a disclaimer. In such jurisdictions,
7
+ this software is released into the Public Domain.
8
+
9
+ In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
10
+ 2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
11
+ The JsonCpp Authors, and is released under the terms of the MIT License (see below).
12
+
13
+ In jurisdictions which recognize Public Domain property, the user of this
14
+ software may choose to accept it either as 1) Public Domain, 2) under the
15
+ conditions of the MIT License (see below), or 3) under the terms of dual
16
+ Public Domain/MIT License conditions described here, as they choose.
17
+
18
+ The MIT License is about as close to Public Domain as a license can get, and is
19
+ described in clear, concise terms at:
20
+
21
+ http://en.wikipedia.org/wiki/MIT_License
22
+
23
+ The full text of the MIT License follows:
24
+
25
+ ========================================================================
26
+ Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
27
+
28
+ Permission is hereby granted, free of charge, to any person
29
+ obtaining a copy of this software and associated documentation
30
+ files (the "Software"), to deal in the Software without
31
+ restriction, including without limitation the rights to use, copy,
32
+ modify, merge, publish, distribute, sublicense, and/or sell copies
33
+ of the Software, and to permit persons to whom the Software is
34
+ furnished to do so, subject to the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be
37
+ included in all copies or substantial portions of the Software.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
40
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
41
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
42
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
43
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
44
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
45
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
46
+ SOFTWARE.
47
+ ========================================================================
48
+ (END LICENSE TEXT)
49
+
50
+ The MIT license is compatible with both the GPL and commercial
51
+ software, affording one all of the rights of Public Domain with the
52
+ minor nuisance of being required to keep the above copyright notice
53
+ and license text in the source code. Note also that by accepting the
54
+ Public Domain "license" you can re-license your copy using whatever
55
+ license you like.
@@ -0,0 +1,2 @@
1
+ FILE(GLOB INCLUDE_FILES "json/*.h")
2
+ INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json)
@@ -0,0 +1,98 @@
1
+ // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
2
+ // Distributed under MIT license, or public domain if desired and
3
+ // recognized in your jurisdiction.
4
+ // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5
+
6
+ #ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED
7
+ #define CPPTL_JSON_ALLOCATOR_H_INCLUDED
8
+
9
+ #include <cstring>
10
+ #include <memory>
11
+
12
+ #pragma pack(push, 8)
13
+
14
+ namespace Json {
15
+ template<typename T>
16
+ class SecureAllocator {
17
+ public:
18
+ // Type definitions
19
+ using value_type = T;
20
+ using pointer = T*;
21
+ using const_pointer = const T*;
22
+ using reference = T&;
23
+ using const_reference = const T&;
24
+ using size_type = std::size_t;
25
+ using difference_type = std::ptrdiff_t;
26
+
27
+ /**
28
+ * Allocate memory for N items using the standard allocator.
29
+ */
30
+ pointer allocate(size_type n) {
31
+ // allocate using "global operator new"
32
+ return static_cast<pointer>(::operator new(n * sizeof(T)));
33
+ }
34
+
35
+ /**
36
+ * Release memory which was allocated for N items at pointer P.
37
+ *
38
+ * The memory block is filled with zeroes before being released.
39
+ * The pointer argument is tagged as "volatile" to prevent the
40
+ * compiler optimizing out this critical step.
41
+ */
42
+ void deallocate(volatile pointer p, size_type n) {
43
+ std::memset(p, 0, n * sizeof(T));
44
+ // free using "global operator delete"
45
+ ::operator delete(p);
46
+ }
47
+
48
+ /**
49
+ * Construct an item in-place at pointer P.
50
+ */
51
+ template<typename... Args>
52
+ void construct(pointer p, Args&&... args) {
53
+ // construct using "placement new" and "perfect forwarding"
54
+ ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
55
+ }
56
+
57
+ size_type max_size() const {
58
+ return size_t(-1) / sizeof(T);
59
+ }
60
+
61
+ pointer address( reference x ) const {
62
+ return std::addressof(x);
63
+ }
64
+
65
+ const_pointer address( const_reference x ) const {
66
+ return std::addressof(x);
67
+ }
68
+
69
+ /**
70
+ * Destroy an item in-place at pointer P.
71
+ */
72
+ void destroy(pointer p) {
73
+ // destroy using "explicit destructor"
74
+ p->~T();
75
+ }
76
+
77
+ // Boilerplate
78
+ SecureAllocator() {}
79
+ template<typename U> SecureAllocator(const SecureAllocator<U>&) {}
80
+ template<typename U> struct rebind { using other = SecureAllocator<U>; };
81
+ };
82
+
83
+
84
+ template<typename T, typename U>
85
+ bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
86
+ return true;
87
+ }
88
+
89
+ template<typename T, typename U>
90
+ bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
91
+ return false;
92
+ }
93
+
94
+ } //namespace Json
95
+
96
+ #pragma pack(pop)
97
+
98
+ #endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED
@@ -0,0 +1,54 @@
1
+ // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
2
+ // Distributed under MIT license, or public domain if desired and
3
+ // recognized in your jurisdiction.
4
+ // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5
+
6
+ #ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED
7
+ #define CPPTL_JSON_ASSERTIONS_H_INCLUDED
8
+
9
+ #include <stdlib.h>
10
+ #include <sstream>
11
+
12
+ #if !defined(JSON_IS_AMALGAMATION)
13
+ #include "config.h"
14
+ #endif // if !defined(JSON_IS_AMALGAMATION)
15
+
16
+ /** It should not be possible for a maliciously designed file to
17
+ * cause an abort() or seg-fault, so these macros are used only
18
+ * for pre-condition violations and internal logic errors.
19
+ */
20
+ #if JSON_USE_EXCEPTION
21
+
22
+ // @todo <= add detail about condition in exception
23
+ # define JSON_ASSERT(condition) \
24
+ {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
25
+
26
+ # define JSON_FAIL_MESSAGE(message) \
27
+ { \
28
+ JSONCPP_OSTRINGSTREAM oss; oss << message; \
29
+ Json::throwLogicError(oss.str()); \
30
+ abort(); \
31
+ }
32
+
33
+ #else // JSON_USE_EXCEPTION
34
+
35
+ # define JSON_ASSERT(condition) assert(condition)
36
+
37
+ // The call to assert() will show the failure message in debug builds. In
38
+ // release builds we abort, for a core-dump or debugger.
39
+ # define JSON_FAIL_MESSAGE(message) \
40
+ { \
41
+ JSONCPP_OSTRINGSTREAM oss; oss << message; \
42
+ assert(false && oss.str().c_str()); \
43
+ abort(); \
44
+ }
45
+
46
+
47
+ #endif
48
+
49
+ #define JSON_ASSERT_MESSAGE(condition, message) \
50
+ if (!(condition)) { \
51
+ JSON_FAIL_MESSAGE(message); \
52
+ }
53
+
54
+ #endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
@@ -0,0 +1,25 @@
1
+ // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
2
+ // Distributed under MIT license, or public domain if desired and
3
+ // recognized in your jurisdiction.
4
+ // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5
+
6
+ #ifndef JSON_AUTOLINK_H_INCLUDED
7
+ #define JSON_AUTOLINK_H_INCLUDED
8
+
9
+ #include "config.h"
10
+
11
+ #ifdef JSON_IN_CPPTL
12
+ #include <cpptl/cpptl_autolink.h>
13
+ #endif
14
+
15
+ #if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && \
16
+ !defined(JSON_IN_CPPTL)
17
+ #define CPPTL_AUTOLINK_NAME "json"
18
+ #undef CPPTL_AUTOLINK_DLL
19
+ #ifdef JSON_DLL
20
+ #define CPPTL_AUTOLINK_DLL
21
+ #endif
22
+ #include "autolink.h"
23
+ #endif
24
+
25
+ #endif // JSON_AUTOLINK_H_INCLUDED