@onekeyfe/react-native-lite-card 6.7.0-21 → 6.7.0-23

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 (227) 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/ReactNativeLiteCardModule.kt +29 -11
  6. package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/gpchannel/GPChannelNatives.kt +7 -7
  7. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/OnekeyLiteCard.kt +14 -3
  8. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/SendResponse.kt +6 -3
  9. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/CommandGenerator.kt +5 -1
  10. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/Connection.kt +36 -17
  11. package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/GPCAPDUGenerator.kt +2 -2
  12. package/ios/Classes/OKLiteCommand/OKLiteCommandTool.m +4 -1
  13. package/ios/Classes/OKNFCBridge.mm +1 -1
  14. package/ios/Classes/OKNFTLite/OKLiteV1.m +6 -3
  15. package/ios/Classes/OKNFTLite/OKLiteV2.m +13 -5
  16. package/ios/Classes/OKNFTLite/OKNFCManager.m +26 -6
  17. package/ios/ReactNativeLiteCard.mm +16 -7
  18. package/package.json +8 -8
  19. package/sdk/CMakeLists.txt +120 -0
  20. package/sdk/README.md +175 -0
  21. package/sdk/android/implJni.cpp +177 -0
  22. package/sdk/deps/jsoncpp/LICENSE +55 -0
  23. package/sdk/deps/jsoncpp/include/CMakeLists.txt +2 -0
  24. package/sdk/deps/jsoncpp/include/json/allocator.h +98 -0
  25. package/sdk/deps/jsoncpp/include/json/assertions.h +54 -0
  26. package/sdk/deps/jsoncpp/include/json/autolink.h +25 -0
  27. package/sdk/deps/jsoncpp/include/json/config.h +187 -0
  28. package/sdk/deps/jsoncpp/include/json/features.h +61 -0
  29. package/sdk/deps/jsoncpp/include/json/forwards.h +37 -0
  30. package/sdk/deps/jsoncpp/include/json/json.h +15 -0
  31. package/sdk/deps/jsoncpp/include/json/reader.h +411 -0
  32. package/sdk/deps/jsoncpp/include/json/value.h +888 -0
  33. package/sdk/deps/jsoncpp/include/json/version.h +20 -0
  34. package/sdk/deps/jsoncpp/include/json/writer.h +357 -0
  35. package/sdk/deps/jsoncpp/src/lib_json/CMakeLists.txt +117 -0
  36. package/sdk/deps/jsoncpp/src/lib_json/json_reader.cpp +2060 -0
  37. package/sdk/deps/jsoncpp/src/lib_json/json_tool.h +114 -0
  38. package/sdk/deps/jsoncpp/src/lib_json/json_value.cpp +1661 -0
  39. package/sdk/deps/jsoncpp/src/lib_json/json_valueiterator.inl +167 -0
  40. package/sdk/deps/jsoncpp/src/lib_json/json_writer.cpp +1233 -0
  41. package/sdk/deps/jsoncpp/src/lib_json/version.h.in +20 -0
  42. package/sdk/deps/trezor-crypto/AUTHORS +2 -0
  43. package/sdk/deps/trezor-crypto/LICENSE +22 -0
  44. package/sdk/deps/trezor-crypto/include/TrezorCrypto/TrezorCrypto.h +29 -0
  45. package/sdk/deps/trezor-crypto/include/TrezorCrypto/address.h +44 -0
  46. package/sdk/deps/trezor-crypto/include/TrezorCrypto/aes.h +224 -0
  47. package/sdk/deps/trezor-crypto/include/TrezorCrypto/base32.h +49 -0
  48. package/sdk/deps/trezor-crypto/include/TrezorCrypto/base58.h +58 -0
  49. package/sdk/deps/trezor-crypto/include/TrezorCrypto/bignum.h +169 -0
  50. package/sdk/deps/trezor-crypto/include/TrezorCrypto/bip32.h +114 -0
  51. package/sdk/deps/trezor-crypto/include/TrezorCrypto/bip39.h +66 -0
  52. package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake256.h +61 -0
  53. package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake2b.h +50 -0
  54. package/sdk/deps/trezor-crypto/include/TrezorCrypto/blake2s.h +49 -0
  55. package/sdk/deps/trezor-crypto/include/TrezorCrypto/cash_addr.h +109 -0
  56. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-config.h +316 -0
  57. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-sync.h +289 -0
  58. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/ecrypt-types.h +53 -0
  59. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305/poly1305-donna.h +28 -0
  60. package/sdk/deps/trezor-crypto/include/TrezorCrypto/chacha20poly1305.h +27 -0
  61. package/sdk/deps/trezor-crypto/include/TrezorCrypto/cmac.h +44 -0
  62. package/sdk/deps/trezor-crypto/include/TrezorCrypto/curves.h +60 -0
  63. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ecdsa.h +112 -0
  64. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/curve25519-donna-32bit.h +87 -0
  65. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/curve25519-donna-helpers.h +30 -0
  66. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-blake2b.h +21 -0
  67. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-32bit-tables.h +25 -0
  68. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-basepoint-table.h +10 -0
  69. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-impl-base.h +110 -0
  70. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna-portable.h +32 -0
  71. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-donna.h +60 -0
  72. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-keccak.h +21 -0
  73. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/ed25519-sha3.h +21 -0
  74. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna/modm-donna-32bit.h +87 -0
  75. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519-donna.h +60 -0
  76. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ed25519.h +42 -0
  77. package/sdk/deps/trezor-crypto/include/TrezorCrypto/endian.h +132 -0
  78. package/sdk/deps/trezor-crypto/include/TrezorCrypto/groestl.h +104 -0
  79. package/sdk/deps/trezor-crypto/include/TrezorCrypto/hasher.h +90 -0
  80. package/sdk/deps/trezor-crypto/include/TrezorCrypto/hmac.h +60 -0
  81. package/sdk/deps/trezor-crypto/include/TrezorCrypto/memzero.h +16 -0
  82. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/base58.h +42 -0
  83. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/monero.h +13 -0
  84. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/range_proof.h +30 -0
  85. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/serialize.h +15 -0
  86. package/sdk/deps/trezor-crypto/include/TrezorCrypto/monero/xmr.h +67 -0
  87. package/sdk/deps/trezor-crypto/include/TrezorCrypto/nano.h +56 -0
  88. package/sdk/deps/trezor-crypto/include/TrezorCrypto/nem.h +199 -0
  89. package/sdk/deps/trezor-crypto/include/TrezorCrypto/nist256p1.h +35 -0
  90. package/sdk/deps/trezor-crypto/include/TrezorCrypto/pbkdf2.h +64 -0
  91. package/sdk/deps/trezor-crypto/include/TrezorCrypto/rand.h +44 -0
  92. package/sdk/deps/trezor-crypto/include/TrezorCrypto/rc4.h +37 -0
  93. package/sdk/deps/trezor-crypto/include/TrezorCrypto/rfc6979.h +40 -0
  94. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ripemd160.h +28 -0
  95. package/sdk/deps/trezor-crypto/include/TrezorCrypto/ripple/base58.h +45 -0
  96. package/sdk/deps/trezor-crypto/include/TrezorCrypto/schnorr.h +48 -0
  97. package/sdk/deps/trezor-crypto/include/TrezorCrypto/script.h +30 -0
  98. package/sdk/deps/trezor-crypto/include/TrezorCrypto/scrypt.h +68 -0
  99. package/sdk/deps/trezor-crypto/include/TrezorCrypto/secp256k1.h +59 -0
  100. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sha2.h +125 -0
  101. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sha3.h +86 -0
  102. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/keypair.h +20 -0
  103. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/ed25519_ref10.h +85 -0
  104. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/ed25519_ref10_fe_25_5.h +43 -0
  105. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/fe_25_5/constants.h +29 -0
  106. package/sdk/deps/trezor-crypto/include/TrezorCrypto/sodium/private/fe_25_5/fe.h +25 -0
  107. package/sdk/deps/trezor-crypto/src/address.c +87 -0
  108. package/sdk/deps/trezor-crypto/src/aes/aes_modes.c +959 -0
  109. package/sdk/deps/trezor-crypto/src/aes/aescrypt.c +307 -0
  110. package/sdk/deps/trezor-crypto/src/aes/aeskey.c +560 -0
  111. package/sdk/deps/trezor-crypto/src/aes/aesopt.h +784 -0
  112. package/sdk/deps/trezor-crypto/src/aes/aestab.c +418 -0
  113. package/sdk/deps/trezor-crypto/src/aes/aestab.h +173 -0
  114. package/sdk/deps/trezor-crypto/src/base32.c +233 -0
  115. package/sdk/deps/trezor-crypto/src/base58.c +298 -0
  116. package/sdk/deps/trezor-crypto/src/bignum.c +808 -0
  117. package/sdk/deps/trezor-crypto/src/bip32.c +852 -0
  118. package/sdk/deps/trezor-crypto/src/bip39.c +266 -0
  119. package/sdk/deps/trezor-crypto/src/bip39_english.h +2074 -0
  120. package/sdk/deps/trezor-crypto/src/blake256.c +235 -0
  121. package/sdk/deps/trezor-crypto/src/blake2_common.h +39 -0
  122. package/sdk/deps/trezor-crypto/src/blake2b.c +333 -0
  123. package/sdk/deps/trezor-crypto/src/blake2s.c +318 -0
  124. package/sdk/deps/trezor-crypto/src/cash_addr.c +195 -0
  125. package/sdk/deps/trezor-crypto/src/chacha20poly1305/chacha20poly1305.c +60 -0
  126. package/sdk/deps/trezor-crypto/src/chacha20poly1305/chacha_merged.c +246 -0
  127. package/sdk/deps/trezor-crypto/src/chacha20poly1305/ecrypt-machine.h +49 -0
  128. package/sdk/deps/trezor-crypto/src/chacha20poly1305/ecrypt-portable.h +275 -0
  129. package/sdk/deps/trezor-crypto/src/chacha20poly1305/poly1305-donna-32.h +219 -0
  130. package/sdk/deps/trezor-crypto/src/chacha20poly1305/poly1305-donna.c +179 -0
  131. package/sdk/deps/trezor-crypto/src/chacha20poly1305/rfc7539.c +48 -0
  132. package/sdk/deps/trezor-crypto/src/chacha20poly1305/rfc7539.h +10 -0
  133. package/sdk/deps/trezor-crypto/src/check_mem.h +30 -0
  134. package/sdk/deps/trezor-crypto/src/cmac.c +342 -0
  135. package/sdk/deps/trezor-crypto/src/curves.c +48 -0
  136. package/sdk/deps/trezor-crypto/src/ecdsa.c +1355 -0
  137. package/sdk/deps/trezor-crypto/src/ed25519-donna/README.md +183 -0
  138. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-32bit.c +681 -0
  139. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-helpers.c +66 -0
  140. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-scalarmult-base.c +67 -0
  141. package/sdk/deps/trezor-crypto/src/ed25519-donna/curve25519-donna-scalarmult-base.h +8 -0
  142. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-blake2b.c +8 -0
  143. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-32bit-tables.c +63 -0
  144. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-basepoint-table.c +261 -0
  145. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-donna-impl-base.c +722 -0
  146. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-blake2b.h +23 -0
  147. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-keccak.h +23 -0
  148. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom-sha3.h +23 -0
  149. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-hash-custom.h +23 -0
  150. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-keccak.c +8 -0
  151. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519-sha3.c +8 -0
  152. package/sdk/deps/trezor-crypto/src/ed25519-donna/ed25519.c +311 -0
  153. package/sdk/deps/trezor-crypto/src/ed25519-donna/modm-donna-32bit.c +517 -0
  154. package/sdk/deps/trezor-crypto/src/groestl.c +783 -0
  155. package/sdk/deps/trezor-crypto/src/groestl_internal.h +419 -0
  156. package/sdk/deps/trezor-crypto/src/hasher.c +186 -0
  157. package/sdk/deps/trezor-crypto/src/hmac.c +179 -0
  158. package/sdk/deps/trezor-crypto/src/memzero.c +6 -0
  159. package/sdk/deps/trezor-crypto/src/monero/base58.c +245 -0
  160. package/sdk/deps/trezor-crypto/src/monero/int-util.h +77 -0
  161. package/sdk/deps/trezor-crypto/src/monero/range_proof.c +115 -0
  162. package/sdk/deps/trezor-crypto/src/monero/serialize.c +54 -0
  163. package/sdk/deps/trezor-crypto/src/monero/xmr.c +136 -0
  164. package/sdk/deps/trezor-crypto/src/nano.c +151 -0
  165. package/sdk/deps/trezor-crypto/src/nem.c +569 -0
  166. package/sdk/deps/trezor-crypto/src/nist256p1.c +63 -0
  167. package/sdk/deps/trezor-crypto/src/nist256p1.table +1664 -0
  168. package/sdk/deps/trezor-crypto/src/options.h +43 -0
  169. package/sdk/deps/trezor-crypto/src/pbkdf2.c +177 -0
  170. package/sdk/deps/trezor-crypto/src/rand.c +51 -0
  171. package/sdk/deps/trezor-crypto/src/rc4.c +56 -0
  172. package/sdk/deps/trezor-crypto/src/ripemd160.c +343 -0
  173. package/sdk/deps/trezor-crypto/src/ripple/base58.c +76 -0
  174. package/sdk/deps/trezor-crypto/src/schnorr.c +208 -0
  175. package/sdk/deps/trezor-crypto/src/script.c +64 -0
  176. package/sdk/deps/trezor-crypto/src/scrypt.c +343 -0
  177. package/sdk/deps/trezor-crypto/src/secp256k1.c +160 -0
  178. package/sdk/deps/trezor-crypto/src/secp256k1.table +1664 -0
  179. package/sdk/deps/trezor-crypto/src/setup.py +38 -0
  180. package/sdk/deps/trezor-crypto/src/sha2.c +1314 -0
  181. package/sdk/deps/trezor-crypto/src/sha3.c +395 -0
  182. package/sdk/deps/trezor-crypto/src/shell.nix +6 -0
  183. package/sdk/deps/trezor-crypto/src/sodium/keypair.c +63 -0
  184. package/sdk/deps/trezor-crypto/src/sodium/private/ed25519_ref10.c +481 -0
  185. package/sdk/deps/trezor-crypto/src/sodium/private/ed25519_ref10_fe_25_5.c +885 -0
  186. package/sdk/deps/trezor-crypto/src/sodium/private/fe_25_5/fe.c +237 -0
  187. package/sdk/gpc/include/scp03/scp03.hpp +80 -0
  188. package/sdk/gpc/include/scp11/scp11.hpp +492 -0
  189. package/sdk/gpc/include/scp11/scp11c.hpp +58 -0
  190. package/sdk/gpc/include/tag.h +68 -0
  191. package/sdk/gpc/include/tlv.hpp +94 -0
  192. package/sdk/gpc/include/tlvparse.hpp +24 -0
  193. package/sdk/gpc/src/scp03.cpp +243 -0
  194. package/sdk/gpc/src/scp11.cpp +798 -0
  195. package/sdk/gpc/src/scp11c.cpp +136 -0
  196. package/sdk/gpc/src/tlv.cpp +159 -0
  197. package/sdk/gpc/src/tlvparse.c +174 -0
  198. package/{framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers → sdk/include}/GPChannelSDK.h +0 -0
  199. package/sdk/include/GPChannelSDKCore.h +10 -0
  200. package/sdk/include/context/BaseContext.h +56 -0
  201. package/sdk/include/device/ApduBuilder.hpp +72 -0
  202. package/sdk/include/mSIGNA/stdutils/uchar_vector.h +36 -0
  203. package/sdk/include/utility/Apdu.hpp +172 -0
  204. package/sdk/include/utility/Debug.hpp +3 -0
  205. package/sdk/include/utility/util.h +104 -0
  206. package/sdk/src/ApduBuilder.cpp +332 -0
  207. package/sdk/src/GPChannelSDK.cpp +252 -0
  208. package/sdk/src/random.c +25 -0
  209. package/sdk/src/version.c +2 -0
  210. package/sdk/tests/android/GPChannelProxy.java +55 -0
  211. package/sdk/tests/android_verify.py +121 -0
  212. package/sdk/tests/safety.cpp +603 -0
  213. package/sdk/tests/verify.py +267 -0
  214. package/android/src/main/jniLibs/arm64-v8a/libgpchannelNDK.so +0 -0
  215. package/android/src/main/jniLibs/armeabi-v7a/libgpchannelNDK.so +0 -0
  216. package/framework/GPChannelSDKCore.xcframework/Info.plist +0 -52
  217. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
  218. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +0 -19
  219. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Info.plist +0 -0
  220. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Modules/module.modulemap +0 -7
  221. package/framework/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/_CodeSignature/CodeResources +0 -147
  222. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
  223. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDK.h +0 -315
  224. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +0 -19
  225. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Info.plist +0 -0
  226. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Modules/module.modulemap +0 -7
  227. package/framework/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/_CodeSignature/CodeResources +0 -147
