@digitalshieldfe/react-native-backup-card-sdk 0.1.4 → 0.1.5
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/android/build.gradle +6 -49
- package/android/libs/backupcardsdk.aar +0 -0
- package/android/src/main/AndroidManifest.xml +1 -4
- package/package.json +6 -4
- package/android/consumer-rules.pro +0 -0
- package/android/proguard-rules.pro +0 -21
- package/android/src/main/java/com/ziancube/backupcardsdk/BackupCardSdk.kt +0 -478
- package/android/src/main/java/com/ziancube/backupcardsdk/GPChannelNatives.java +0 -41
- package/android/src/main/java/com/ziancube/backupcardsdk/listener/ApiAsyncListener.java +0 -13
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/ApiNfc.java +0 -173
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/ImplNfc.java +0 -39
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/NfcComm.java +0 -115
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/ApduParam.java +0 -67
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/CommList.java +0 -41
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/Utils.java +0 -109
- package/android/src/main/jni/CMakeLists.txt +0 -60
- package/android/src/main/jni/GPChannel/include/GPChannelSDK.h +0 -306
- package/android/src/main/jni/GPChannel/include/context/BaseContext.h +0 -56
- package/android/src/main/jni/GPChannel/include/device/ApduBuilder.hpp +0 -72
- package/android/src/main/jni/GPChannel/include/utility/Apdu.hpp +0 -166
- package/android/src/main/jni/GPChannel/include/utility/Debug.hpp +0 -59
- package/android/src/main/jni/GPChannel/include/utility/Singleton.h +0 -34
- package/android/src/main/jni/GPChannel/include/utility/mutex.h +0 -24
- package/android/src/main/jni/GPChannel/include/utility/trim.hpp +0 -155
- package/android/src/main/jni/GPChannel/include/utility/util.h +0 -104
- package/android/src/main/jni/GPChannel/include/utility/xFactory.hpp +0 -26
- package/android/src/main/jni/GPChannel/include/utility/xManager.hpp +0 -84
- package/android/src/main/jni/GPChannel/src/arm64-v8a/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/arm64-v8a/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/GPChannel/src/armeabi-v7a/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/armeabi-v7a/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/GPChannel/src/x86/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/x86/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/src/implJni.cpp +0 -313
- package/android/src/main/jni/src/implJni.h +0 -9
- package/android/src/main/jni/utils/jsoncpp/AUTHORS +0 -111
- package/android/src/main/jni/utils/jsoncpp/CMakeLists.txt +0 -159
- package/android/src/main/jni/utils/jsoncpp/LICENSE +0 -55
- package/android/src/main/jni/utils/jsoncpp/README.md +0 -135
- package/android/src/main/jni/utils/jsoncpp/amalgamate.py +0 -155
- package/android/src/main/jni/utils/jsoncpp/appveyor.yml +0 -22
- package/android/src/main/jni/utils/jsoncpp/dev.makefile +0 -35
- package/android/src/main/jni/utils/jsoncpp/devtools/__init__.py +0 -6
- package/android/src/main/jni/utils/jsoncpp/devtools/agent_vmw7.json +0 -33
- package/android/src/main/jni/utils/jsoncpp/devtools/agent_vmxp.json +0 -26
- package/android/src/main/jni/utils/jsoncpp/devtools/antglob.py +0 -205
- package/android/src/main/jni/utils/jsoncpp/devtools/batchbuild.py +0 -278
- package/android/src/main/jni/utils/jsoncpp/devtools/fixeol.py +0 -70
- package/android/src/main/jni/utils/jsoncpp/devtools/licenseupdater.py +0 -94
- package/android/src/main/jni/utils/jsoncpp/devtools/tarball.py +0 -52
- package/android/src/main/jni/utils/jsoncpp/doxybuild.py +0 -189
- package/android/src/main/jni/utils/jsoncpp/include/CMakeLists.txt +0 -2
- package/android/src/main/jni/utils/jsoncpp/include/json/allocator.h +0 -98
- package/android/src/main/jni/utils/jsoncpp/include/json/assertions.h +0 -54
- package/android/src/main/jni/utils/jsoncpp/include/json/autolink.h +0 -25
- package/android/src/main/jni/utils/jsoncpp/include/json/config.h +0 -187
- package/android/src/main/jni/utils/jsoncpp/include/json/features.h +0 -61
- package/android/src/main/jni/utils/jsoncpp/include/json/forwards.h +0 -37
- package/android/src/main/jni/utils/jsoncpp/include/json/json.h +0 -15
- package/android/src/main/jni/utils/jsoncpp/include/json/reader.h +0 -411
- package/android/src/main/jni/utils/jsoncpp/include/json/value.h +0 -888
- package/android/src/main/jni/utils/jsoncpp/include/json/version.h +0 -20
- package/android/src/main/jni/utils/jsoncpp/include/json/writer.h +0 -357
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/jsontest.vcproj +0 -119
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/lib_json.vcproj +0 -205
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/test_lib_json.vcproj +0 -130
- package/android/src/main/jni/utils/jsoncpp/makerelease.py +0 -390
- package/android/src/main/jni/utils/jsoncpp/meson.build +0 -103
- package/android/src/main/jni/utils/jsoncpp/pkg-config/jsoncpp.pc.in +0 -9
- package/android/src/main/jni/utils/jsoncpp/src/CMakeLists.txt +0 -5
- package/android/src/main/jni/utils/jsoncpp/src/jsontestrunner/CMakeLists.txt +0 -25
- package/android/src/main/jni/utils/jsoncpp/src/jsontestrunner/main.cpp +0 -333
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/CMakeLists.txt +0 -117
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_reader.cpp +0 -2060
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_tool.h +0 -114
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_value.cpp +0 -1661
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_valueiterator.inl +0 -167
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_writer.cpp +0 -1233
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/version.h.in +0 -20
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/CMakeLists.txt +0 -38
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/jsontest.cpp +0 -457
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/jsontest.h +0 -286
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/main.cpp +0 -2606
- package/android/src/main/jni/utils/jsoncpp/travis.sh +0 -23
- package/android/src/main/jni/utils/jsoncpp/version +0 -1
- package/android/src/main/jni/utils/jsoncpp/version.in +0 -1
- package/android/src/main/jni/utils/logUtils.cpp +0 -108
- package/android/src/main/jni/utils/logUtils.h +0 -87
- package/android/src/main/jni/utils/mSIGNA/stdutils/uchar_vector.h +0 -614
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
#ifndef JUB_GPC_APDU_SDK_H
|
|
2
|
-
#define JUB_GPC_APDU_SDK_H
|
|
3
|
-
//
|
|
4
|
-
// Generic helper definitions for shared library support
|
|
5
|
-
#include <stdint.h>
|
|
6
|
-
|
|
7
|
-
#if defined _MSC_VER || defined __CYGWIN__
|
|
8
|
-
#define JUB_COINCORE_DLL_IMPORT extern "C" __declspec(dllimport)
|
|
9
|
-
#define JUB_COINCORE_DLL_EXPORT extern "C" __declspec(dllexport)
|
|
10
|
-
#define JUB_COINCORE_DLL_LOCAL
|
|
11
|
-
#else
|
|
12
|
-
#if __GNUC__ >= 4
|
|
13
|
-
#define JUB_COINCORE_DLL_IMPORT __attribute__((visibility("default")))
|
|
14
|
-
#define JUB_COINCORE_DLL_EXPORT __attribute__((visibility("default")))
|
|
15
|
-
#define JUB_COINCORE_DLL_LOCAL __attribute__((visibility("internal")))
|
|
16
|
-
#else
|
|
17
|
-
#define JUB_COINCORE_DLL_IMPORT
|
|
18
|
-
#define JUB_COINCORE_DLL_EXPORT
|
|
19
|
-
#define JUB_COINCORE_DLL_LOCAL
|
|
20
|
-
#endif // #if __GNUC__ >= 4
|
|
21
|
-
#endif // #if defined _MSC_VER || defined __CYGWIN__
|
|
22
|
-
|
|
23
|
-
// Tag to deprecate functions and methods.
|
|
24
|
-
// Gives a compiler warning when they are used.
|
|
25
|
-
#if defined _MSC_VER || defined __CYGWIN__
|
|
26
|
-
#define BC_DEPRECATED __declspec(deprecated)
|
|
27
|
-
#else
|
|
28
|
-
#if __GNUC__ >= 4
|
|
29
|
-
#define JUB_DEPRECATED __attribute__((deprecated))
|
|
30
|
-
#else
|
|
31
|
-
#define JUB_DEPRECATED
|
|
32
|
-
#endif // #if __GNUC__ >= 4
|
|
33
|
-
#endif // #if defined _MSC_VER || defined __CYGWIN__
|
|
34
|
-
|
|
35
|
-
// Avoid namespace conflict between boost::placeholders and std::placeholders.
|
|
36
|
-
#define BOOST_BIND_NO_PLACEHOLDERS
|
|
37
|
-
|
|
38
|
-
// Define so we can have better visibility of lcov exclusion ranges.
|
|
39
|
-
#define LCOV_EXCL_START(text)
|
|
40
|
-
#define LCOV_EXCL_STOP()
|
|
41
|
-
|
|
42
|
-
#if defined(_WIN32)
|
|
43
|
-
#define HID_MODE
|
|
44
|
-
#elif defined(__APPLE__)
|
|
45
|
-
// see https://sourceforge.net/p/predef/mailman/message/34497133/
|
|
46
|
-
#include <TargetConditionals.h>
|
|
47
|
-
#if TARGET_OS_OSX // mac osx
|
|
48
|
-
#define HID_MODE
|
|
49
|
-
#elif TARGET_OS_IOS // ios
|
|
50
|
-
#define BLE_MODE
|
|
51
|
-
#define NFC_MODE
|
|
52
|
-
#endif // #if TARGET_OS_OSX
|
|
53
|
-
#elif defined(__ANDROID__)
|
|
54
|
-
#define BLE_MODE
|
|
55
|
-
#define NFC_MODE
|
|
56
|
-
#else // other
|
|
57
|
-
#define HID_MODE
|
|
58
|
-
#endif // #if defined(_WIN32)
|
|
59
|
-
|
|
60
|
-
#define JUBR_OK 0x00000000UL
|
|
61
|
-
|
|
62
|
-
#define JUBR_ERROR 0x00000001UL
|
|
63
|
-
#define JUBR_HOST_MEMORY 0x00000002UL
|
|
64
|
-
#define JUBR_ARGUMENTS_BAD 0x00000003UL
|
|
65
|
-
#define JUBR_IMPL_NOT_SUPPORT 0x00000004UL
|
|
66
|
-
#define JUBR_MEMORY_NULL_PTR 0x00000005UL
|
|
67
|
-
#define JUBR_CONTEXT_NOT_SATISFIED 0x00000006UL
|
|
68
|
-
|
|
69
|
-
#define JUBR_INVALID_MEMORY_PTR 0x00000008UL
|
|
70
|
-
#define JUBR_REPEAT_MEMORY_PTR 0x00000009UL
|
|
71
|
-
#define JUBR_BUFFER_TOO_SMALL 0x0000000AUL
|
|
72
|
-
|
|
73
|
-
/* === Library typedef: === */
|
|
74
|
-
#ifndef IN
|
|
75
|
-
#define IN
|
|
76
|
-
#endif // #ifndef IN
|
|
77
|
-
|
|
78
|
-
#ifndef OUT
|
|
79
|
-
#define OUT
|
|
80
|
-
#endif // #ifndef OUT
|
|
81
|
-
|
|
82
|
-
#ifndef INOUT
|
|
83
|
-
#define INOUT
|
|
84
|
-
#endif // #ifndef INOUT
|
|
85
|
-
|
|
86
|
-
#define JUB_TRUE 1
|
|
87
|
-
#define JUB_FALSE 0
|
|
88
|
-
|
|
89
|
-
#ifndef JUB_DISABLE_TRUE_FALSE
|
|
90
|
-
#ifndef FALSE
|
|
91
|
-
#define FALSE JUB_FALSE
|
|
92
|
-
#endif // #ifndef FALSE
|
|
93
|
-
|
|
94
|
-
#ifndef TRUE
|
|
95
|
-
#define TRUE JUB_TRUE
|
|
96
|
-
#endif // #ifndef TRUE
|
|
97
|
-
#endif // #ifndef JUB_DISABLE_TRUE_FALSE
|
|
98
|
-
|
|
99
|
-
/* an unsigned 8-bit value */
|
|
100
|
-
typedef unsigned char JUB_BYTE;
|
|
101
|
-
|
|
102
|
-
/* an unsigned 8-bit character */
|
|
103
|
-
typedef JUB_BYTE JUB_UCHAR;
|
|
104
|
-
|
|
105
|
-
/* an unsigned/signed 8-bit character, decide by complie*/
|
|
106
|
-
typedef char JUB_CHAR;
|
|
107
|
-
|
|
108
|
-
/* an 8-bit UTF-8 character */
|
|
109
|
-
typedef JUB_BYTE JUB_UTF8UCHAR;
|
|
110
|
-
|
|
111
|
-
/* a BYTE-sized Boolean flag */
|
|
112
|
-
typedef JUB_BYTE JUB_BBOOL;
|
|
113
|
-
|
|
114
|
-
/* an unsigned value, at least 32 bits long */
|
|
115
|
-
typedef unsigned long int JUB_ULONG;
|
|
116
|
-
|
|
117
|
-
/* a signed value, the same size as a JUB_ULONG */
|
|
118
|
-
typedef signed long int JUB_LONG;
|
|
119
|
-
|
|
120
|
-
typedef JUB_BYTE JUB_UINT8;
|
|
121
|
-
|
|
122
|
-
typedef unsigned int JUB_UINT32;
|
|
123
|
-
|
|
124
|
-
typedef unsigned short JUB_UINT16;
|
|
125
|
-
|
|
126
|
-
/* uint64 */
|
|
127
|
-
typedef unsigned long long JUB_UINT64;
|
|
128
|
-
|
|
129
|
-
/* signed uint64 */
|
|
130
|
-
typedef signed long long JUB_INT64;
|
|
131
|
-
|
|
132
|
-
#define JUB_PTR *
|
|
133
|
-
typedef JUB_CHAR JUB_PTR JUB_CHAR_PTR;
|
|
134
|
-
typedef JUB_CHAR_PTR JUB_PTR JUB_CHAR_PTR_PTR;
|
|
135
|
-
typedef const JUB_CHAR JUB_PTR JUB_CHAR_CPTR;
|
|
136
|
-
typedef const JUB_BYTE JUB_PTR JUB_BYTE_CPTR;
|
|
137
|
-
|
|
138
|
-
typedef JUB_BYTE JUB_PTR JUB_BYTE_PTR;
|
|
139
|
-
typedef const JUB_BYTE JUB_PTR JUB_BYTE_CPTR;
|
|
140
|
-
typedef JUB_UCHAR JUB_PTR JUB_UCHAR_PTR;
|
|
141
|
-
typedef JUB_UTF8UCHAR JUB_PTR JUB_UTF8UCHAR_PTR;
|
|
142
|
-
typedef JUB_ULONG JUB_PTR JUB_ULONG_PTR;
|
|
143
|
-
typedef JUB_UINT16 JUB_PTR JUB_UINT16_PTR;
|
|
144
|
-
typedef JUB_UINT32 JUB_PTR JUB_UINT32_PTR;
|
|
145
|
-
typedef JUB_UINT64 JUB_PTR JUB_UINT64_PTR;
|
|
146
|
-
typedef void JUB_PTR JUB_VOID_PTR;
|
|
147
|
-
|
|
148
|
-
/* Pointer to a JUB_VOID_PTR-- i.e., pointer to pointer to void */
|
|
149
|
-
typedef JUB_VOID_PTR JUB_PTR JUB_VOID_PTR_PTR;
|
|
150
|
-
|
|
151
|
-
typedef JUB_ULONG JUB_RV;
|
|
152
|
-
|
|
153
|
-
#ifdef __cplusplus
|
|
154
|
-
extern "C"
|
|
155
|
-
{
|
|
156
|
-
#endif // #ifdef __cplusplus
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* SharedInfo.
|
|
160
|
-
*/
|
|
161
|
-
typedef struct JUB_GPC_SCP11_SHAREDINFO
|
|
162
|
-
{
|
|
163
|
-
uint32_t scpID; // SCP identifier and parameters, for SCP11c 0x1107
|
|
164
|
-
uint32_t keyUsage; // Key Usage Qualifier, for SCP11c 0x3C
|
|
165
|
-
uint32_t keyType; // Key Type, for SCP11c, it's 0x88 (AES)
|
|
166
|
-
uint32_t keyLength; // Key Length, 0x10
|
|
167
|
-
JUB_CHAR hostID[33]; // hostID string, max length 32
|
|
168
|
-
} GPC_SCP11_SHAREDINFO;
|
|
169
|
-
|
|
170
|
-
/*****************************************************************************
|
|
171
|
-
* @function name : JUB_FreeMemory
|
|
172
|
-
* @in param : memPtr
|
|
173
|
-
* @out param :
|
|
174
|
-
* @last change :
|
|
175
|
-
*****************************************************************************/
|
|
176
|
-
JUB_RV JUB_FreeMemory(IN JUB_CHAR_CPTR memPtr);
|
|
177
|
-
|
|
178
|
-
/*****************************************************************************
|
|
179
|
-
* @function name : JUB_GPC_TLVDecode
|
|
180
|
-
* @in param : tlv - TLV
|
|
181
|
-
* tag - tag
|
|
182
|
-
* @out param : value - value
|
|
183
|
-
* @last change :
|
|
184
|
-
*****************************************************************************/
|
|
185
|
-
JUB_COINCORE_DLL_EXPORT
|
|
186
|
-
JUB_RV JUB_GPC_TLVDecode(IN JUB_CHAR_CPTR tlv,
|
|
187
|
-
OUT JUB_ULONG_PTR tag,
|
|
188
|
-
OUT JUB_CHAR_PTR_PTR value);
|
|
189
|
-
|
|
190
|
-
/*****************************************************************************
|
|
191
|
-
* @function name : JUB_GPC_Initialize
|
|
192
|
-
* @in param : sharedInfo - SCP11 sharedInfo
|
|
193
|
-
* oce_crt - OCE certificate in hex string
|
|
194
|
-
* e_rk - Ephemeral private key of the OCE used for key agreement in hex string, ecdsa private key, length = 32
|
|
195
|
-
* @out param :
|
|
196
|
-
* @last change :
|
|
197
|
-
*****************************************************************************/
|
|
198
|
-
JUB_COINCORE_DLL_EXPORT
|
|
199
|
-
JUB_RV JUB_GPC_Initialize(IN GPC_SCP11_SHAREDINFO sharedInfo,
|
|
200
|
-
IN JUB_CHAR_CPTR card_group_id,
|
|
201
|
-
IN JUB_CHAR_CPTR oce_crt,
|
|
202
|
-
IN JUB_CHAR_CPTR oce_rk);
|
|
203
|
-
|
|
204
|
-
/*****************************************************************************
|
|
205
|
-
* @function name : JUB_GPC_Finalize
|
|
206
|
-
* @in param :
|
|
207
|
-
* @out param :
|
|
208
|
-
* @last change :
|
|
209
|
-
*****************************************************************************/
|
|
210
|
-
JUB_COINCORE_DLL_EXPORT
|
|
211
|
-
JUB_RV JUB_GPC_Finalize();
|
|
212
|
-
|
|
213
|
-
/*****************************************************************************
|
|
214
|
-
* @function name : JUB_GPC_BuildMutualAuthData
|
|
215
|
-
* @in param :
|
|
216
|
-
* @out param : apduData - APDU data for MutualAuth cmd in hex string
|
|
217
|
-
* @last change :
|
|
218
|
-
* @ condition: JUB_GPC_Initialize() has been called first.
|
|
219
|
-
*****************************************************************************/
|
|
220
|
-
JUB_COINCORE_DLL_EXPORT
|
|
221
|
-
JUB_RV JUB_GPC_BuildMutualAuthData(OUT JUB_CHAR_PTR_PTR apduData);
|
|
222
|
-
|
|
223
|
-
/*****************************************************************************
|
|
224
|
-
* @function name : JUB_GPC_OpenSecureChannel
|
|
225
|
-
* @in param : response - response from Mutual Auth command in hex string
|
|
226
|
-
* @out param :
|
|
227
|
-
* @last change :
|
|
228
|
-
* @ condition: JUB_GPC_Initialize() has been called first.
|
|
229
|
-
*****************************************************************************/
|
|
230
|
-
JUB_COINCORE_DLL_EXPORT
|
|
231
|
-
JUB_RV JUB_GPC_OpenSecureChannel(IN JUB_CHAR_CPTR response);
|
|
232
|
-
|
|
233
|
-
/*****************************************************************************
|
|
234
|
-
* @function name : JUB_GPC_BuildAPDU
|
|
235
|
-
* @in param : cla - Class byte of the command message
|
|
236
|
-
* ins - Instruction byte of the command message
|
|
237
|
-
* p1 - Reference control parameter 1
|
|
238
|
-
* p2 - Reference control parameter 2
|
|
239
|
-
* data - APDU data in hex string
|
|
240
|
-
* @out param : apdu - APDU in plain text
|
|
241
|
-
* @last change :
|
|
242
|
-
*****************************************************************************/
|
|
243
|
-
JUB_COINCORE_DLL_EXPORT
|
|
244
|
-
JUB_RV JUB_GPC_BuildAPDU(IN JUB_ULONG cla, IN JUB_ULONG ins,
|
|
245
|
-
IN JUB_ULONG p1, IN JUB_ULONG p2,
|
|
246
|
-
IN JUB_CHAR_CPTR data,
|
|
247
|
-
OUT JUB_CHAR_PTR_PTR apdu);
|
|
248
|
-
|
|
249
|
-
/*****************************************************************************
|
|
250
|
-
* @function name : JUB_GPC_ParseAPDUResponse
|
|
251
|
-
* @in param : response - command response in hex string
|
|
252
|
-
* @out param : pwRet - APDU response
|
|
253
|
-
* resp - APDU response data
|
|
254
|
-
* @last change :
|
|
255
|
-
*****************************************************************************/
|
|
256
|
-
JUB_COINCORE_DLL_EXPORT
|
|
257
|
-
JUB_RV JUB_GPC_ParseAPDUResponse(IN JUB_CHAR_CPTR response,
|
|
258
|
-
OUT JUB_UINT16_PTR pwRet,
|
|
259
|
-
OUT JUB_CHAR_PTR_PTR resp);
|
|
260
|
-
|
|
261
|
-
/*****************************************************************************
|
|
262
|
-
* @function name : JUB_GPC_BuildSafeAPDU
|
|
263
|
-
* @in param : cla - Class byte of the command message
|
|
264
|
-
* ins - Instruction byte of the command message
|
|
265
|
-
* p1 - Reference control parameter 1
|
|
266
|
-
* p2 - Reference control parameter 2
|
|
267
|
-
* data - APDU data in hex string
|
|
268
|
-
* @out param : safeApdu - APDU in cipher text
|
|
269
|
-
* @last change :
|
|
270
|
-
* @ condition: JUB_GPC_Initialize() has been called first.
|
|
271
|
-
*****************************************************************************/
|
|
272
|
-
JUB_COINCORE_DLL_EXPORT
|
|
273
|
-
JUB_RV JUB_GPC_BuildSafeAPDU(IN JUB_ULONG cla, IN JUB_ULONG ins,
|
|
274
|
-
IN JUB_ULONG p1, IN JUB_ULONG p2,
|
|
275
|
-
IN JUB_CHAR_CPTR data,
|
|
276
|
-
OUT JUB_CHAR_PTR_PTR safeApdu);
|
|
277
|
-
|
|
278
|
-
/*****************************************************************************
|
|
279
|
-
* @function name : JUB_GPC_ParseSafeAPDUResponse
|
|
280
|
-
* @in param : response - command response in hex string
|
|
281
|
-
* @out param : pwRet - APDU response
|
|
282
|
-
* decResp - APDU response data in plain text
|
|
283
|
-
* @last change :
|
|
284
|
-
* @ condition: JUB_GPC_Initialize() has been called first.
|
|
285
|
-
*****************************************************************************/
|
|
286
|
-
JUB_COINCORE_DLL_EXPORT
|
|
287
|
-
JUB_RV JUB_GPC_ParseSafeAPDUResponse(IN JUB_CHAR_CPTR response,
|
|
288
|
-
OUT JUB_UINT16_PTR pwRet,
|
|
289
|
-
OUT JUB_CHAR_PTR_PTR decResp);
|
|
290
|
-
|
|
291
|
-
/*****************************************************************************
|
|
292
|
-
* @function name : JUB_GPC_ParseCertificate
|
|
293
|
-
* @in param : cert - certificate of a device
|
|
294
|
-
* @out param : sn - Certificate Serial Number
|
|
295
|
-
* : subjectID - Subject Identifier in hex
|
|
296
|
-
* @last change :
|
|
297
|
-
*****************************************************************************/
|
|
298
|
-
JUB_COINCORE_DLL_EXPORT
|
|
299
|
-
JUB_RV JUB_GPC_ParseCertificate(IN JUB_CHAR_CPTR cert,
|
|
300
|
-
OUT JUB_CHAR_PTR_PTR sn,
|
|
301
|
-
OUT JUB_CHAR_PTR_PTR subjectID);
|
|
302
|
-
|
|
303
|
-
#ifdef __cplusplus
|
|
304
|
-
}
|
|
305
|
-
#endif // #ifdef __cplusplus
|
|
306
|
-
#endif /* JUB_GPC_APDU_SDK_H */
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#ifndef __Context__
|
|
3
|
-
#define __Context__
|
|
4
|
-
|
|
5
|
-
#include "GPChannelSDK.h"
|
|
6
|
-
|
|
7
|
-
#include <string>
|
|
8
|
-
#include <vector>
|
|
9
|
-
#include <iostream>
|
|
10
|
-
#include <memory>
|
|
11
|
-
|
|
12
|
-
#include "scp03/scp03.hpp"
|
|
13
|
-
#include "scp11/scp11c.hpp"
|
|
14
|
-
//#include "utility/Singleton.h"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
namespace jub {
|
|
18
|
-
namespace context {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class BaseContext {
|
|
22
|
-
public:
|
|
23
|
-
BaseContext() {
|
|
24
|
-
}
|
|
25
|
-
BaseContext(const scp11_sharedInfo& info,
|
|
26
|
-
const scp11_crt& crt,
|
|
27
|
-
const std::vector<unsigned char>& rk) {
|
|
28
|
-
_scp03.reset();
|
|
29
|
-
_scp11 = scp11c(info, crt, rk);
|
|
30
|
-
}
|
|
31
|
-
virtual ~BaseContext() {
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
void clear() {
|
|
35
|
-
_scp03.reset();
|
|
36
|
-
_scp11.clear();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
scp03& getSCP03Instance() {
|
|
40
|
-
return _scp03;
|
|
41
|
-
}
|
|
42
|
-
scp11c& getSCP11cInstance() {
|
|
43
|
-
return _scp11;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private:
|
|
47
|
-
scp03 _scp03;
|
|
48
|
-
scp11c _scp11;
|
|
49
|
-
}; // class BaseContext end
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
} // namespace context end
|
|
53
|
-
} // namespace jub end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
#endif // #pragma once
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
#ifndef __ApduBuilder__
|
|
2
|
-
#define __ApduBuilder__
|
|
3
|
-
|
|
4
|
-
#include "utility/Apdu.hpp"
|
|
5
|
-
|
|
6
|
-
namespace jub {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class ApduBuilder {
|
|
10
|
-
public:
|
|
11
|
-
/* functions */
|
|
12
|
-
virtual JUB_RV BuildApdu(const APDU *apdu,
|
|
13
|
-
std::vector<JUB_BYTE> &vSafeApdu) = 0;
|
|
14
|
-
virtual JUB_RV BuildSafeApdu(const APDU *apdu, std::vector<JUB_BYTE> &vSafeApdu) = 0;
|
|
15
|
-
virtual JUB_RV ParseSafeApduResp(const JUB_BYTE_PTR respData, const JUB_ULONG respDataLen,
|
|
16
|
-
JUB_BYTE_PTR retData, JUB_ULONG_PTR pretDataLen,
|
|
17
|
-
JUB_UINT16 &wRet) = 0;
|
|
18
|
-
|
|
19
|
-
// do something (for example: encrypt data)
|
|
20
|
-
virtual JUB_RV PackData(std::vector<JUB_BYTE> &vDest,
|
|
21
|
-
const std::vector<JUB_BYTE> &vSrc) = 0;
|
|
22
|
-
// do something (for example: decrypt data)
|
|
23
|
-
virtual JUB_RV UnPackData(std::vector<JUB_BYTE> &vDest,
|
|
24
|
-
const std::vector<JUB_BYTE> &vSrc) = 0;
|
|
25
|
-
|
|
26
|
-
virtual JUB_RV PlusCMAC(const APDU *apdu, APDU *apduSafe) = 0;
|
|
27
|
-
virtual JUB_RV CheckCMAC(const ResponseAPDU &respApdu) = 0;
|
|
28
|
-
|
|
29
|
-
virtual JUB_RV SetSCP03(void *pscp03) = 0;
|
|
30
|
-
virtual JUB_RV SetSCP11(void *pscp11) = 0;
|
|
31
|
-
|
|
32
|
-
protected:
|
|
33
|
-
virtual JUB_RV IncCounter() = 0;
|
|
34
|
-
}; // class ApduBuilder end
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class JubApduBuiler
|
|
38
|
-
: public ApduBuilder {
|
|
39
|
-
public:
|
|
40
|
-
/* functions */
|
|
41
|
-
virtual JUB_RV BuildApdu(const APDU *apdu, std::vector<JUB_BYTE> &vApdu);
|
|
42
|
-
virtual JUB_RV ParseApduResp(const JUB_BYTE_PTR respData, const JUB_ULONG respDataLen,
|
|
43
|
-
JUB_BYTE_PTR retData, JUB_ULONG_PTR pretDataLen,
|
|
44
|
-
JUB_UINT16 &wRet);
|
|
45
|
-
|
|
46
|
-
virtual JUB_RV BuildSafeApdu(const APDU *apdu, std::vector<JUB_BYTE> &vSafeApdu);
|
|
47
|
-
virtual JUB_RV ParseSafeApduResp(const JUB_BYTE_PTR respData, const JUB_ULONG respDataLen,
|
|
48
|
-
JUB_BYTE_PTR retData, JUB_ULONG_PTR pretDataLen,
|
|
49
|
-
JUB_UINT16 &wRet);
|
|
50
|
-
|
|
51
|
-
virtual JUB_RV PackData(std::vector<JUB_BYTE> &vDest,
|
|
52
|
-
const std::vector<JUB_BYTE> &vSrc);
|
|
53
|
-
virtual JUB_RV UnPackData(std::vector<JUB_BYTE> &vDest,
|
|
54
|
-
const std::vector<JUB_BYTE> &vSrc);
|
|
55
|
-
|
|
56
|
-
virtual JUB_RV PlusCMAC(const APDU *apdu, APDU *apduSafe);
|
|
57
|
-
virtual JUB_RV CheckCMAC(const ResponseAPDU &respApdu);
|
|
58
|
-
|
|
59
|
-
virtual JUB_RV SetSCP03(void *scp03Ptr);
|
|
60
|
-
virtual JUB_RV SetSCP11(void *scp11Ptr);
|
|
61
|
-
|
|
62
|
-
protected:
|
|
63
|
-
virtual JUB_RV IncCounter() override;
|
|
64
|
-
|
|
65
|
-
private:
|
|
66
|
-
void *_scp03Ptr;
|
|
67
|
-
void *_scp11Ptr;
|
|
68
|
-
}; // class JubApduBuiler end
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
} // namespace jub end
|
|
72
|
-
#endif // __ApduBuilder__
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
#ifndef __Apdu__
|
|
3
|
-
#define __Apdu__
|
|
4
|
-
|
|
5
|
-
#include "GPChannelSDK.h"
|
|
6
|
-
|
|
7
|
-
#include <vector>
|
|
8
|
-
|
|
9
|
-
namespace jub {
|
|
10
|
-
|
|
11
|
-
class APDU {
|
|
12
|
-
|
|
13
|
-
public:
|
|
14
|
-
APDU() {
|
|
15
|
-
cla = 0;
|
|
16
|
-
ins = 0;
|
|
17
|
-
p1 = 0;
|
|
18
|
-
p2 = 0;
|
|
19
|
-
lc = 0;
|
|
20
|
-
le = 0;
|
|
21
|
-
data.clear();
|
|
22
|
-
}
|
|
23
|
-
APDU(JUB_ULONG ncla,
|
|
24
|
-
JUB_ULONG nins,
|
|
25
|
-
JUB_ULONG np1,
|
|
26
|
-
JUB_ULONG np2,
|
|
27
|
-
JUB_ULONG nlc,
|
|
28
|
-
const JUB_BYTE* pData = nullptr,
|
|
29
|
-
JUB_ULONG nle = 0) :
|
|
30
|
-
cla(ncla),
|
|
31
|
-
ins(nins),
|
|
32
|
-
p1(np1),
|
|
33
|
-
p2(np2),
|
|
34
|
-
lc(nlc),
|
|
35
|
-
le(nle) {
|
|
36
|
-
if ( 0 != lc
|
|
37
|
-
&& nullptr != pData
|
|
38
|
-
) {
|
|
39
|
-
SetData(pData, lc);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
data.clear();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
~APDU() {}
|
|
46
|
-
|
|
47
|
-
public:
|
|
48
|
-
JUB_ULONG cla, ins, p1, p2, lc, le;
|
|
49
|
-
std::vector<JUB_BYTE> data;
|
|
50
|
-
|
|
51
|
-
public:
|
|
52
|
-
void SetApdu(JUB_ULONG ncla,
|
|
53
|
-
JUB_ULONG nins,
|
|
54
|
-
JUB_ULONG np1,
|
|
55
|
-
JUB_ULONG np2,
|
|
56
|
-
JUB_ULONG nlc,
|
|
57
|
-
JUB_BYTE* pData = nullptr,
|
|
58
|
-
JUB_ULONG nle = 0) {
|
|
59
|
-
cla = ncla;
|
|
60
|
-
ins = nins;
|
|
61
|
-
p1 = np1;
|
|
62
|
-
p2 = np2;
|
|
63
|
-
lc = nlc;
|
|
64
|
-
le = nle;
|
|
65
|
-
if ( 0 != lc
|
|
66
|
-
&& nullptr != pData
|
|
67
|
-
) {
|
|
68
|
-
SetData(pData, lc);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
data.clear();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
void SetData(const JUB_BYTE* pData, JUB_ULONG ulDataSize) {
|
|
75
|
-
// assert(ulDataSize == lc);
|
|
76
|
-
data.clear();
|
|
77
|
-
// data.resize(ulDataSize);
|
|
78
|
-
data.insert(data.begin(), pData, pData + ulDataSize);
|
|
79
|
-
}
|
|
80
|
-
}; // class APDU end
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
class ResponseAPDU {
|
|
84
|
-
|
|
85
|
-
public:
|
|
86
|
-
ResponseAPDU() {
|
|
87
|
-
raw.clear();
|
|
88
|
-
clear();
|
|
89
|
-
}
|
|
90
|
-
ResponseAPDU(std::vector<JUB_BYTE> raw)
|
|
91
|
-
: raw(raw) {
|
|
92
|
-
clear();
|
|
93
|
-
}
|
|
94
|
-
ResponseAPDU(JUB_BYTE_PTR ret, JUB_ULONG retLen) {
|
|
95
|
-
raw.insert(raw.end(), ret, ret+retLen);
|
|
96
|
-
clear();
|
|
97
|
-
}
|
|
98
|
-
~ResponseAPDU() {
|
|
99
|
-
raw.clear();
|
|
100
|
-
clear();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
void clear() {
|
|
104
|
-
data.clear();
|
|
105
|
-
cmac.clear();
|
|
106
|
-
SW1 = 0;
|
|
107
|
-
SW2 = 0;
|
|
108
|
-
}
|
|
109
|
-
bool empty() {
|
|
110
|
-
return ( data.empty()
|
|
111
|
-
&& cmac.empty()
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
bool decode(bool hasMac=true) {
|
|
116
|
-
if (raw.empty()) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if ( CMAC_LEN > raw.size()
|
|
121
|
-
&& SW_LEN != raw.size()
|
|
122
|
-
) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
clear();
|
|
127
|
-
|
|
128
|
-
// parse SW
|
|
129
|
-
int swIndex1 = (int)raw.size() - SW_LEN;
|
|
130
|
-
int swIndex2 = (int)raw.size() - 1;
|
|
131
|
-
SW1 = raw[swIndex1];
|
|
132
|
-
SW2 = raw[swIndex2];
|
|
133
|
-
if (SW_LEN == raw.size()) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
int cmacLen = 0;
|
|
138
|
-
if (hasMac) {
|
|
139
|
-
cmacLen = CMAC_LEN;
|
|
140
|
-
}
|
|
141
|
-
int cmacIndex = (int)raw.size() - SW_LEN - cmacLen;
|
|
142
|
-
data.insert(data.end(), raw.begin(), raw.begin()+cmacIndex);
|
|
143
|
-
if (hasMac) {
|
|
144
|
-
cmac.insert(cmac.end(), raw.begin()+cmacIndex, raw.begin()+swIndex1);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
public:
|
|
151
|
-
const int CMAC_LEN = 8;
|
|
152
|
-
const int SW_LEN = 2;
|
|
153
|
-
|
|
154
|
-
std::vector<JUB_BYTE> data;
|
|
155
|
-
std::vector<JUB_BYTE> cmac;
|
|
156
|
-
JUB_BYTE SW1;
|
|
157
|
-
JUB_BYTE SW2;
|
|
158
|
-
|
|
159
|
-
private:
|
|
160
|
-
std::vector<JUB_BYTE> raw;
|
|
161
|
-
}; // class ResponseAPDU end
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} // namespace jub end
|
|
165
|
-
|
|
166
|
-
#endif // __Apdu__
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
#ifndef __DEBUG_H__
|
|
3
|
-
#define __DEBUG_H__
|
|
4
|
-
|
|
5
|
-
#include <string>
|
|
6
|
-
|
|
7
|
-
#ifdef ANDROID
|
|
8
|
-
#include <android/log.h>
|
|
9
|
-
#endif
|
|
10
|
-
|
|
11
|
-
namespace jub {
|
|
12
|
-
|
|
13
|
-
#define DEBUG_LEVEL 1
|
|
14
|
-
|
|
15
|
-
#define JUB_DebugLevel(level, ...) \
|
|
16
|
-
{ \
|
|
17
|
-
if (DEBUG_LEVEL >= level) { \
|
|
18
|
-
JUB_DebugLog(__VA_ARGS__); \
|
|
19
|
-
} \
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
#define JUB_Debug(level, STR) \
|
|
23
|
-
{ \
|
|
24
|
-
if (DEBUG_LEVEL >= level) { \
|
|
25
|
-
JUB_DebugLog(STR); \
|
|
26
|
-
} \
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
#ifdef ANDROID
|
|
30
|
-
void JUB_DebugLog(android_LogPriority logPriority, const char *format, ...);
|
|
31
|
-
void JUB_DebugLog(android_LogPriority logPriority, const std::string &log);
|
|
32
|
-
#else
|
|
33
|
-
void JUB_DebugLog(const char *format, ...);
|
|
34
|
-
void JUB_DebugLog(const std::string &log);
|
|
35
|
-
#endif
|
|
36
|
-
|
|
37
|
-
#if defined(DEBUG) || defined(_DEBUG)
|
|
38
|
-
#ifdef ANDROID
|
|
39
|
-
#define DEBUG_LOG(...) jub::JUB_DebugLog(ANDROID_LOG_DEBUG, __VA_ARGS__)
|
|
40
|
-
#define DEBUG_ERR(...) jub::JUB_DebugLog(ANDROID_LOG_ERROR, __VA_ARGS__)
|
|
41
|
-
#else
|
|
42
|
-
#define DEBUG_LOG(...) jub::JUB_DebugLog(__VA_ARGS__)
|
|
43
|
-
#define DEBUG_ERR(...) jub::JUB_DebugLog(__VA_ARGS__)
|
|
44
|
-
#endif
|
|
45
|
-
#else
|
|
46
|
-
#define DEBUG_LOG(...)
|
|
47
|
-
#define DEBUG_ERR(...)
|
|
48
|
-
#endif
|
|
49
|
-
|
|
50
|
-
enum {
|
|
51
|
-
BA2S_AA_BB, //01 01 03 04
|
|
52
|
-
BA2S_0XAA_0XBB, //0x01 0x02 0x03 0x04
|
|
53
|
-
BA2S_AABB, //01020304
|
|
54
|
-
}; // enum end
|
|
55
|
-
|
|
56
|
-
std::string ByteArray2String(const uint8_t* buf, uint32_t len, uint8_t type = BA2S_AABB);
|
|
57
|
-
} // namespace jub end
|
|
58
|
-
|
|
59
|
-
#endif // __DEBUG_H__
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#ifndef COINPASS_SINGLETON_HPP
|
|
3
|
-
#define COINPASS_SINGLETON_HPP
|
|
4
|
-
|
|
5
|
-
template<typename T>
|
|
6
|
-
class Singleton {
|
|
7
|
-
|
|
8
|
-
public:
|
|
9
|
-
template<typename... Args>
|
|
10
|
-
static T* GetInstance(Args&&... args) {
|
|
11
|
-
if (nullptr == _pInstance) {
|
|
12
|
-
_pInstance = new T(std::forward<Args>(args)...);
|
|
13
|
-
}
|
|
14
|
-
return _pInstance;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static void DestroyInstance() {
|
|
18
|
-
delete _pInstance;
|
|
19
|
-
_pInstance = nullptr;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
private:
|
|
23
|
-
Singleton(void);
|
|
24
|
-
virtual ~Singleton(void);
|
|
25
|
-
Singleton(const Singleton&);
|
|
26
|
-
Singleton& operator = (const Singleton&);
|
|
27
|
-
|
|
28
|
-
private:
|
|
29
|
-
static T* _pInstance;
|
|
30
|
-
}; // class Singleton end
|
|
31
|
-
|
|
32
|
-
template <class T> T* Singleton<T>::_pInstance = nullptr;
|
|
33
|
-
|
|
34
|
-
#endif
|