@onekeyfe/react-native-lite-card 6.7.0-5 → 6.7.0-50
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 +134 -43
- package/ReactNativeLiteCard.podspec +31 -2
- package/android/build.gradle +8 -0
- package/android/consumer-rules.pro +4 -0
- package/android/src/main/cpp/CMakeLists.txt +6 -2
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/ReactNativeLiteCardModule.kt +60 -49
- 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 +117 -39
- 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 +24 -2
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/Connection.kt +46 -19
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/GPCAPDUGenerator.kt +2 -2
- package/ios/Classes/OKLiteCommand/OKLiteCommandTool.m +38 -1
- package/ios/Classes/OKNFCBridge.mm +24 -1
- package/ios/Classes/OKNFTLite/OKLiteV1.m +20 -10
- package/ios/Classes/OKNFTLite/OKLiteV2.m +13 -5
- package/ios/Classes/OKNFTLite/OKNFCManager.h +2 -2
- package/ios/Classes/OKNFTLite/OKNFCManager.m +110 -18
- package/ios/ReactNativeLiteCard.mm +23 -11
- package/lib/module/index.js +4 -4
- package/lib/typescript/src/NativeReactNativeLiteCard.d.ts +4 -4
- package/lib/typescript/src/index.d.ts +2 -2
- package/package.json +9 -8
- package/sdk/CMakeLists.txt +121 -0
- package/sdk/README.md +190 -0
- package/sdk/android/implJni.cpp +216 -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/scripts/generate-source-id.rb +22 -0
- package/sdk/source-id-manifest.txt +19 -0
- package/sdk/source-id.cmake +31 -0
- package/sdk/src/ApduBuilder.cpp +332 -0
- package/sdk/src/GPChannelSDK.cpp +258 -0
- package/sdk/src/random.c +25 -0
- package/sdk/src/version.c +3 -0
- package/sdk/tests/android/GPChannelProxy.java +55 -0
- package/sdk/tests/android_verify.py +124 -0
- package/sdk/tests/safety.cpp +757 -0
- package/sdk/tests/verify.py +284 -0
- package/src/NativeReactNativeLiteCard.ts +4 -2
- package/src/index.tsx +14 -3
- 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
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
#include <stddef.h>
|
|
2
|
+
#include <stdint.h>
|
|
3
|
+
#include <stdlib.h>
|
|
4
|
+
#include <string.h>
|
|
5
|
+
|
|
6
|
+
#include <TrezorCrypto/sodium/private/ed25519_ref10.h>
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Field arithmetic:
|
|
10
|
+
* Use 5*51 bit limbs on 64-bit systems with support for 128 bit arithmetic,
|
|
11
|
+
* and 10*25.5 bit limbs elsewhere.
|
|
12
|
+
*
|
|
13
|
+
* Functions used elsewhere that are candidates for inlining are defined
|
|
14
|
+
* via "private/curve25519_ref10.h".
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#include <TrezorCrypto/sodium/private/fe_25_5/constants.h>
|
|
18
|
+
#include <TrezorCrypto/sodium/private/fe_25_5/fe.h>
|
|
19
|
+
|
|
20
|
+
void fe25519_invert(fe25519 out, const fe25519 z) {
|
|
21
|
+
fe25519 t0;
|
|
22
|
+
fe25519 t1;
|
|
23
|
+
fe25519 t2;
|
|
24
|
+
fe25519 t3;
|
|
25
|
+
int i;
|
|
26
|
+
|
|
27
|
+
fe25519_sq(t0, z);
|
|
28
|
+
fe25519_sq(t1, t0);
|
|
29
|
+
fe25519_sq(t1, t1);
|
|
30
|
+
fe25519_mul(t1, z, t1);
|
|
31
|
+
fe25519_mul(t0, t0, t1);
|
|
32
|
+
fe25519_sq(t2, t0);
|
|
33
|
+
fe25519_mul(t1, t1, t2);
|
|
34
|
+
fe25519_sq(t2, t1);
|
|
35
|
+
for (i = 1; i < 5; ++i) {
|
|
36
|
+
fe25519_sq(t2, t2);
|
|
37
|
+
}
|
|
38
|
+
fe25519_mul(t1, t2, t1);
|
|
39
|
+
fe25519_sq(t2, t1);
|
|
40
|
+
for (i = 1; i < 10; ++i) {
|
|
41
|
+
fe25519_sq(t2, t2);
|
|
42
|
+
}
|
|
43
|
+
fe25519_mul(t2, t2, t1);
|
|
44
|
+
fe25519_sq(t3, t2);
|
|
45
|
+
for (i = 1; i < 20; ++i) {
|
|
46
|
+
fe25519_sq(t3, t3);
|
|
47
|
+
}
|
|
48
|
+
fe25519_mul(t2, t3, t2);
|
|
49
|
+
fe25519_sq(t2, t2);
|
|
50
|
+
for (i = 1; i < 10; ++i) {
|
|
51
|
+
fe25519_sq(t2, t2);
|
|
52
|
+
}
|
|
53
|
+
fe25519_mul(t1, t2, t1);
|
|
54
|
+
fe25519_sq(t2, t1);
|
|
55
|
+
for (i = 1; i < 50; ++i) {
|
|
56
|
+
fe25519_sq(t2, t2);
|
|
57
|
+
}
|
|
58
|
+
fe25519_mul(t2, t2, t1);
|
|
59
|
+
fe25519_sq(t3, t2);
|
|
60
|
+
for (i = 1; i < 100; ++i) {
|
|
61
|
+
fe25519_sq(t3, t3);
|
|
62
|
+
}
|
|
63
|
+
fe25519_mul(t2, t3, t2);
|
|
64
|
+
fe25519_sq(t2, t2);
|
|
65
|
+
for (i = 1; i < 50; ++i) {
|
|
66
|
+
fe25519_sq(t2, t2);
|
|
67
|
+
}
|
|
68
|
+
fe25519_mul(t1, t2, t1);
|
|
69
|
+
fe25519_sq(t1, t1);
|
|
70
|
+
for (i = 1; i < 5; ++i) {
|
|
71
|
+
fe25519_sq(t1, t1);
|
|
72
|
+
}
|
|
73
|
+
fe25519_mul(out, t1, t0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void fe25519_pow22523(fe25519 out, const fe25519 z) {
|
|
77
|
+
fe25519 t0;
|
|
78
|
+
fe25519 t1;
|
|
79
|
+
fe25519 t2;
|
|
80
|
+
int i;
|
|
81
|
+
|
|
82
|
+
fe25519_sq(t0, z);
|
|
83
|
+
fe25519_sq(t1, t0);
|
|
84
|
+
fe25519_sq(t1, t1);
|
|
85
|
+
fe25519_mul(t1, z, t1);
|
|
86
|
+
fe25519_mul(t0, t0, t1);
|
|
87
|
+
fe25519_sq(t0, t0);
|
|
88
|
+
fe25519_mul(t0, t1, t0);
|
|
89
|
+
fe25519_sq(t1, t0);
|
|
90
|
+
for (i = 1; i < 5; ++i) {
|
|
91
|
+
fe25519_sq(t1, t1);
|
|
92
|
+
}
|
|
93
|
+
fe25519_mul(t0, t1, t0);
|
|
94
|
+
fe25519_sq(t1, t0);
|
|
95
|
+
for (i = 1; i < 10; ++i) {
|
|
96
|
+
fe25519_sq(t1, t1);
|
|
97
|
+
}
|
|
98
|
+
fe25519_mul(t1, t1, t0);
|
|
99
|
+
fe25519_sq(t2, t1);
|
|
100
|
+
for (i = 1; i < 20; ++i) {
|
|
101
|
+
fe25519_sq(t2, t2);
|
|
102
|
+
}
|
|
103
|
+
fe25519_mul(t1, t2, t1);
|
|
104
|
+
fe25519_sq(t1, t1);
|
|
105
|
+
for (i = 1; i < 10; ++i) {
|
|
106
|
+
fe25519_sq(t1, t1);
|
|
107
|
+
}
|
|
108
|
+
fe25519_mul(t0, t1, t0);
|
|
109
|
+
fe25519_sq(t1, t0);
|
|
110
|
+
for (i = 1; i < 50; ++i) {
|
|
111
|
+
fe25519_sq(t1, t1);
|
|
112
|
+
}
|
|
113
|
+
fe25519_mul(t1, t1, t0);
|
|
114
|
+
fe25519_sq(t2, t1);
|
|
115
|
+
for (i = 1; i < 100; ++i) {
|
|
116
|
+
fe25519_sq(t2, t2);
|
|
117
|
+
}
|
|
118
|
+
fe25519_mul(t1, t2, t1);
|
|
119
|
+
fe25519_sq(t1, t1);
|
|
120
|
+
for (i = 1; i < 50; ++i) {
|
|
121
|
+
fe25519_sq(t1, t1);
|
|
122
|
+
}
|
|
123
|
+
fe25519_mul(t0, t1, t0);
|
|
124
|
+
fe25519_sq(t0, t0);
|
|
125
|
+
fe25519_sq(t0, t0);
|
|
126
|
+
fe25519_mul(out, t0, z);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
r = p + q
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
void ge25519_add2(ge25519_p1p1_1 *r, const ge25519_p3 *p, const ge25519_cached *q) {
|
|
134
|
+
fe25519 t0;
|
|
135
|
+
|
|
136
|
+
fe25519_add(r->X, p->Y, p->X);
|
|
137
|
+
fe25519_sub(r->Y, p->Y, p->X);
|
|
138
|
+
fe25519_mul(r->Z, r->X, q->YplusX);
|
|
139
|
+
fe25519_mul(r->Y, r->Y, q->YminusX);
|
|
140
|
+
fe25519_mul(r->T, q->T2d, p->T);
|
|
141
|
+
fe25519_mul(r->X, p->Z, q->Z);
|
|
142
|
+
fe25519_add(t0, r->X, r->X);
|
|
143
|
+
fe25519_sub(r->X, r->Z, r->Y);
|
|
144
|
+
fe25519_add(r->Y, r->Z, r->Y);
|
|
145
|
+
fe25519_add(r->Z, t0, r->T);
|
|
146
|
+
fe25519_sub(r->T, t0, r->T);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
int ge25519_frombytes_negate_vartime(ge25519_p3 *h, const unsigned char *s) {
|
|
150
|
+
fe25519 u;
|
|
151
|
+
fe25519 v;
|
|
152
|
+
fe25519 v3;
|
|
153
|
+
fe25519 vxx;
|
|
154
|
+
fe25519 m_root_check, p_root_check;
|
|
155
|
+
|
|
156
|
+
fe25519_frombytes(h->Y, s);
|
|
157
|
+
fe25519_1(h->Z);
|
|
158
|
+
fe25519_sq(u, h->Y);
|
|
159
|
+
fe25519_mul(v, u, d);
|
|
160
|
+
fe25519_sub(u, u, h->Z); /* u = y^2-1 */
|
|
161
|
+
fe25519_add(v, v, h->Z); /* v = dy^2+1 */
|
|
162
|
+
|
|
163
|
+
fe25519_sq(v3, v);
|
|
164
|
+
fe25519_mul(v3, v3, v); /* v3 = v^3 */
|
|
165
|
+
fe25519_sq(h->X, v3);
|
|
166
|
+
fe25519_mul(h->X, h->X, v);
|
|
167
|
+
fe25519_mul(h->X, h->X, u); /* x = uv^7 */
|
|
168
|
+
|
|
169
|
+
fe25519_pow22523(h->X, h->X); /* x = (uv^7)^((q-5)/8) */
|
|
170
|
+
fe25519_mul(h->X, h->X, v3);
|
|
171
|
+
fe25519_mul(h->X, h->X, u); /* x = uv^3(uv^7)^((q-5)/8) */
|
|
172
|
+
|
|
173
|
+
fe25519_sq(vxx, h->X);
|
|
174
|
+
fe25519_mul(vxx, vxx, v);
|
|
175
|
+
fe25519_sub(m_root_check, vxx, u); /* vx^2-u */
|
|
176
|
+
if (fe25519_iszero(m_root_check) == 0) {
|
|
177
|
+
fe25519_add(p_root_check, vxx, u); /* vx^2+u */
|
|
178
|
+
if (fe25519_iszero(p_root_check) == 0) {
|
|
179
|
+
return -1;
|
|
180
|
+
}
|
|
181
|
+
fe25519_mul(h->X, h->X, sqrtm1);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (fe25519_isnegative(h->X) == (s[31] >> 7)) {
|
|
185
|
+
fe25519_neg(h->X, h->X);
|
|
186
|
+
}
|
|
187
|
+
fe25519_mul(h->T, h->X, h->Y);
|
|
188
|
+
|
|
189
|
+
return 0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/*
|
|
193
|
+
r = p
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
void ge25519_p1p1_to_p3(ge25519_p3 *r, const ge25519_p1p1_1 *p) {
|
|
197
|
+
fe25519_mul(r->X, p->X, p->T);
|
|
198
|
+
fe25519_mul(r->Y, p->Y, p->Z);
|
|
199
|
+
fe25519_mul(r->Z, p->Z, p->T);
|
|
200
|
+
fe25519_mul(r->T, p->X, p->Y);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/*
|
|
204
|
+
r = 2 * p
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
void ge25519_p2_dbl(ge25519_p1p1_1 *r, const ge25519_p2 *p) {
|
|
208
|
+
fe25519 t0;
|
|
209
|
+
|
|
210
|
+
fe25519_sq(r->X, p->X);
|
|
211
|
+
fe25519_sq(r->Z, p->Y);
|
|
212
|
+
fe25519_sq2(r->T, p->Z);
|
|
213
|
+
fe25519_add(r->Y, p->X, p->Y);
|
|
214
|
+
fe25519_sq(t0, r->Y);
|
|
215
|
+
fe25519_add(r->Y, r->Z, r->X);
|
|
216
|
+
fe25519_sub(r->Z, r->Z, r->X);
|
|
217
|
+
fe25519_sub(r->X, t0, r->Y);
|
|
218
|
+
fe25519_sub(r->T, r->T, r->Z);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
void ge25519_p3_0(ge25519_p3 *h) {
|
|
222
|
+
fe25519_0(h->X);
|
|
223
|
+
fe25519_1(h->Y);
|
|
224
|
+
fe25519_1(h->Z);
|
|
225
|
+
fe25519_0(h->T);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
void ge25519_cached_0(ge25519_cached *h) {
|
|
229
|
+
fe25519_1(h->YplusX);
|
|
230
|
+
fe25519_1(h->YminusX);
|
|
231
|
+
fe25519_1(h->Z);
|
|
232
|
+
fe25519_0(h->T2d);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/*
|
|
236
|
+
r = p
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
void ge25519_p3_to_cached(ge25519_cached *r, const ge25519_p3 *p) {
|
|
240
|
+
fe25519_add(r->YplusX, p->Y, p->X);
|
|
241
|
+
fe25519_sub(r->YminusX, p->Y, p->X);
|
|
242
|
+
fe25519_copy(r->Z, p->Z);
|
|
243
|
+
fe25519_mul(r->T2d, p->T, d2);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/*
|
|
247
|
+
r = p
|
|
248
|
+
*/
|
|
249
|
+
|
|
250
|
+
void ge25519_p3_to_p2(ge25519_p2 *r, const ge25519_p3 *p) {
|
|
251
|
+
fe25519_copy(r->X, p->X);
|
|
252
|
+
fe25519_copy(r->Y, p->Y);
|
|
253
|
+
fe25519_copy(r->Z, p->Z);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
void ge25519_p3_tobytes(unsigned char *s, const ge25519_p3 *h) {
|
|
257
|
+
fe25519 recip;
|
|
258
|
+
fe25519 x;
|
|
259
|
+
fe25519 y;
|
|
260
|
+
|
|
261
|
+
fe25519_invert(recip, h->Z);
|
|
262
|
+
fe25519_mul(x, h->X, recip);
|
|
263
|
+
fe25519_mul(y, h->Y, recip);
|
|
264
|
+
fe25519_tobytes(s, y);
|
|
265
|
+
s[31] ^= fe25519_isnegative(x) << 7;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/*
|
|
269
|
+
r = 2 * p
|
|
270
|
+
*/
|
|
271
|
+
|
|
272
|
+
void ge25519_p3_dbl(ge25519_p1p1_1 *r, const ge25519_p3 *p) {
|
|
273
|
+
ge25519_p2 q;
|
|
274
|
+
ge25519_p3_to_p2(&q, p);
|
|
275
|
+
ge25519_p2_dbl(r, &q);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
void ge25519_precomp_0(ge25519_precomp *h) {
|
|
279
|
+
fe25519_1(h->yplusx);
|
|
280
|
+
fe25519_1(h->yminusx);
|
|
281
|
+
fe25519_0(h->xy2d);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
unsigned char equal(signed char b, signed char c) {
|
|
285
|
+
unsigned char ub = b;
|
|
286
|
+
unsigned char uc = c;
|
|
287
|
+
unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */
|
|
288
|
+
uint32_t y = x; /* 0: yes; 1..255: no */
|
|
289
|
+
|
|
290
|
+
y -= 1; /* 4294967295: yes; 0..254: no */
|
|
291
|
+
y >>= 31; /* 1: yes; 0: no */
|
|
292
|
+
|
|
293
|
+
return y;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
unsigned char negative(signed char b) {
|
|
297
|
+
/* 18446744073709551361..18446744073709551615: yes; 0..255: no */
|
|
298
|
+
uint64_t x = b;
|
|
299
|
+
|
|
300
|
+
x >>= 63; /* 1: yes; 0: no */
|
|
301
|
+
|
|
302
|
+
return x;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
void ge25519_cmov(ge25519_precomp *t, const ge25519_precomp *u, unsigned char b) {
|
|
306
|
+
fe25519_cmov(t->yplusx, u->yplusx, b);
|
|
307
|
+
fe25519_cmov(t->yminusx, u->yminusx, b);
|
|
308
|
+
fe25519_cmov(t->xy2d, u->xy2d, b);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
void ge25519_cmov_cached(ge25519_cached *t, const ge25519_cached *u, unsigned char b) {
|
|
312
|
+
fe25519_cmov(t->YplusX, u->YplusX, b);
|
|
313
|
+
fe25519_cmov(t->YminusX, u->YminusX, b);
|
|
314
|
+
fe25519_cmov(t->Z, u->Z, b);
|
|
315
|
+
fe25519_cmov(t->T2d, u->T2d, b);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/*
|
|
319
|
+
r = p - q
|
|
320
|
+
*/
|
|
321
|
+
|
|
322
|
+
void ge25519_sub(ge25519_p1p1_1 *r, const ge25519_p3 *p, const ge25519_cached *q) {
|
|
323
|
+
fe25519 t0;
|
|
324
|
+
|
|
325
|
+
fe25519_add(r->X, p->Y, p->X);
|
|
326
|
+
fe25519_sub(r->Y, p->Y, p->X);
|
|
327
|
+
fe25519_mul(r->Z, r->X, q->YminusX);
|
|
328
|
+
fe25519_mul(r->Y, r->Y, q->YplusX);
|
|
329
|
+
fe25519_mul(r->T, q->T2d, p->T);
|
|
330
|
+
fe25519_mul(r->X, p->Z, q->Z);
|
|
331
|
+
fe25519_add(t0, r->X, r->X);
|
|
332
|
+
fe25519_sub(r->X, r->Z, r->Y);
|
|
333
|
+
fe25519_add(r->Y, r->Z, r->Y);
|
|
334
|
+
fe25519_sub(r->Z, t0, r->T);
|
|
335
|
+
fe25519_add(r->T, t0, r->T);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
void ge25519_tobytes(unsigned char *s, const ge25519_p2 *h) {
|
|
339
|
+
fe25519 recip;
|
|
340
|
+
fe25519 x;
|
|
341
|
+
fe25519 y;
|
|
342
|
+
|
|
343
|
+
fe25519_invert(recip, h->Z);
|
|
344
|
+
fe25519_mul(x, h->X, recip);
|
|
345
|
+
fe25519_mul(y, h->Y, recip);
|
|
346
|
+
fe25519_tobytes(s, y);
|
|
347
|
+
s[31] ^= fe25519_isnegative(x) << 7;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/* multiply by the order of the main subgroup l = 2^252+27742317777372353535851937790883648493 */
|
|
351
|
+
void ge25519_mul_l(ge25519_p3 *r, const ge25519_p3 *A) {
|
|
352
|
+
static const signed char aslide[253] = {
|
|
353
|
+
13, 0, 0, 0, 0, -1, 0, 0, 0, 0, -11, 0, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0,
|
|
354
|
+
0, -3, 0, 0, 0, 0, -13, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, -13,
|
|
355
|
+
0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 11, 0, 0, 0,
|
|
356
|
+
0, -13, 0, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 3, 0, 0, 0,
|
|
357
|
+
0, -11, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0,
|
|
358
|
+
0, 0, 7, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
359
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
360
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
361
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
362
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
363
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
|
|
364
|
+
ge25519_cached Ai[8];
|
|
365
|
+
ge25519_p1p1_1 t;
|
|
366
|
+
ge25519_p3 u;
|
|
367
|
+
ge25519_p3 A2;
|
|
368
|
+
int i;
|
|
369
|
+
|
|
370
|
+
ge25519_p3_to_cached(&Ai[0], A);
|
|
371
|
+
ge25519_p3_dbl(&t, A);
|
|
372
|
+
ge25519_p1p1_to_p3(&A2, &t);
|
|
373
|
+
ge25519_add2(&t, &A2, &Ai[0]);
|
|
374
|
+
ge25519_p1p1_to_p3(&u, &t);
|
|
375
|
+
ge25519_p3_to_cached(&Ai[1], &u);
|
|
376
|
+
ge25519_add2(&t, &A2, &Ai[1]);
|
|
377
|
+
ge25519_p1p1_to_p3(&u, &t);
|
|
378
|
+
ge25519_p3_to_cached(&Ai[2], &u);
|
|
379
|
+
ge25519_add2(&t, &A2, &Ai[2]);
|
|
380
|
+
ge25519_p1p1_to_p3(&u, &t);
|
|
381
|
+
ge25519_p3_to_cached(&Ai[3], &u);
|
|
382
|
+
ge25519_add2(&t, &A2, &Ai[3]);
|
|
383
|
+
ge25519_p1p1_to_p3(&u, &t);
|
|
384
|
+
ge25519_p3_to_cached(&Ai[4], &u);
|
|
385
|
+
ge25519_add2(&t, &A2, &Ai[4]);
|
|
386
|
+
ge25519_p1p1_to_p3(&u, &t);
|
|
387
|
+
ge25519_p3_to_cached(&Ai[5], &u);
|
|
388
|
+
ge25519_add2(&t, &A2, &Ai[5]);
|
|
389
|
+
ge25519_p1p1_to_p3(&u, &t);
|
|
390
|
+
ge25519_p3_to_cached(&Ai[6], &u);
|
|
391
|
+
ge25519_add2(&t, &A2, &Ai[6]);
|
|
392
|
+
ge25519_p1p1_to_p3(&u, &t);
|
|
393
|
+
ge25519_p3_to_cached(&Ai[7], &u);
|
|
394
|
+
|
|
395
|
+
ge25519_p3_0(r);
|
|
396
|
+
|
|
397
|
+
for (i = 252; i >= 0; --i) {
|
|
398
|
+
ge25519_p3_dbl(&t, r);
|
|
399
|
+
|
|
400
|
+
if (aslide[i] > 0) {
|
|
401
|
+
ge25519_p1p1_to_p3(&u, &t);
|
|
402
|
+
ge25519_add2(&t, &u, &Ai[aslide[i] / 2]);
|
|
403
|
+
} else if (aslide[i] < 0) {
|
|
404
|
+
ge25519_p1p1_to_p3(&u, &t);
|
|
405
|
+
ge25519_sub(&t, &u, &Ai[(-aslide[i]) / 2]);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
ge25519_p1p1_to_p3(r, &t);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
int ge25519_is_on_main_subgroup(const ge25519_p3 *p) {
|
|
413
|
+
ge25519_p3 pl;
|
|
414
|
+
|
|
415
|
+
ge25519_mul_l(&pl, p);
|
|
416
|
+
|
|
417
|
+
return fe25519_iszero(pl.X);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
#ifndef CRYPTO_ALIGN
|
|
421
|
+
#if defined(__INTEL_COMPILER) || defined(_MSC_VER)
|
|
422
|
+
#define CRYPTO_ALIGN(x) __declspec(align(x))
|
|
423
|
+
#else
|
|
424
|
+
#define CRYPTO_ALIGN(x) __attribute__((aligned(x)))
|
|
425
|
+
#endif
|
|
426
|
+
#endif
|
|
427
|
+
|
|
428
|
+
#define COMPILER_ASSERT(X) (void)sizeof(char[(X) ? 1 : -1])
|
|
429
|
+
|
|
430
|
+
int ge25519_has_small_order(const unsigned char s[32]) {
|
|
431
|
+
CRYPTO_ALIGN(16)
|
|
432
|
+
static const unsigned char blacklist[][32] = {
|
|
433
|
+
/* 0 (order 4) */
|
|
434
|
+
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
435
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
436
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
437
|
+
/* 1 (order 1) */
|
|
438
|
+
{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
439
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
440
|
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
|
|
441
|
+
/* 2707385501144840649318225287225658788936804267575313519463743609750303402022
|
|
442
|
+
(order 8) */
|
|
443
|
+
{0x26, 0xe8, 0x95, 0x8f, 0xc2, 0xb2, 0x27, 0xb0, 0x45, 0xc3, 0xf4,
|
|
444
|
+
0x89, 0xf2, 0xef, 0x98, 0xf0, 0xd5, 0xdf, 0xac, 0x05, 0xd3, 0xc6,
|
|
445
|
+
0x33, 0x39, 0xb1, 0x38, 0x02, 0x88, 0x6d, 0x53, 0xfc, 0x05},
|
|
446
|
+
/* 55188659117513257062467267217118295137698188065244968500265048394206261417927
|
|
447
|
+
(order 8) */
|
|
448
|
+
{0xc7, 0x17, 0x6a, 0x70, 0x3d, 0x4d, 0xd8, 0x4f, 0xba, 0x3c, 0x0b,
|
|
449
|
+
0x76, 0x0d, 0x10, 0x67, 0x0f, 0x2a, 0x20, 0x53, 0xfa, 0x2c, 0x39,
|
|
450
|
+
0xcc, 0xc6, 0x4e, 0xc7, 0xfd, 0x77, 0x92, 0xac, 0x03, 0x7a},
|
|
451
|
+
/* p-1 (order 2) */
|
|
452
|
+
{0xec, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
453
|
+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
454
|
+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f},
|
|
455
|
+
/* p (=0, order 4) */
|
|
456
|
+
{0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
457
|
+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
458
|
+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f},
|
|
459
|
+
/* p+1 (=1, order 1) */
|
|
460
|
+
{0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
461
|
+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
462
|
+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}};
|
|
463
|
+
unsigned char c[7] = {0};
|
|
464
|
+
unsigned int k;
|
|
465
|
+
size_t i, j;
|
|
466
|
+
|
|
467
|
+
COMPILER_ASSERT(7 == sizeof blacklist / sizeof blacklist[0]);
|
|
468
|
+
for (j = 0; j < 31; j++) {
|
|
469
|
+
for (i = 0; i < sizeof blacklist / sizeof blacklist[0]; i++) {
|
|
470
|
+
c[i] |= s[j] ^ blacklist[i][j];
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
for (i = 0; i < sizeof blacklist / sizeof blacklist[0]; i++) {
|
|
474
|
+
c[i] |= (s[j] & 0x7f) ^ blacklist[i][j];
|
|
475
|
+
}
|
|
476
|
+
k = 0;
|
|
477
|
+
for (i = 0; i < sizeof blacklist / sizeof blacklist[0]; i++) {
|
|
478
|
+
k |= (c[i] - 1);
|
|
479
|
+
}
|
|
480
|
+
return (int)((k >> 8) & 1);
|
|
481
|
+
}
|