@@ -0,0 +1,316 @@
1
+ /* ecrypt-config.h */
2
+
3
+ /* *** Normally, it should not be necessary to edit this file. *** */
4
+
5
+ #ifndef ECRYPT_CONFIG
6
+ #define ECRYPT_CONFIG
7
+
8
+ /* ------------------------------------------------------------------------- */
9
+
10
+ /* Guess the endianness of the target architecture. */
11
+
12
+ /*
13
+ * The LITTLE endian machines:
14
+ */
15
+ #if defined(__ultrix) /* Older MIPS */
16
+ #define ECRYPT_LITTLE_ENDIAN
17
+ #elif defined(__alpha) /* Alpha */
18
+ #define ECRYPT_LITTLE_ENDIAN
19
+ #elif defined(i386) /* x86 (gcc) */
20
+ #define ECRYPT_LITTLE_ENDIAN
21
+ #elif defined(__i386) /* x86 (gcc) */
22
+ #define ECRYPT_LITTLE_ENDIAN
23
+ #elif defined(__x86_64) /* x86_64 (gcc) */
24
+ #define ECRYPT_LITTLE_ENDIAN
25
+ #elif defined(_M_IX86) /* x86 (MSC, Borland) */
26
+ #define ECRYPT_LITTLE_ENDIAN
27
+ #elif defined(_MSC_VER) /* x86 (surely MSC) */
28
+ #define ECRYPT_LITTLE_ENDIAN
29
+ #elif defined(__INTEL_COMPILER) /* x86 (surely Intel compiler icl.exe) */
30
+ #define ECRYPT_LITTLE_ENDIAN
31
+
32
+ /*
33
+ * The BIG endian machines:
34
+ */
35
+ #elif defined(__sparc) /* Newer Sparc's */
36
+ #define ECRYPT_BIG_ENDIAN
37
+ #elif defined(__powerpc__) /* PowerPC */
38
+ #define ECRYPT_BIG_ENDIAN
39
+ #elif defined(__ppc__) /* PowerPC */
40
+ #define ECRYPT_BIG_ENDIAN
41
+ #elif defined(__hppa) /* HP-PA */
42
+ #define ECRYPT_BIG_ENDIAN
43
+
44
+ /*
45
+ * Finally machines with UNKNOWN endianness:
46
+ */
47
+ #elif defined (_AIX) /* RS6000 */
48
+ #define ECRYPT_UNKNOWN
49
+ #elif defined(__aux) /* 68K */
50
+ #define ECRYPT_UNKNOWN
51
+ #elif defined(__dgux) /* 88K (but P6 in latest boxes) */
52
+ #define ECRYPT_UNKNOWN
53
+ #elif defined(__sgi) /* Newer MIPS */
54
+ #define ECRYPT_UNKNOWN
55
+ #else /* Any other processor */
56
+ #define ECRYPT_UNKNOWN
57
+ #endif
58
+
59
+ /* ------------------------------------------------------------------------- */
60
+
61
+ /*
62
+ * Find minimal-width types to store 8-bit, 16-bit, 32-bit, and 64-bit
63
+ * integers.
64
+ *
65
+ * Note: to enable 64-bit types on 32-bit compilers, it might be
66
+ * necessary to switch from ISO C90 mode to ISO C99 mode (e.g., gcc
67
+ * -std=c99), or to allow compiler-specific extensions.
68
+ */
69
+
70
+ #include <limits.h>
71
+
72
+ /* --- check char --- */
73
+
74
+ #if (UCHAR_MAX / 0xFU > 0xFU)
75
+ #ifndef I8T
76
+ #define I8T char
77
+ #define U8C(v) (v##U)
78
+
79
+ #if (UCHAR_MAX == 0xFFU)
80
+ #define ECRYPT_I8T_IS_BYTE
81
+ #endif
82
+
83
+ #endif
84
+
85
+ #if (UCHAR_MAX / 0xFFU > 0xFFU)
86
+ #ifndef I16T
87
+ #define I16T char
88
+ #define U16C(v) (v##U)
89
+ #endif
90
+
91
+ #if (UCHAR_MAX / 0xFFFFU > 0xFFFFU)
92
+ #ifndef I32T
93
+ #define I32T char
94
+ #define U32C(v) (v##U)
95
+ #endif
96
+
97
+ #if (UCHAR_MAX / 0xFFFFFFFFU > 0xFFFFFFFFU)
98
+ #ifndef I64T
99
+ #define I64T char
100
+ #define U64C(v) (v##U)
101
+ #define ECRYPT_NATIVE64
102
+ #endif
103
+
104
+ #endif
105
+ #endif
106
+ #endif
107
+ #endif
108
+
109
+ /* --- check short --- */
110
+
111
+ #if (USHRT_MAX / 0xFU > 0xFU)
112
+ #ifndef I8T
113
+ #define I8T short
114
+ #define U8C(v) (v##U)
115
+
116
+ #if (USHRT_MAX == 0xFFU)
117
+ #define ECRYPT_I8T_IS_BYTE
118
+ #endif
119
+
120
+ #endif
121
+
122
+ #if (USHRT_MAX / 0xFFU > 0xFFU)
123
+ #ifndef I16T
124
+ #define I16T short
125
+ #define U16C(v) (v##U)
126
+ #endif
127
+
128
+ #if (USHRT_MAX / 0xFFFFU > 0xFFFFU)
129
+ #ifndef I32T
130
+ #define I32T short
131
+ #define U32C(v) (v##U)
132
+ #endif
133
+
134
+ #if (USHRT_MAX / 0xFFFFFFFFU > 0xFFFFFFFFU)
135
+ #ifndef I64T
136
+ #define I64T short
137
+ #define U64C(v) (v##U)
138
+ #define ECRYPT_NATIVE64
139
+ #endif
140
+
141
+ #endif
142
+ #endif
143
+ #endif
144
+ #endif
145
+
146
+ /* --- check int --- */
147
+
148
+ #if (UINT_MAX / 0xFU > 0xFU)
149
+ #ifndef I8T
150
+ #define I8T int
151
+ #define U8C(v) (v##U)
152
+
153
+ #if (ULONG_MAX == 0xFFU)
154
+ #define ECRYPT_I8T_IS_BYTE
155
+ #endif
156
+
157
+ #endif
158
+
159
+ #if (UINT_MAX / 0xFFU > 0xFFU)
160
+ #ifndef I16T
161
+ #define I16T int
162
+ #define U16C(v) (v##U)
163
+ #endif
164
+
165
+ #if (UINT_MAX / 0xFFFFU > 0xFFFFU)
166
+ #ifndef I32T
167
+ #define I32T int
168
+ #define U32C(v) (v##U)
169
+ #endif
170
+
171
+ #if (UINT_MAX / 0xFFFFFFFFU > 0xFFFFFFFFU)
172
+ #ifndef I64T
173
+ #define I64T int
174
+ #define U64C(v) (v##U)
175
+ #define ECRYPT_NATIVE64
176
+ #endif
177
+
178
+ #endif
179
+ #endif
180
+ #endif
181
+ #endif
182
+
183
+ /* --- check long --- */
184
+
185
+ #if (ULONG_MAX / 0xFUL > 0xFUL)
186
+ #ifndef I8T
187
+ #define I8T long
188
+ #define U8C(v) (v##UL)
189
+
190
+ #if (ULONG_MAX == 0xFFUL)
191
+ #define ECRYPT_I8T_IS_BYTE
192
+ #endif
193
+
194
+ #endif
195
+
196
+ #if (ULONG_MAX / 0xFFUL > 0xFFUL)
197
+ #ifndef I16T
198
+ #define I16T long
199
+ #define U16C(v) (v##UL)
200
+ #endif
201
+
202
+ #if (ULONG_MAX / 0xFFFFUL > 0xFFFFUL)
203
+ #ifndef I32T
204
+ #define I32T long
205
+ #define U32C(v) (v##UL)
206
+ #endif
207
+
208
+ #if (ULONG_MAX / 0xFFFFFFFFUL > 0xFFFFFFFFUL)
209
+ #ifndef I64T
210
+ #define I64T long
211
+ #define U64C(v) (v##UL)
212
+ #define ECRYPT_NATIVE64
213
+ #endif
214
+
215
+ #endif
216
+ #endif
217
+ #endif
218
+ #endif
219
+
220
+ /* --- check long long --- */
221
+
222
+ #ifdef ULLONG_MAX
223
+
224
+ #if (ULLONG_MAX / 0xFULL > 0xFULL)
225
+ #ifndef I8T
226
+ #define I8T long long
227
+ #define U8C(v) (v##ULL)
228
+
229
+ #if (ULLONG_MAX == 0xFFULL)
230
+ #define ECRYPT_I8T_IS_BYTE
231
+ #endif
232
+
233
+ #endif
234
+
235
+ #if (ULLONG_MAX / 0xFFULL > 0xFFULL)
236
+ #ifndef I16T
237
+ #define I16T long long
238
+ #define U16C(v) (v##ULL)
239
+ #endif
240
+
241
+ #if (ULLONG_MAX / 0xFFFFULL > 0xFFFFULL)
242
+ #ifndef I32T
243
+ #define I32T long long
244
+ #define U32C(v) (v##ULL)
245
+ #endif
246
+
247
+ #if (ULLONG_MAX / 0xFFFFFFFFULL > 0xFFFFFFFFULL)
248
+ #ifndef I64T
249
+ #define I64T long long
250
+ #define U64C(v) (v##ULL)
251
+ #endif
252
+
253
+ #endif
254
+ #endif
255
+ #endif
256
+ #endif
257
+
258
+ #endif
259
+
260
+ /* --- check __int64 --- */
261
+
262
+ #if !defined(__STDC__) && defined(_UI64_MAX)
263
+
264
+ #ifndef I64T
265
+ #define I64T __int64
266
+ #define U64C(v) (v##ui64)
267
+ #endif
268
+
269
+ #endif
270
+
271
+ /* --- if platform doesn't announce anything, use most common choices --- */
272
+
273
+ #ifndef I8T
274
+ #define I8T char
275
+ #define U8C(v) (v##U)
276
+ #endif
277
+ #ifndef I16T
278
+ #define I16T short
279
+ #define U16C(v) (v##U)
280
+ #endif
281
+ #ifndef I32T
282
+ #define I32T int
283
+ #define U32C(v) (v##U)
284
+ #endif
285
+ #ifndef I64T
286
+ #define I64T long long
287
+ #define U64C(v) (v##ULL)
288
+ #endif
289
+
290
+ /* ------------------------------------------------------------------------- */
291
+
292
+ /* find the largest type on this platform (used for alignment) */
293
+
294
+ #if defined(__SSE__) || (defined(_MSC_VER) && (_MSC_VER >= 1300))
295
+
296
+ #include <xmmintrin.h>
297
+ #define MAXT __m128
298
+
299
+ #elif defined(__MMX__)
300
+
301
+ #include <mmintrin.h>
302
+ #define MAXT __m64
303
+
304
+ #elif defined(__ALTIVEC__)
305
+
306
+ #define MAXT __vector int
307
+
308
+ #else
309
+
310
+ #define MAXT long
311
+
312
+ #endif
313
+
314
+ /* ------------------------------------------------------------------------- */
315
+
316
+ #endif
@@ -0,0 +1,289 @@
1
+ #define ECRYPT_VARIANT 1
2
+ #define ECRYPT_API
3
+ /* ecrypt-sync.h */
4
+
5
+ /*
6
+ * Header file for synchronous stream ciphers without authentication
7
+ * mechanism.
8
+ *
9
+ * *** Please only edit parts marked with "[edit]". ***
10
+ */
11
+
12
+ #ifndef ECRYPT_SYNC
13
+ #define ECRYPT_SYNC
14
+
15
+ #include "ecrypt-types.h"
16
+
17
+ #ifdef __cplusplus
18
+ extern "C" {
19
+ #endif
20
+
21
+ /* ------------------------------------------------------------------------- */
22
+
23
+ /* Cipher parameters */
24
+
25
+ /*
26
+ * The name of your cipher.
27
+ */
28
+ #define ECRYPT_NAME "ChaCha20"
29
+ #define ECRYPT_PROFILE "_____"
30
+
31
+ /*
32
+ * Specify which key and IV sizes are supported by your cipher. A user
33
+ * should be able to enumerate the supported sizes by running the
34
+ * following code:
35
+ *
36
+ * for (i = 0; ECRYPT_KEYSIZE(i) <= ECRYPT_MAXKEYSIZE; ++i)
37
+ * {
38
+ * keysize = ECRYPT_KEYSIZE(i);
39
+ *
40
+ * ...
41
+ * }
42
+ *
43
+ * All sizes are in bits.
44
+ */
45
+
46
+ #define ECRYPT_MAXKEYSIZE 256 /* [edit] */
47
+ #define ECRYPT_KEYSIZE(i) (128 + (i)*128) /* [edit] */
48
+
49
+ #define ECRYPT_MAXIVSIZE 64 /* [edit] */
50
+ #define ECRYPT_IVSIZE(i) (64 + (i)*64) /* [edit] */
51
+
52
+ /* ------------------------------------------------------------------------- */
53
+
54
+ /* Data structures */
55
+
56
+ /*
57
+ * ECRYPT_ctx is the structure containing the representation of the
58
+ * internal state of your cipher.
59
+ */
60
+
61
+ typedef struct
62
+ {
63
+ u32 input[16]; /* could be compressed */
64
+ /*
65
+ * [edit]
66
+ *
67
+ * Put here all state variable needed during the encryption process.
68
+ */
69
+ } ECRYPT_ctx;
70
+
71
+ /* ------------------------------------------------------------------------- */
72
+
73
+ /* Mandatory functions */
74
+
75
+ /*
76
+ * Key and message independent initialization. This function will be
77
+ * called once when the program starts (e.g., to build expanded S-box
78
+ * tables).
79
+ */
80
+ void ECRYPT_init(void);
81
+
82
+ /*
83
+ * Key setup. It is the user's responsibility to select the values of
84
+ * keysize and ivsize from the set of supported values specified
85
+ * above.
86
+ */
87
+ void ECRYPT_keysetup(
88
+ ECRYPT_ctx* ctx,
89
+ const u8* key,
90
+ u32 keysize, /* Key size in bits. */
91
+ u32 ivsize); /* IV size in bits. */
92
+
93
+ /*
94
+ * IV setup. After having called ECRYPT_keysetup(), the user is
95
+ * allowed to call ECRYPT_ivsetup() different times in order to
96
+ * encrypt/decrypt different messages with the same key but different
97
+ * IV's.
98
+ */
99
+ void ECRYPT_ivsetup(
100
+ ECRYPT_ctx* ctx,
101
+ const u8* iv);
102
+
103
+ /*
104
+ * Encryption/decryption of arbitrary length messages.
105
+ *
106
+ * For efficiency reasons, the API provides two types of
107
+ * encrypt/decrypt functions. The ECRYPT_encrypt_bytes() function
108
+ * (declared here) encrypts byte strings of arbitrary length, while
109
+ * the ECRYPT_encrypt_blocks() function (defined later) only accepts
110
+ * lengths which are multiples of ECRYPT_BLOCKLENGTH.
111
+ *
112
+ * The user is allowed to make multiple calls to
113
+ * ECRYPT_encrypt_blocks() to incrementally encrypt a long message,
114
+ * but he is NOT allowed to make additional encryption calls once he
115
+ * has called ECRYPT_encrypt_bytes() (unless he starts a new message
116
+ * of course). For example, this sequence of calls is acceptable:
117
+ *
118
+ * ECRYPT_keysetup();
119
+ *
120
+ * ECRYPT_ivsetup();
121
+ * ECRYPT_encrypt_blocks();
122
+ * ECRYPT_encrypt_blocks();
123
+ * ECRYPT_encrypt_bytes();
124
+ *
125
+ * ECRYPT_ivsetup();
126
+ * ECRYPT_encrypt_blocks();
127
+ * ECRYPT_encrypt_blocks();
128
+ *
129
+ * ECRYPT_ivsetup();
130
+ * ECRYPT_encrypt_bytes();
131
+ *
132
+ * The following sequence is not:
133
+ *
134
+ * ECRYPT_keysetup();
135
+ * ECRYPT_ivsetup();
136
+ * ECRYPT_encrypt_blocks();
137
+ * ECRYPT_encrypt_bytes();
138
+ * ECRYPT_encrypt_blocks();
139
+ */
140
+
141
+ void ECRYPT_encrypt_bytes(
142
+ ECRYPT_ctx* ctx,
143
+ const u8* plaintext,
144
+ u8* ciphertext,
145
+ u32 msglen); /* Message length in bytes. */
146
+
147
+ void ECRYPT_decrypt_bytes(
148
+ ECRYPT_ctx* ctx,
149
+ const u8* ciphertext,
150
+ u8* plaintext,
151
+ u32 msglen); /* Message length in bytes. */
152
+
153
+ /* ------------------------------------------------------------------------- */
154
+
155
+ /* Optional features */
156
+
157
+ /*
158
+ * For testing purposes it can sometimes be useful to have a function
159
+ * which immediately generates keystream without having to provide it
160
+ * with a zero plaintext. If your cipher cannot provide this function
161
+ * (e.g., because it is not strictly a synchronous cipher), please
162
+ * reset the ECRYPT_GENERATES_KEYSTREAM flag.
163
+ */
164
+
165
+ #define ECRYPT_GENERATES_KEYSTREAM
166
+ #ifdef ECRYPT_GENERATES_KEYSTREAM
167
+
168
+ void ECRYPT_keystream_bytes(
169
+ ECRYPT_ctx* ctx,
170
+ u8* keystream,
171
+ u32 length); /* Length of keystream in bytes. */
172
+
173
+ #endif
174
+
175
+ /* ------------------------------------------------------------------------- */
176
+
177
+ /* Optional optimizations */
178
+
179
+ /*
180
+ * By default, the functions in this section are implemented using
181
+ * calls to functions declared above. However, you might want to
182
+ * implement them differently for performance reasons.
183
+ */
184
+
185
+ /*
186
+ * All-in-one encryption/decryption of (short) packets.
187
+ *
188
+ * The default definitions of these functions can be found in
189
+ * "ecrypt-sync.c". If you want to implement them differently, please
190
+ * undef the ECRYPT_USES_DEFAULT_ALL_IN_ONE flag.
191
+ */
192
+ #define ECRYPT_USES_DEFAULT_ALL_IN_ONE /* [edit] */
193
+
194
+ void ECRYPT_encrypt_packet(
195
+ ECRYPT_ctx* ctx,
196
+ const u8* iv,
197
+ const u8* plaintext,
198
+ u8* ciphertext,
199
+ u32 msglen);
200
+
201
+ void ECRYPT_decrypt_packet(
202
+ ECRYPT_ctx* ctx,
203
+ const u8* iv,
204
+ const u8* ciphertext,
205
+ u8* plaintext,
206
+ u32 msglen);
207
+
208
+ /*
209
+ * Encryption/decryption of blocks.
210
+ *
211
+ * By default, these functions are defined as macros. If you want to
212
+ * provide a different implementation, please undef the
213
+ * ECRYPT_USES_DEFAULT_BLOCK_MACROS flag and implement the functions
214
+ * declared below.
215
+ */
216
+
217
+ #define ECRYPT_BLOCKLENGTH 64 /* [edit] */
218
+
219
+ #define ECRYPT_USES_DEFAULT_BLOCK_MACROS /* [edit] */
220
+ #ifdef ECRYPT_USES_DEFAULT_BLOCK_MACROS
221
+
222
+ #define ECRYPT_encrypt_blocks(ctx, plaintext, ciphertext, blocks) \
223
+ ECRYPT_encrypt_bytes(ctx, plaintext, ciphertext, \
224
+ (blocks) * ECRYPT_BLOCKLENGTH)
225
+
226
+ #define ECRYPT_decrypt_blocks(ctx, ciphertext, plaintext, blocks) \
227
+ ECRYPT_decrypt_bytes(ctx, ciphertext, plaintext, \
228
+ (blocks) * ECRYPT_BLOCKLENGTH)
229
+
230
+ #ifdef ECRYPT_GENERATES_KEYSTREAM
231
+
232
+ #define ECRYPT_keystream_blocks(ctx, keystream, blocks) \
233
+ ECRYPT_keystream_bytes(ctx, keystream, \
234
+ (blocks) * ECRYPT_BLOCKLENGTH)
235
+
236
+ #endif
237
+
238
+ #else
239
+
240
+ void ECRYPT_encrypt_blocks(
241
+ ECRYPT_ctx* ctx,
242
+ const u8* plaintext,
243
+ u8* ciphertext,
244
+ u32 blocks); /* Message length in blocks. */
245
+
246
+ void ECRYPT_decrypt_blocks(
247
+ ECRYPT_ctx* ctx,
248
+ const u8* ciphertext,
249
+ u8* plaintext,
250
+ u32 blocks); /* Message length in blocks. */
251
+
252
+ #ifdef ECRYPT_GENERATES_KEYSTREAM
253
+
254
+ void ECRYPT_keystream_blocks(
255
+ ECRYPT_ctx* ctx,
256
+ const u8* keystream,
257
+ u32 blocks); /* Keystream length in blocks. */
258
+
259
+ #endif
260
+
261
+ #endif
262
+
263
+ /*
264
+ * If your cipher can be implemented in different ways, you can use
265
+ * the ECRYPT_VARIANT parameter to allow the user to choose between
266
+ * them at compile time (e.g., gcc -DECRYPT_VARIANT=3 ...). Please
267
+ * only use this possibility if you really think it could make a
268
+ * significant difference and keep the number of variants
269
+ * (ECRYPT_MAXVARIANT) as small as possible (definitely not more than
270
+ * 10). Note also that all variants should have exactly the same
271
+ * external interface (i.e., the same ECRYPT_BLOCKLENGTH, etc.).
272
+ */
273
+ #define ECRYPT_MAXVARIANT 1 /* [edit] */
274
+
275
+ #ifndef ECRYPT_VARIANT
276
+ #define ECRYPT_VARIANT 1
277
+ #endif
278
+
279
+ #if (ECRYPT_VARIANT > ECRYPT_MAXVARIANT)
280
+ #error this variant does not exist
281
+ #endif
282
+
283
+ /* ------------------------------------------------------------------------- */
284
+
285
+ #ifdef __cplusplus
286
+ } /* extern "C" */
287
+ #endif
288
+
289
+ #endif
@@ -0,0 +1,53 @@
1
+ /* ecrypt-types.h */
2
+
3
+ /*
4
+ * *** Please do not edit this file. ***
5
+ *
6
+ * The default macros can be overridden for specific architectures by
7
+ * editing 'ecrypt-machine.h'.
8
+ */
9
+
10
+ #ifndef ECRYPT_TYPES
11
+ #define ECRYPT_TYPES
12
+
13
+ #include "ecrypt-config.h"
14
+
15
+ /* ------------------------------------------------------------------------- */
16
+
17
+ /*
18
+ * The following types are defined (if available):
19
+ *
20
+ * u8: unsigned integer type, at least 8 bits
21
+ * u16: unsigned integer type, at least 16 bits
22
+ * u32: unsigned integer type, at least 32 bits
23
+ * u64: unsigned integer type, at least 64 bits
24
+ *
25
+ * s8, s16, s32, s64 -> signed counterparts of u8, u16, u32, u64
26
+ *
27
+ * The selection of minimum-width integer types is taken care of by
28
+ * 'ecrypt-config.h'. Note: to enable 64-bit types on 32-bit
29
+ * compilers, it might be necessary to switch from ISO C90 mode to ISO
30
+ * C99 mode (e.g., gcc -std=c99).
31
+ */
32
+
33
+ #ifdef I8T
34
+ typedef signed I8T s8;
35
+ typedef unsigned I8T u8;
36
+ #endif
37
+
38
+ #ifdef I16T
39
+ typedef signed I16T s16;
40
+ typedef unsigned I16T u16;
41
+ #endif
42
+
43
+ #ifdef I32T
44
+ typedef signed I32T s32;
45
+ typedef unsigned I32T u32;
46
+ #endif
47
+
48
+ #ifdef I64T
49
+ typedef signed I64T s64;
50
+ typedef unsigned I64T u64;
51
+ #endif
52
+
53
+ #endif
@@ -0,0 +1,28 @@
1
+ #ifndef POLY1305_DONNA_H
2
+ #define POLY1305_DONNA_H
3
+
4
+ #include <stddef.h>
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ typedef struct poly1305_context {
11
+ size_t aligner;
12
+ unsigned char opaque[136];
13
+ } poly1305_context;
14
+
15
+ void poly1305_init(poly1305_context *ctx, const unsigned char key[32]);
16
+ void poly1305_update(poly1305_context *ctx, const unsigned char *m, size_t bytes);
17
+ void poly1305_finish(poly1305_context *ctx, unsigned char mac[16]);
18
+ void poly1305_auth(unsigned char mac[16], const unsigned char *m, size_t bytes, const unsigned char key[32]);
19
+
20
+ int poly1305_verify(const unsigned char mac1[16], const unsigned char mac2[16]);
21
+ int poly1305_power_on_self_test(void);
22
+
23
+ #ifdef __cplusplus
24
+ } /* extern "C" */
25
+ #endif
26
+
27
+ #endif /* POLY1305_DONNA_H */
28
+
@@ -0,0 +1,27 @@
1
+ #ifndef CHACHA20POLY1305_H
2
+ #define CHACHA20POLY1305_H
3
+
4
+ #include <stdint.h>
5
+ #include "chacha20poly1305/ecrypt-sync.h"
6
+ #include <TrezorCrypto/chacha20poly1305/poly1305-donna.h>
7
+
8
+ #ifdef __cplusplus
9
+ extern "C" {
10
+ #endif
11
+
12
+ typedef struct {
13
+ ECRYPT_ctx chacha20;
14
+ poly1305_context poly1305;
15
+ } chacha20poly1305_ctx;
16
+
17
+ void xchacha20poly1305_init(chacha20poly1305_ctx *ctx, uint8_t key[32], uint8_t nonce[24]);
18
+ void chacha20poly1305_encrypt(chacha20poly1305_ctx *ctx, uint8_t *in, uint8_t *out, size_t n);
19
+ void chacha20poly1305_decrypt(chacha20poly1305_ctx *ctx, uint8_t *in, uint8_t *out, size_t n);
20
+ void chacha20poly1305_auth(chacha20poly1305_ctx *ctx, uint8_t *in, size_t n);
21
+ void chacha20poly1305_finish(chacha20poly1305_ctx *ctx, uint8_t mac[16]);
22
+
23
+ #ifdef __cplusplus
24
+ } /* extern "C" */
25
+ #endif
26
+
27
+ #endif // CHACHA20POLY1305_H