lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 |
|
| 2 | /*****************************************************************************
|
| 3 | * °æ±¾ËùÓÐ (C)2013ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾
|
| 4 | *
|
| 5 | * Ä£¿éÃû £ºÐéÄ⿨
|
| 6 | * ÎļþÃû £ºvsim.h
|
| 7 | * Îļþ±êʶ£º
|
| 8 | * Ïà¹ØÎļþ£º
|
| 9 | * ʵÏÖ¹¦ÄÜ£º¶¨ÒåÐéÄ⿨Ïà¹ØºêºÍ½Ó¿Ú
|
| 10 | * ×÷Õß £º miaohaixiang
|
| 11 | * °æ±¾ £º
|
| 12 | * Íê³ÉÈÕÆÚ£º20160406
|
| 13 | * ÆäËü˵Ã÷£º
|
| 14 | *****************************************************************************/
|
| 15 | #ifndef UICC_VCARD_H
|
| 16 | #define UICC_VCARD_H
|
| 17 |
|
| 18 | #include <string.h>
|
| 19 | #include <stdio.h>
|
| 20 | #include <stdarg.h>
|
| 21 | #include <stdlib.h>
|
| 22 | #include <time.h>
|
| 23 | #include <syslog.h>
|
| 24 | #include <unistd.h>
|
| 25 | #include <errno.h>
|
| 26 | #include <signal.h>
|
| 27 | #include <netdb.h>
|
| 28 | #include <sys/types.h>
|
| 29 | #include <sys/ioctl.h>
|
| 30 | #include <sys/socket.h>
|
| 31 | #include <sys/time.h>
|
| 32 | #include <sys/uio.h>
|
| 33 | #include <sys/stat.h>
|
| 34 | #include <fcntl.h>
|
| 35 | #include <sys/sysctl.h>
|
| 36 | #include <poll.h>
|
| 37 | #include <stddef.h>
|
| 38 | #include <linux/if_packet.h>
|
| 39 | #include "softap_api.h"
|
| 40 | #include <sys/un.h>
|
| 41 | #include <ctype.h>
|
| 42 | #include <semaphore.h>
|
| 43 | #include <pthread.h>
|
| 44 |
|
| 45 | typedef unsigned char u8;
|
| 46 | typedef unsigned char Byte;
|
| 47 | typedef unsigned char BYTE;
|
| 48 | typedef unsigned char BITS;
|
| 49 | typedef unsigned short WORD;
|
| 50 | typedef UINT32 DWORD;
|
| 51 | typedef unsigned long long UINT64;
|
| 52 |
|
| 53 | //in bits
|
| 54 | #define VSIM_DIGIT_BITS 32
|
| 55 | #define VSIM_HALF_DIGIT_BITS 16
|
| 56 | //in bytes
|
| 57 | #define VSIM_DIGIT_LEN (VSIM_DIGIT_BITS / 8)
|
| 58 | //Max len in digits
|
| 59 | #define MAX_VSIM_DIGITS ((VSIM_MAX_RSA_MODULUS_LEN + VSIM_DIGIT_LEN - 1) / VSIM_DIGIT_LEN + 1)
|
| 60 | //Max digits
|
| 61 | #define MAX_VSIM_DIGIT 0xffffffff
|
| 62 | #define MAX_VSIM_HALF_DIGIT 0xffff
|
| 63 |
|
| 64 |
|
| 65 | #define VSIM_LOW_HALF(x) ((x) & MAX_VSIM_HALF_DIGIT)
|
| 66 | #define VSIM_HIGH_HALF(x) (((x) >> VSIM_HALF_DIGIT_BITS) & MAX_VSIM_HALF_DIGIT)
|
| 67 | #define VSIM_TO_HIGH_HALF(x) (((VSIM_DIGIT)(x)) << VSIM_HALF_DIGIT_BITS)
|
| 68 | #define VSIM_DIGIT_2MSB(x) (unsigned int)(((x) >> (VSIM_DIGIT_BITS - 2)) & 3)
|
| 69 |
|
| 70 | /*³£Á¿¶¨ÒåÇø*/
|
| 71 | #define Z_VCARD_NV_BIN_LENGTH (UINT32)4
|
| 72 | #define Z_VCARD_NV_MAGIC_NUM_LENGTH (UINT32)4
|
| 73 |
|
| 74 | #define Z_VCARD_NV_LENGTH_ADDR (UINT32)0
|
| 75 | #define Z_VCARD_NV_PUBLIC_KEY_ADDR (UINT32)(Z_VCARD_NV_LENGTH_ADDR + Z_VCARD_NV_BIN_LENGTH + Z_VCARD_NV_MAGIC_NUM_LENGTH)
|
| 76 | #define Z_VCARD_NV_AUTH_PARM_ADDR (UINT32)(Z_VCARD_NV_PUBLIC_KEY_ADDR + (sizeof(t_Vcard_EncPubKey)))
|
| 77 | #define Z_VCARD_NV_SEC_INFO_ADDR (UINT32)(Z_VCARD_NV_AUTH_PARM_ADDR + (sizeof(t_Vcard_AuthInfo)))
|
| 78 | #define Z_VCARD_NV_EF_CONTENT_ADDR (UINT32)(Z_VCARD_NV_SEC_INFO_ADDR + (sizeof(t_Vcard_SecurityInfo)))
|
| 79 | #define Z_VCARD_MAX_FLASH_BLOCK_SIZE (UINT32)262144
|
| 80 |
|
| 81 | #define UICC_VCARD_MAX_DF_FCP_LEN (BYTE)52
|
| 82 | #define UICC_VCARD_MAX_GSM_EF_FCP_LEN (BYTE)20
|
| 83 | #define UICC_VCARD_MAX_GSM_DF_FCP_LEN (BYTE)36
|
| 84 | #define UICC_VCARD_MAX_EF_NUM (BYTE)100
|
| 85 | #define UICC_VCARD_MAX_DF_NUM (BYTE)20
|
| 86 |
|
| 87 | #define UICC_VCARD_MAX_PIN_LEN (BYTE)8
|
| 88 | #define UICC_VCARD_MAX_PUK_LEN (BYTE)8
|
| 89 | #define UICC_VCARD_MAX_AID_LEN (BYTE)16
|
| 90 | #define UICC_VCARD_DIR_REC_LEN (BYTE)56
|
| 91 | #define UICC_VCARD_MIN_VALID_AID_LEN (BYTE)7
|
| 92 |
|
| 93 | #define UICC_VCARD_MAX_PIN1_RETRY_NUM (BYTE)3
|
| 94 | #define UICC_VCARD_MAX_PUK1_RETRY_NUM (BYTE)10
|
| 95 | #define UICC_VCARD_MAX_PIN2_RETRY_NUM (BYTE)3
|
| 96 | #define UICC_VCARD_MAX_PUK2_RETRY_NUM (BYTE)10
|
| 97 |
|
| 98 | #define DFKEY_MF (BYTE)0
|
| 99 | #define DFKEY_ADF (BYTE)1
|
| 100 | #define DFKEY_GSM (BYTE)2
|
| 101 | #define DFKEY_USIM_GSMACSS (BYTE)3
|
| 102 | #define DFKEY_USIM_MEXE (BYTE)4
|
| 103 | #define DFKEY_USIM_SOLSA (BYTE)5
|
| 104 | #define DFKEY_USIM_HNB (BYTE)6
|
| 105 | #define DFKEY_MF_TELE_PB (BYTE)7
|
| 106 | #define DFKEY_USIM_WLAN (BYTE)8
|
| 107 | #define DFKEY_MF_TELE_MMEDIA (BYTE)9
|
| 108 | #define DFKEY_MF_TELE_MMSS (BYTE)10
|
| 109 | #define DFKEY_MF_TELE (BYTE)11
|
| 110 | #define DFKEY_MF_TELE_GRAPH (BYTE)12
|
| 111 | #define DFKEY_USIM_PB (BYTE)13
|
| 112 | #define DFKEY_GSM_IRIDIUM (BYTE)14
|
| 113 | #define DFKEY_GSM_GLOBST (BYTE)15
|
| 114 | #define DFKEY_GSM_ICO (BYTE)16
|
| 115 | #define DFKEY_GSM_ACES (BYTE)17
|
| 116 | #define DFKEY_GSM_EIATIA (BYTE)18
|
| 117 | #define DFKEY_GSM_CTS (BYTE)19
|
| 118 | #define DFKEY_GSM_SOLSA (BYTE)20
|
| 119 | #define DFKEY_GSM_MEXE (BYTE)21
|
| 120 | #define DFKEY_MF_IS41 (BYTE)22
|
| 121 | #define DFKEY_MF_FPCTS (BYTE)23
|
| 122 | #define DFKEY_ISIM_MF (BYTE)24
|
| 123 | #define DFKEY_ISIM_ADF (BYTE)25
|
| 124 | #define DFKEY_ISIM_TELE (BYTE)26
|
| 125 | #define DFKEY_END (BYTE)DFKEY_ISIM_TELE
|
| 126 | #define Z_UICCMNG_MAX_DF_NUM (DFKEY_END+1)
|
| 127 | #define DFKEY_INVALID (BYTE)0xFF
|
| 128 | #define EFKEY_INVALID (WORD)0xFFFF
|
| 129 |
|
| 130 | /*DF FID*/
|
| 131 | #define UICC_VCARD_MF_FID (WORD)0x3F00
|
| 132 | #define UICC_VCARD_TELE_FID (WORD)0x7F10
|
| 133 | #define UICC_VCARD_GSM_FID (WORD)0x7F20
|
| 134 | #define UICC_VCARD_GRAPHICS_FID (WORD)0x5F50
|
| 135 | #define UICC_VCARD_USIM_FID (WORD)0x7FFF
|
| 136 | #define UICC_VCARD_USIM_PB_FID (WORD)0x5F3A
|
| 137 | #define UICC_VCARD_USIM_GSM_ACCESS_FID (WORD)0x5F3B
|
| 138 | #define UICC_VCARD_USIM_MEXE_FID (WORD)0x5F3C
|
| 139 | #define UICC_VCARD_USIM_SOLASA_FID (WORD)0x5F70
|
| 140 | #define UICC_VCARD_GSM_SOLASA_FID (WORD)0x5F70
|
| 141 | #define UICC_VCARD_ISIM_TELE_FID (WORD)0x7F10
|
| 142 | #define UICC_VCARD_ISIM_ADF_FID (WORD)0x7FFF
|
| 143 |
|
| 144 | /*SIM EF TYPE*/
|
| 145 | #define Z_VCARD_EF_REC_CONT (BYTE)0
|
| 146 | #define Z_VCARD_EF_BIN_CONT (BYTE)1
|
| 147 | #define Z_VCARD_DF_FCP (BYTE)2
|
| 148 | #define Z_VCARD_EF_FCP (BYTE)3
|
| 149 | #define Z_VCARD_SEC_INFO (BYTE)4
|
| 150 | #define Z_VCARD_AUTH_PARM (BYTE)5
|
| 151 |
|
| 152 | #define Z_VCARD_AUTH_PARM_SQN_MS (BYTE)0
|
| 153 | #define Z_VCARD_AUTH_PARM_K (BYTE)1
|
| 154 | #define Z_VCARD_AUTH_PARM_OP (BYTE)2
|
| 155 |
|
| 156 | #define Z_VCARD_SUCCESS (BYTE)0
|
| 157 | #define Z_VCARD_TYPE_NOT_SUPPORT (BYTE)1
|
| 158 | #define Z_VCARD_INVALID_LENGTH (BYTE)2
|
| 159 | #define Z_VCARD_INVALID_DATA (BYTE)3
|
| 160 | #define Z_VCARD_FILE_NOT_SUPPORT (BYTE)4
|
| 161 | #define Z_VCARD_CARD_NOT_INIT (BYTE)5
|
| 162 | #define Z_VCARD_INVALID_RECORD_NUM (BYTE)6
|
| 163 | #define Z_VCARD_MEMORY_ERROR (BYTE)7
|
| 164 | #define Z_VCARD_CARD_TYPE_ERROR (BYTE)8
|
| 165 | #define Z_VCARD_CARD_FILE_EXIST (BYTE)9
|
| 166 |
|
| 167 | /*File Type*/
|
| 168 | #define Z_VCARD_FILE_TYPE_INVALID (BYTE)0
|
| 169 | #define Z_VCARD_FILE_TYPE_DF (BYTE)1
|
| 170 | #define Z_VCARD_FILE_TYPE_EF (BYTE)2
|
| 171 |
|
| 172 | /*EF File Type*/
|
| 173 | typedef BYTE t_Vcard_EfFileType;
|
| 174 | #define Z_VCARD_EF_TYPE_BIN (BYTE)0
|
| 175 | #define Z_VCARD_EF_TYPE_REC (BYTE)1
|
| 176 | #define Z_VCARD_EF_TYPE_CYC (BYTE)2
|
| 177 |
|
| 178 | typedef BYTE t_Vcard_EFAppType;
|
| 179 | #define Z_VCARD_EF_SHARE (BYTE)0 /*ICCID µÈSIM USIM Ó¦Óù²ÏíµÄÎļþ*/
|
| 180 | #define Z_VCARD_EF_USIM_ONLY (BYTE)1
|
| 181 | #define Z_VCARD_EF_GSM_ONLY (BYTE)2
|
| 182 | #define Z_VCARD_EF_GSM_USIM (BYTE)3 /*USIM SIM Ó¦Óù²´æµÄÎļþ*/
|
| 183 |
|
| 184 | typedef BYTE t_Vcard_ChvPukType;
|
| 185 | #define Z_VCARD_TYPE_CHV1 (BYTE)0
|
| 186 | #define Z_VCARD_TYPE_PUK1 (BYTE)1
|
| 187 | #define Z_VCARD_TYPE_CHV2 (BYTE)2
|
| 188 | #define Z_VCARD_TYPE_PUK2 (BYTE)3
|
| 189 |
|
| 190 | /*Îļþ·ÃÎÊȨÏÞ*/
|
| 191 | typedef BYTE t_Vcard_AccRule;
|
| 192 | #define Z_VCARD_ACC_ALW (BYTE)0
|
| 193 | #define Z_VCARD_ACC_PIN1 (BYTE)1
|
| 194 | #define Z_VCARD_ACC_PIN2 (BYTE)2
|
| 195 | #define Z_VCARD_ACC_RFU (BYTE)3
|
| 196 | #define Z_VCARD_ACC_ADM (BYTE)4
|
| 197 | #define Z_VCARD_ACC_UNSUP (BYTE)15
|
| 198 |
|
| 199 | typedef BYTE t_Vcard_AccType;
|
| 200 | #define Z_VCARD_OPRT_READ (BYTE)0
|
| 201 | #define Z_VCARD_OPRT_UPDATE (BYTE)1
|
| 202 | #define Z_VCARD_OPRT_ACTIVE (BYTE)2
|
| 203 | #define Z_VCARD_OPRT_DEACTIVE (BYTE)3
|
| 204 | #define Z_VCARD_OPRT_INCREASE (BYTE)4
|
| 205 |
|
| 206 | #define Z_VCARD_DATA_CONTENT_OFFSET (DWORD)4
|
| 207 |
|
| 208 | #define Z_VCARD_APP_STAT_INITEING (BYTE)1
|
| 209 | #define Z_VCARD_APP_STAT_INITED (BYTE)2
|
| 210 | #define Z_VCARD_APP_STAT_TERM (BYTE)0
|
| 211 |
|
| 212 | #define UICC_VCARD_AUTH_RAND_LEN (BYTE)16
|
| 213 | #define UICC_VCARD_AUTH_AUTN_LEN (BYTE)16
|
| 214 | #define UICC_VCARD_AUTH_KC_LEN (BYTE)8
|
| 215 | #define UICC_VCARD_AUTH_CK_LEN (BYTE)16
|
| 216 | #define UICC_VCARD_AUTH_IK_LEN (BYTE)16
|
| 217 | #define UICC_VCARD_AUTH_RES_LEN (BYTE)16
|
| 218 | #define UICC_VCARD_AUTH_AUTS_LEN (BYTE)14
|
| 219 | #define UICC_VCARD_AUTH_AMF_LEN (BYTE)2
|
| 220 | #define UICC_VCARD_AUTH_MAC_LEN (BYTE)8
|
| 221 | #define UICC_VCARD_AUTH_SQN_LEN (BYTE)6
|
| 222 | #define UICC_VCARD_AUTH_MAC_A_LEN (BYTE)8
|
| 223 | #define UICC_VCARD_AUTH_XRES_LEN (BYTE)16
|
| 224 | #define UICC_VCARD_AUTH_AK_LEN (BYTE)6
|
| 225 | #define UICC_VCARD_AUTH_MAC_S_LEN (BYTE)8
|
| 226 | #define UICC_VCARD_AUTH_SRES_LEN (BYTE)4
|
| 227 | #define UICC_VCARD_AUTH_K_LEN (BYTE)16
|
| 228 | #define UICC_VCARD_AUTH_OP_LEN (BYTE)16
|
| 229 | #define UICC_VCARD_SQN_MS_NUM (BYTE)32
|
| 230 | #define UICC_VCARD_AUTH_ENCRYPT_K_LEN (BYTE)128
|
| 231 | #define UICC_VCARD_AUTH_ENCRYPT_OP_LEN (BYTE)128
|
| 232 | #define UICC_VCARD_ENC_PUBLIC_MOD_LEN (BYTE)128
|
| 233 | #define UICC_VCARD_ENC_PUBLIC_EXP_LEN (BYTE)128
|
| 234 | #define UICC_VCARD_PUBLIC_MOD_LEN (BYTE)128
|
| 235 | #define UICC_VCARD_PUBLIC_EXP_LEN (BYTE)128
|
| 236 |
|
| 237 | #define UICC_VCARD_AUTH_CAUSE_SYS_FAIL (BYTE)21
|
| 238 | #define UICC_VCARD_AUTH_CAUSE_MAC_FAIL (BYTE)20
|
| 239 |
|
| 240 | #define UICC_VCARD_MAX_BIN_SIZE (DWORD)(256*1024)
|
| 241 |
|
| 242 | #define Z_APUICC_USAT_MAX_AID_LEN (BYTE)16
|
| 243 |
|
| 244 | #define ZPS_ApUicc_APPMODE_NULL (BYTE)0
|
| 245 | #define Z_APUICC_APPMODE_NULL ZPS_ApUicc_APPMODE_NULL
|
| 246 | #define ZPS_ApUicc_APPMODE_USIM (BYTE)1
|
| 247 | #define Z_APUICC_APPMODE_USIM ZPS_ApUicc_APPMODE_USIM
|
| 248 | #define ZPS_ApUicc_APPMODE_SIM (BYTE)2
|
| 249 | #define Z_APUICC_APPMODE_SIM ZPS_ApUicc_APPMODE_SIM
|
| 250 | #define ZPS_ApUicc_APPMODE_ISIM (BYTE)3
|
| 251 | #define Z_APUICC_APPMODE_ISIM ZPS_ApUicc_APPMODE_ISIM
|
| 252 | #define ZPS_ApUicc_MAX_INITAPPMODEVAL (BYTE)ZPS_ApUicc_APPMODE_ISIM
|
| 253 | #define Z_APUICC_MAX_INITAPPMODEVAL ZPS_ApUicc_MAX_INITAPPMODEVAL
|
| 254 |
|
| 255 | #define ZOSS_SUCCESS 0x0
|
| 256 | #define ZOSS_ERROR 0xffffffff
|
| 257 | #define ZOSS_NULL NULL
|
| 258 |
|
| 259 | #define USIM_DFKEY_MF (BYTE)0
|
| 260 | #define USIM_DFKEY_USIM_ADF (BYTE)1
|
| 261 | #define USIM_DFKEY_USIM_PB (BYTE)2
|
| 262 | #define USIM_DFKEY_USIM_GSMACSS (BYTE)3
|
| 263 | #define USIM_DFKEY_USIM_MEXE (BYTE)4
|
| 264 | #define USIM_DFKEY_USIM_SOLSA (BYTE)5
|
| 265 | #define USIM_DFKEY_USIM_HNB (BYTE)6
|
| 266 | #define USIM_DFKEY_MF_TELE_PB (BYTE)7
|
| 267 | #define USIM_DFKEY_USIM_WLAN (BYTE)8
|
| 268 | #define USIM_DFKEY_MF_TELE_MMEDIA (BYTE)9
|
| 269 | #define USIM_DFKEY_MF_TELE_MMSS (BYTE)10
|
| 270 | #define USIM_DFKEY_MF_TELE (BYTE)11
|
| 271 | #define USIM_DFKEY_MF_TELE_GRAPH (BYTE)12
|
| 272 | #define USIM_DFKEY_MF_GSM (BYTE)13
|
| 273 | #define USIM_DFKEY_END (BYTE)USIM_DFKEY_MF_GSM
|
| 274 | #define USIM_DFKEY_NUM (BYTE)(USIM_DFKEY_END + 1)
|
| 275 | #define USIM_DFKEY_INVALID (BYTE)0xFF
|
| 276 |
|
| 277 | #define SIM_DFKEY_MF (BYTE)0
|
| 278 | #define SIM_DFKEY_MF_TELE (BYTE)1
|
| 279 | #define SIM_DFKEY_MF_TELE_GRAPH (BYTE)2
|
| 280 | #define SIM_DFKEY_GSM (BYTE)3
|
| 281 | #define SIM_DFKEY_GSM_IRIDIUM (BYTE)4 //NONE,ûÓÐÎļþ
|
| 282 | #define SIM_DFKEY_GSM_GLOBST (BYTE)5 //NONE
|
| 283 | #define SIM_DFKEY_GSM_ICO (BYTE)6 //NONE
|
| 284 | #define SIM_DFKEY_GSM_ACES (BYTE)7 //NONE
|
| 285 | #define SIM_DFKEY_GSM_EIATIA (BYTE)8 //NONE
|
| 286 | #define SIM_DFKEY_GSM_CTS (BYTE)9 //NONE
|
| 287 | #define SIM_DFKEY_GSM_SOLSA (BYTE)10
|
| 288 | #define SIM_DFKEY_GSM_MEXE (BYTE)11
|
| 289 | #define SIM_DFKEY_MF_IS41 (BYTE)12 //NONE
|
| 290 | #define SIM_DFKEY_MF_FPCTS (BYTE)13 //NONE
|
| 291 | #define SIM_DFKEY_END (BYTE)SIM_DFKEY_MF_FPCTS
|
| 292 | #define SIM_DFKEY_NUM (BYTE)(SIM_DFKEY_END + 1)
|
| 293 | #define SIM_DFKEY_INVALID (BYTE)0xFF
|
| 294 |
|
| 295 | #define Z_SUCC (BYTE)0
|
| 296 | #define Z_FAIL (BYTE)1
|
| 297 |
|
| 298 | /*==========STATUS WORD: SW1SW2===========*/
|
| 299 | #define Z_UICCMNG_SUCCESS (WORD)0x9000
|
| 300 | #define Z_UICCMNG_SUCCESS_CMD_PENDING (WORD)0x9100
|
| 301 | #define Z_UICCMNG_BUSY (WORD)0x9300
|
| 302 | #define Z_UICCMNG_WARNING (WORD)0x6200
|
| 303 | #define Z_UICCMNG_WARN_EOF (WORD)0x6282
|
| 304 | #define Z_UICCMNG_WARN_RETRIES (WORD)0x63C0
|
| 305 | #define Z_UICCMNG_ERROR (WORD)0x6400
|
| 306 | #define Z_UICCMNG_MEMORY_ERROR (WORD)0x6581
|
| 307 | #define Z_UICCMNG_ERR_WRONG_LENGTH (WORD)0x6700
|
| 308 | #define Z_UICCMNG_ERR_FILE_NOF_FOUND (WORD)0x6A82
|
| 309 | #define Z_UICCMNG_ERR_REC_NOT_FOUND (WORD)0x6A83
|
| 310 | #define Z_UICCMNG_FILE_SECURED (WORD)0x6982
|
| 311 | #define Z_UICCMNG_BLOCKED (WORD)0x6983
|
| 312 | #define Z_UICCMNG_EOF_REACHED (WORD)0x6282
|
| 313 | #define Z_UICCMNG_NOT_AVAIL (WORD)0x6985
|
| 314 | #define Z_UICCMNG_REF_NOT_FOUND (WORD)0x6A88
|
| 315 | #define Z_UICCMNG_GSM_ERR_WRONG_P3 (WORD)0x6700
|
| 316 | #define Z_UICCMNG_GSM_ERR_WRONG_P1_P2 (WORD)0x6B00
|
| 317 | #define Z_UICCMNG_GSM_ERR_TECHNICAL (WORD)0x6F00
|
| 318 | #define Z_UICCMNG_GSM_ERR_OUT_OF_RANGE (WORD)0x9402
|
| 319 | #define Z_UICCMNG_GSM_ERR_FILE_NOT_FOUND (WORD)0x9404
|
| 320 | #define Z_UICCMNG_GSM_ERR_FILE_INCONSISTENT (WORD)0x9408
|
| 321 | #define Z_UICCMNG_GSM_NO_CHV_INIT (WORD)0x9802
|
| 322 | #define Z_UICCMNG_GSM_UNSUCCESSFUL_SECURITY (WORD)0x9804/*access condition not fulfilled
|
| 323 | unsuccessful CHV verification, at least one attempt left
|
| 324 | unsuccessful UNBLOCK CHV verification, at least one attempt left
|
| 325 | authentication failed (see note)*/
|
| 326 | #define Z_UICCMNG_GSM_CONTRA_CHV_STATUS (WORD)0x9808
|
| 327 | #define Z_UICCMNG_GSM_CONTRA_INVAL_STATUS (WORD)0x9810
|
| 328 | #define Z_UICCMNG_GSM_CHV_FAIL_NO_ATTEMPS (WORD)0x9840 /*unsuccessful CHV verification, no attempt left
|
| 329 | unsuccessful UNBLOCK CHV verification, no attempt left
|
| 330 | CHV blocked
|
| 331 | UNBLOCK CHV blocked*/
|
| 332 | #define Z_UICCMNG_GSM_NO_INCREASE (WORD)0x9850
|
| 333 | #define Z_UICCMNG_GSM_SUCCESS_W_RESP_LEN (WORD)0x9F00
|
| 334 | #define Z_UICCMNG_GSM_SUCCESS_W_RESP_LEN_MASK (WORD)0xFF00
|
| 335 | #define Z_UICCMNG_WRAN_RETRIES (WORD)0x9200
|
| 336 | #define Z_UICCMNG_RETRIES_HB (WORD)0x6300
|
| 337 | #define Z_UICCMNG_WRAN_CORRUPT (WORD)0x6281
|
| 338 | #define Z_UICCMNG_INVALIDATED (WORD)0x6283
|
| 339 | #define Z_UICCMNG_ERROR_CHANGED (WORD)0x6500
|
| 340 | #define Z_UICCMNG_ERROR_INS (WORD)0x6D00
|
| 341 | #define Z_UICCMNG_WRONG_CLASS (WORD)0x6E00
|
| 342 | #define Z_UICCMNG_NO_CLA_SUPPORT (WORD)0x6800
|
| 343 | #define Z_UICCMNG_NO_LOG_CHAN (WORD)0x6881
|
| 344 | #define Z_UICCMNG_NO_SM (WORD)0x6882
|
| 345 | #define Z_UICCMNG_NOT_ALLOW (WORD)0x6900
|
| 346 | #define Z_UICCMNG_STRUCT_ERR (WORD)0x6981
|
| 347 | #define Z_UICCMNG_INVALID_DATA (WORD)0x6984
|
| 348 | #define Z_UICCMNG_NOT_EF (WORD)0x6986
|
| 349 | #define Z_UICCMNG_WRONG_PARA (WORD)0x6A80
|
| 350 | #define Z_UICCMNG_NO_FUNCTION (WORD)0x6A81
|
| 351 | #define Z_UICCMNG_ERR_P1_P2 (WORD)0x6A86
|
| 352 | #define Z_UICCMNG_ERR_LC (WORD)0x6A87
|
| 353 | #define Z_UICCMNG_ERR_AUTH (WORD)0x9862
|
| 354 | #define Z_UICCMNG_ERR_AUTH_GSM_NOT_SUPPORT (WORD)0x9864
|
| 355 | #define Z_UICCMNG_DL_RESP_LEN (WORD)0x9E00
|
| 356 | #define Z_UICCMNG_GSM_NO_EF (WORD)0x9400
|
| 357 |
|
| 358 | /*===========Z_UICC&SIM INS===========*/
|
| 359 | #define Z_UICCMNG_SIM_INS_SELECT (BYTE)0xA4
|
| 360 | #define Z_UICCMNG_SIM_INS_STATUS (BYTE)0xF2
|
| 361 | #define Z_UICCMNG_SIM_INS_READ_BINARY (BYTE)0xB0
|
| 362 | #define Z_UICCMNG_SIM_INS_UPDATE_BINARY (BYTE)0xD6
|
| 363 | #define Z_UICCMNG_SIM_INS_READ_RECORD (BYTE)0xB2
|
| 364 | #define Z_UICCMNG_SIM_INS_UPDATE_RECORD (BYTE)0xDC
|
| 365 | #define Z_UICCMNG_SIM_INS_SEARCH_RECORD (BYTE)0xA2
|
| 366 | #define Z_UICCMNG_SIM_INS_INCREASE (BYTE)0x32
|
| 367 | #define Z_UICCMNG_SIM_INS_VERIFY_PIN (BYTE)0x20
|
| 368 | #define Z_UICCMNG_SIM_INS_CHANGE_PIN (BYTE)0x24
|
| 369 | #define Z_UICCMNG_SIM_INS_DISABLE_PIN (BYTE)0x26
|
| 370 | #define Z_UICCMNG_SIM_INS_ENABLE_PIN (BYTE)0x28
|
| 371 | #define Z_UICCMNG_SIM_INS_UNBLOCK_PIN (BYTE)0x2C
|
| 372 | #define Z_UICCMNG_SIM_INS_DEACTIVATE_FILE (BYTE)0x04
|
| 373 | #define Z_UICCMNG_SIM_INS_ACTIVATE_FILE (BYTE)0x44
|
| 374 | #define Z_UICCMNG_SIM_INS_AUTHENTICATE (BYTE)0x88
|
| 375 | #define Z_UICCMNG_SIM_INS_GET_CHALLENGE (BYTE)0x84
|
| 376 | #define Z_UICCMNG_SIM_INS_TERMINAL_PROFILE (BYTE)0x10
|
| 377 | #define Z_UICCMNG_SIM_INS_ENVELOPE (BYTE)0xC2
|
| 378 | #define Z_UICCMNG_SIM_INS_FETCH (BYTE)0x12
|
| 379 | #define Z_UICCMNG_SIM_INS_TERMINAL_RESPONSE (BYTE)0x14
|
| 380 | #define Z_UICCMNG_SIM_INS_MANAGE_CHANNEL (BYTE)0x70
|
| 381 | #define Z_UICCMNG_SIM_INS_GET_RESPONSE (BYTE)0xC0
|
| 382 |
|
| 383 |
|
| 384 | /* Ŀ¼×î´óÉî¶È */
|
| 385 | #define Z_UICCMNG_PATH_DEPTH (BYTE)5
|
| 386 |
|
| 387 | /* FID×Ö½ÚÊý */
|
| 388 | #define Z_UICCMNG_FID_LEN (BYTE)2
|
| 389 |
|
| 390 | /*Authenticate length*/
|
| 391 | #define ZPS_ApUicc_MAX_LEN_RAND (BYTE)16
|
| 392 | #define Z_APUICC_MAX_LEN_RAND ZPS_ApUicc_MAX_LEN_RAND
|
| 393 | #define ZPS_ApUicc_MAX_LEN_AUTN (BYTE)16
|
| 394 | #define Z_APUICC_MAX_LEN_AUTN ZPS_ApUicc_MAX_LEN_AUTN
|
| 395 | #define ZPS_ApUicc_MAX_LEN_KC (BYTE)8
|
| 396 | #define Z_APUICC_MAX_LEN_KC ZPS_ApUicc_MAX_LEN_KC
|
| 397 | #define ZPS_ApUicc_MAX_LEN_RES (BYTE)16
|
| 398 | #define Z_APUICC_MAX_LEN_RES ZPS_ApUicc_MAX_LEN_RES
|
| 399 | #define ZPS_ApUicc_MAX_LEN_AUTS (BYTE)14
|
| 400 | #define Z_APUICC_MAX_LEN_AUTS ZPS_ApUicc_MAX_LEN_AUTS
|
| 401 | /*the flag of Authenticate context*/
|
| 402 | #define ZPS_ApUicc_AUTH_GSM (BYTE)0 /*GSM auth*/
|
| 403 | #define Z_APUICC_AUTH_GSM ZPS_ApUicc_AUTH_GSM
|
| 404 | #define ZPS_ApUicc_AUTH_UMTS (BYTE)1 /*UMTS auth*/
|
| 405 | #define Z_APUICC_AUTH_UMTS ZPS_ApUicc_AUTH_UMTS
|
| 406 |
|
| 407 | /*Authenticate err*/
|
| 408 | #define ZPS_ApUicc_AUTH_MACFAIL (BYTE)20 /*MAC failure*/
|
| 409 | #define Z_APUICC_AUTH_MACFAIL ZPS_ApUicc_AUTH_MACFAIL
|
| 410 | #define ZPS_ApUicc_AUTH_SYNCFAIL (BYTE)21 /*Sync failure*/
|
| 411 | #define Z_APUICC_AUTH_SYNCFAIL ZPS_ApUicc_AUTH_SYNCFAIL
|
| 412 | #define ZPS_ApUicc_AUTH_GSMAUTHUNACCPT (BYTE)23 /*Gsm auth unaccept*/
|
| 413 | #define Z_APUICC_AUTH_GSMAUTHUNACCPT ZPS_ApUicc_AUTH_GSMAUTHUNACCPT
|
| 414 | #define ZPS_ApUicc_AUTH_OTHERFAIL (BYTE) 0xFF
|
| 415 | #define Z_APUICC_AUTH_OTHERFAIL ZPS_ApUicc_AUTH_OTHERFAIL
|
| 416 |
|
| 417 | typedef struct
|
| 418 | {
|
| 419 | BYTE abFid[Z_UICCMNG_FID_LEN];
|
| 420 | }T_zUiccmng_FileID;
|
| 421 |
|
| 422 | typedef struct
|
| 423 | {
|
| 424 | BYTE bPathLen;
|
| 425 | T_zUiccmng_FileID tFid[Z_UICCMNG_PATH_DEPTH];
|
| 426 | }T_zUiccmng_Path;
|
| 427 |
|
| 428 | typedef struct{
|
| 429 | WORD wCurNo; /*ÂëÁ÷´æ·ÅµÄ×Ö½ÚÊýÖ¸Õ룬±ÈÈçÊǵڼ¸¸ö×Ö½Ú*/
|
| 430 | BYTE bCurBitPtr; /*ÂëÁ÷ÔÚ×Ö½ÚÖеĿªÊ¼µØÖ·Ö¸Õ룬±ÈÈçÊǵڼ¸¸ö×ֽڵĵڼ¸Î»*/
|
| 431 | WORD wLen; /*ÂëÁ÷¿ª±ÙµÄ³¤¶È£¬·ÀÖ¹Òç³ö*/
|
| 432 | BYTE *pbCode; /* ÔʼÂëÁ÷*/
|
| 433 | BYTE bBitEd; /*ÂëÁ÷ÔÚÄÚ´æÖнáÊøµÄÔʼµØÖ·Ö¸Õë*/
|
| 434 | BITS bType1:1; /*¸ÃÎļþÊÇ·ñΪÀàÐÍ1£¬²»ÎªÀàÐÍ1£º1£¬ÎªÀàÐÍ1£º0*/
|
| 435 | BITS :7;
|
| 436 | }T_zUiccmng_CdecInfo_T;
|
| 437 |
|
| 438 |
|
| 439 | typedef BYTE t_Vcard_auth_sqn_ms[8];
|
| 440 |
|
| 441 | typedef struct
|
| 442 | {
|
| 443 | BYTE bAuthType;
|
| 444 | BYTE abRand[UICC_VCARD_AUTH_RAND_LEN];
|
| 445 | BYTE abAutn[UICC_VCARD_AUTH_AUTN_LEN];
|
| 446 | }t_vcard_AuthParm;
|
| 447 |
|
| 448 | typedef struct
|
| 449 | {
|
| 450 | BYTE abKc[UICC_VCARD_AUTH_KC_LEN];
|
| 451 | BYTE abCK[UICC_VCARD_AUTH_CK_LEN];
|
| 452 | BYTE abIK[UICC_VCARD_AUTH_IK_LEN];
|
| 453 | BYTE abRes[UICC_VCARD_AUTH_RES_LEN];
|
| 454 | }t_vcard_Succ;
|
| 455 |
|
| 456 | typedef struct
|
| 457 | {
|
| 458 | BYTE bFailCause;
|
| 459 | BYTE abAuts[UICC_VCARD_AUTH_AUTS_LEN];
|
| 460 | }t_vcard_Fail;
|
| 461 |
|
| 462 | typedef union
|
| 463 | {
|
| 464 | t_vcard_Succ tAuthSucc;
|
| 465 | t_vcard_Fail tAuthFail;
|
| 466 | }t_u_Vcard_AuthRsp;
|
| 467 |
|
| 468 | typedef struct{
|
| 469 | BYTE bAuthRlt;
|
| 470 | t_u_Vcard_AuthRsp uAuthRsp;
|
| 471 | } t_vcard_AuthRst;
|
| 472 |
|
| 473 | typedef struct
|
| 474 | {
|
| 475 | BYTE bExistFlag;
|
| 476 | BYTE bRecNum;
|
| 477 | BYTE bRecLen;
|
| 478 | DWORD dwAddrOffset;
|
| 479 | }t_vCard_EfFileInfo;
|
| 480 |
|
| 481 | typedef struct
|
| 482 | {
|
| 483 | WORD wFid;
|
| 484 | t_vCard_EfFileInfo tUsimInfo;
|
| 485 | t_vCard_EfFileInfo tSimInfo;
|
| 486 | }t_Vcard_EfFcp;
|
| 487 |
|
| 488 | typedef struct
|
| 489 | {
|
| 490 | BYTE bExistFlag;
|
| 491 | BYTE abPadding[3];
|
| 492 | }t_Vcard_DfFcp;
|
| 493 |
|
| 494 | typedef struct
|
| 495 | {
|
| 496 | t_Vcard_DfFcp atDfFcp[Z_UICCMNG_MAX_DF_NUM];
|
| 497 | t_Vcard_EfFcp atEfFcp[UICC_VCARD_MAX_EF_NUM];
|
| 498 | }t_Vcard_Fcp;
|
| 499 |
|
| 500 | typedef struct
|
| 501 | {
|
| 502 | BITS bIsPin1Enabled:1;
|
| 503 | BITS bIsPin1Verified:1;
|
| 504 | BITS bIsPin1Blocked:1;
|
| 505 | BITS bIsCardBroken:1;
|
| 506 | BITS :3;
|
| 507 | }t_Vcard_SecurityStat;
|
| 508 |
|
| 509 | typedef struct
|
| 510 | {
|
| 511 | BYTE bCurrentApp;
|
| 512 | BYTE bAPPStat;
|
| 513 | BYTE abPadding[2];
|
| 514 | BYTE abCurrentAid[Z_APUICC_USAT_MAX_AID_LEN];
|
| 515 | }t_Vcard_AppInfo;
|
| 516 |
|
| 517 | typedef struct
|
| 518 | {
|
| 519 | BITS bIsPowerOn :1;
|
| 520 | BITS bIsPin1Enabled :1;
|
| 521 | BITS bIsPin1Verified :1;
|
| 522 | BITS bIsPin1Blocked :1;
|
| 523 | BITS bIsPuk1Blocked :1;
|
| 524 | BITS bIsPin2Enabled :1;
|
| 525 | BITS bIsPin2Verified :1;
|
| 526 | BITS bIsPin2Blocked :1;
|
| 527 |
|
| 528 | BITS bIsPuk2Blocked :1;
|
| 529 | BITS :7;
|
| 530 | BYTE bCurrentRecNum;
|
| 531 | BYTE bCurSelFileType;
|
| 532 | BYTE bCurrentDf;
|
| 533 | BYTE bPadding;
|
| 534 | WORD wCurrentEf;
|
| 535 | t_Vcard_AppInfo tAppInfo;
|
| 536 | }t_Vcard_CardStatus;
|
| 537 |
|
| 538 | typedef struct
|
| 539 | {
|
| 540 | BYTE bIsPin1Enabled;
|
| 541 | BYTE bIsPin1Blocked;
|
| 542 | BYTE bIsPuk1Blocked;
|
| 543 | BYTE bIsPin2Enabled;
|
| 544 | BYTE bIsPin2Blocked;
|
| 545 | BYTE bIsPuk2Blocked;
|
| 546 | BYTE bPin1RemainNum;
|
| 547 | BYTE bPin2RemainNum;
|
| 548 | BYTE bPuk1RemainNum;
|
| 549 | BYTE bPuk2RemainNum;
|
| 550 | BYTE abPadding[2];
|
| 551 | BYTE abPin1[UICC_VCARD_MAX_PIN_LEN];
|
| 552 | BYTE abPuk1[UICC_VCARD_MAX_PUK_LEN];
|
| 553 | BYTE abPin2[UICC_VCARD_MAX_PIN_LEN];
|
| 554 | BYTE abPuk2[UICC_VCARD_MAX_PUK_LEN];
|
| 555 | }t_Vcard_SecurityInfo;
|
| 556 |
|
| 557 | typedef struct {
|
| 558 | BYTE bEfType; /*ÎļþÊôÐÔ£¬¼Ç¼ÐÍ»ò¶þ½øÖÆ*/
|
| 559 | BYTE bRecNum;
|
| 560 | WORD wDataOffset; /*Êý¾ÝÇøµÄÆ«ÒÆ*/
|
| 561 | BYTE bLen;
|
| 562 | BYTE bMaxEfLen;
|
| 563 | BYTE abPadding[2];
|
| 564 | }t_Vcard_EfFileInfo;
|
| 565 |
|
| 566 | typedef struct {
|
| 567 | BYTE abEncExp[UICC_VCARD_ENC_PUBLIC_EXP_LEN];
|
| 568 | BYTE abEncMod[UICC_VCARD_ENC_PUBLIC_MOD_LEN];
|
| 569 | }t_Vcard_EncPubKey;
|
| 570 |
|
| 571 | typedef struct {
|
| 572 | BYTE abEncK[UICC_VCARD_AUTH_ENCRYPT_K_LEN];
|
| 573 | BYTE abEncOP[UICC_VCARD_AUTH_ENCRYPT_OP_LEN];
|
| 574 | t_Vcard_auth_sqn_ms atSqnMs[UICC_VCARD_SQN_MS_NUM];
|
| 575 | }t_Vcard_AuthInfo;
|
| 576 |
|
| 577 | typedef struct
|
| 578 | {
|
| 579 | t_Vcard_EncPubKey tEncPubKey;
|
| 580 | t_Vcard_AuthInfo tAuthParm;
|
| 581 | t_Vcard_SecurityInfo tSecInfo;
|
| 582 | t_Vcard_Fcp tFcp;
|
| 583 | DWORD dwEfInfoSize;
|
| 584 | BYTE *pbEfInfo;
|
| 585 | }t_Vcard_CardInfo;
|
| 586 |
|
| 587 | typedef enum
|
| 588 | {
|
| 589 | DRV_UICC_TRANSFER_SUCCEEDED,
|
| 590 | DRV_UICC_TRANSFER_FAILED
|
| 591 | } T_ZDrvUicc_ApduReselt;
|
| 592 |
|
| 593 | /**
|
| 594 | * \enum T_ZDrvUicc_ResetResult
|
| 595 | * Response cause for function \ref UICC_reset.
|
| 596 | */
|
| 597 | typedef enum
|
| 598 | {
|
| 599 | DRV_UICC_ACTIVATION_SUCCEEDED,
|
| 600 | DRV_UICC_ACTIVATION_FAILED,
|
| 601 | DRV_UICC_REJECT_CARD
|
| 602 | } T_ZDrvUicc_ResetResult;
|
| 603 |
|
| 604 | /**
|
| 605 | * \enum T_ZDrvUicc_CloseResult
|
| 606 | * Response cause for function \ref UICC_close.
|
| 607 | */
|
| 608 | typedef enum
|
| 609 | {
|
| 610 | DRV_UICC_DEACTIVATION_SUCCEEDED,
|
| 611 | DRV_UICC_DEACTIVATION_FAILED,
|
| 612 | DRV_UICC_ALREADY_DEACTIVATED
|
| 613 | } T_ZDrvUicc_CloseResult;
|
| 614 |
|
| 615 | /**
|
| 616 | * \enum T_ZDrvUicc_SetInOutCallBack
|
| 617 | * Response cause for callback function \ref UICC_set_inout_callback.
|
| 618 | */
|
| 619 | typedef enum
|
| 620 | {
|
| 621 | DRV_CALLBACK_FUNCTION_SET, /*!< Callback function registered. */
|
| 622 | DRV_CALLBACK_NOT_AVAILABLE /*!< Callback function NOT registered (or not supported). */
|
| 623 | } T_ZDrvUicc_SetInOutCallBack;
|
| 624 |
|
| 625 | /**
|
| 626 | * \enum T_ZDrvUicc_CardSelector
|
| 627 | * Card selector.
|
| 628 | */
|
| 629 | typedef enum
|
| 630 | {
|
| 631 | DRV_UICC_PRIMARY_CARD,
|
| 632 | DRV_UICC_SECONDARY_CARD_1,
|
| 633 | DRV_UICC_SECONDARY_CARD_2
|
| 634 | } T_ZDrvUicc_CardSelector;
|
| 635 |
|
| 636 | /**
|
| 637 | * \enum T_ZDrvUicc_CommandCase
|
| 638 | * Command case indicator.
|
| 639 | */
|
| 640 | typedef enum
|
| 641 | {
|
| 642 | DRV_UICC_CMD_CASE_1, /*!< No Tx nor Tx command. */
|
| 643 | DRV_UICC_CMD_CASE_2, /*!< Rx command. */
|
| 644 | DRV_UICC_CMD_CASE_3, /*!< Tx command. */
|
| 645 | DRV_UICC_CMD_CASE_4 /*!< Tx and Rx command. */
|
| 646 | } T_ZDrvUicc_CommandCase;
|
| 647 |
|
| 648 | /**
|
| 649 | * \enum T_ZDrvUicc_ResetMode
|
| 650 | * Reset indicator.
|
| 651 | */
|
| 652 | typedef enum
|
| 653 | {
|
| 654 | DRV_UICC_COLD_RESET, /*!< Cold Reset. */
|
| 655 | DRV_UICC_WARM_RESET /*!< Warm Reset (reset with RST line only). */
|
| 656 | } T_ZDrvUicc_ResetMode;
|
| 657 |
|
| 658 | /**
|
| 659 | * \struct T_ZDrvUicc_ApduHeader
|
| 660 | * Structure holding the APDU command header.
|
| 661 | */
|
| 662 | typedef struct
|
| 663 | {
|
| 664 | UINT8 cla; /*!< Command CLAss. */
|
| 665 | UINT8 ins; /*!< Command INStruction. */
|
| 666 | UINT8 p1; /*!< Command Parameter. */
|
| 667 | UINT8 p2; /*!< Command Parameter. */
|
| 668 | UINT16 lc; /*!< Tx-size. */
|
| 669 | UINT16 le; /*!< Rx-Size. */
|
| 670 | } T_ZDrvUicc_ApduHeader;
|
| 671 |
|
| 672 |
|
| 673 | /**
|
| 674 | * \struct T_ZDrvUicc_ApduFooter
|
| 675 | * Structure holding the APDU command response 'header'.
|
| 676 | */
|
| 677 | typedef struct
|
| 678 | {
|
| 679 | UINT16 luicc; /*!< Actual Rx-size recived. */
|
| 680 | UINT8 sw1; /*!< Received Status Word SW1. */
|
| 681 | UINT8 sw2; /*!< Received Status Word SW2. */
|
| 682 | } T_ZDrvUicc_ApduFooter;
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 | typedef T_ZDrvUicc_ApduReselt (*t_Vcard_ApduHandler)(T_ZDrvUicc_CardSelector card_selector,\
|
| 687 | T_ZDrvUicc_CommandCase command_case,\
|
| 688 | BOOL extended_length,\
|
| 689 | T_ZDrvUicc_ApduHeader c_apdu,\
|
| 690 | T_ZDrvUicc_ApduFooter *r_apdu_ptr,\
|
| 691 | UINT8 *apdu_data_ptr);
|
| 692 |
|
| 693 | typedef struct
|
| 694 | {
|
| 695 | BYTE bApduIns;
|
| 696 | t_Vcard_ApduHandler ptUsimApduHandler;
|
| 697 | t_Vcard_ApduHandler ptSimApduHandler;
|
| 698 | }t_Vcard_ApduCmdMap;
|
| 699 |
|
| 700 | typedef struct
|
| 701 | {
|
| 702 | WORD wFid;
|
| 703 | t_Vcard_EfFileType bEfType;
|
| 704 | BYTE bRecLen;
|
| 705 | BYTE bRecNum;
|
| 706 | t_Vcard_AccRule tReadRule;
|
| 707 | t_Vcard_AccRule tUpdateRule;
|
| 708 | t_Vcard_AccRule tIncreaseRule;
|
| 709 | }T_zVcard_FileInfo;
|
| 710 |
|
| 711 | typedef struct
|
| 712 | {
|
| 713 | WORD wFid;
|
| 714 | t_Vcard_EfFileType bEfType;
|
| 715 | t_Vcard_AccRule tReadRule;
|
| 716 | t_Vcard_AccRule tUpdateRule;
|
| 717 | t_Vcard_AccRule tIncreaseRule;
|
| 718 | t_Vcard_EFAppType tAppType;
|
| 719 | BYTE bUsimParentDf;
|
| 720 | BYTE bSimParentDf;
|
| 721 | BYTE abPadding[3];
|
| 722 | }T_zVcard_EfAttribute;
|
| 723 |
|
| 724 | UINT32 zVcard_ReadNv(UINT32 NvItemID, VOID *NvItemData, UINT32 NvItemLen);
|
| 725 |
|
| 726 | UINT32 zVcard_WriteNv(UINT32 NvItemID, VOID *NvItemData, UINT32 NvItemLen);
|
| 727 |
|
| 728 | BOOL zVcard_WriteEfNV(UINT16 efid, UINT16 indx, VOID *data, UINT16 dataLen);
|
| 729 |
|
| 730 | T_ZDrvUicc_ResetResult zVcard_ResetCard(T_ZDrvUicc_CardSelector tCardNum);
|
| 731 |
|
| 732 | T_ZDrvUicc_CloseResult zVcard_CloseCard(T_ZDrvUicc_CardSelector tCardNum);
|
| 733 |
|
| 734 | UINT8 zVcard_GetAtr(T_ZDrvUicc_CardSelector bSlotNum, UINT8 *atr);
|
| 735 |
|
| 736 | T_ZDrvUicc_ApduReselt zVcard_TransportApdu(T_ZDrvUicc_CardSelector card_selector,
|
| 737 | T_ZDrvUicc_CommandCase command_case,
|
| 738 | BOOL extended_length,
|
| 739 | T_ZDrvUicc_ApduHeader c_apdu,
|
| 740 | T_ZDrvUicc_ApduFooter *r_apdu_ptr,
|
| 741 | UINT8 *apdu_data_ptr);
|
| 742 |
|
| 743 | BYTE zVcard_Init(VOID);
|
| 744 |
|
| 745 | void v_sim_f1 ( u8 k[16], u8 rand[16], u8 sqn[6], u8 amf[2],
|
| 746 | u8 mac_a[8] );
|
| 747 | void v_sim_f2345 ( u8 k[16], u8 rand[16],
|
| 748 | u8 res[8], u8 ck[16], u8 ik[16], u8 ak[6] );
|
| 749 | void v_sim_f1star( u8 k[16], u8 rand[16], u8 sqn[6], u8 amf[2],
|
| 750 | u8 mac_s[8] );
|
| 751 | void v_sim_f5star( u8 k[16], u8 rand[16],
|
| 752 | u8 ak[6] );
|
| 753 | void v_sim_ComputeOPc( u8 op_c[16] );
|
| 754 | void v_sim_RijndaelKeySchedule( u8 key[16] );
|
| 755 | void v_sim_RijndaelEncrypt( u8 input[16], u8 output[16] );
|
| 756 | void A3A8(/* in */ Byte rand[16], /* in */ Byte key[16],/* out */ Byte simoutput[12]);
|
| 757 |
|
| 758 |
|
| 759 | #ifndef PROTOTYPES
|
| 760 | #define PROTOTYPES 1
|
| 761 | #endif
|
| 762 |
|
| 763 | typedef unsigned char *POINTER;
|
| 764 | typedef unsigned short int UINT2;
|
| 765 | typedef unsigned long int UINT4;
|
| 766 | typedef signed long int signeddigit;
|
| 767 |
|
| 768 |
|
| 769 | typedef UINT4 VSIM_DIGIT;
|
| 770 | typedef UINT2 VSIM_HALF_DIGIT;
|
| 771 |
|
| 772 | #ifndef NULL_PTR
|
| 773 | #define NULL_PTR ((POINTER)0)
|
| 774 | #endif
|
| 775 |
|
| 776 | #ifndef UNUSED_ARG
|
| 777 | #define UNUSED_ARG(x) x = *(&x);
|
| 778 | #endif
|
| 779 |
|
| 780 |
|
| 781 | #if PROTOTYPES
|
| 782 | #define PROTO_LIST(list) list
|
| 783 | #else
|
| 784 | #define PROTO_LIST(list) ()
|
| 785 | #endif
|
| 786 |
|
| 787 | #define ID_OK 0
|
| 788 | #define ID_ERROR 1
|
| 789 |
|
| 790 | #define RE_DATA 0x0401
|
| 791 | #define RE_LEN 0x0406
|
| 792 |
|
| 793 | #define MAX_RSA_MODULUS_BITS 1024
|
| 794 | #define VSIM_MAX_RSA_MODULUS_LEN ((MAX_RSA_MODULUS_BITS + 7) / 8)
|
| 795 | #define MAX_RSA_PRIME_BITS ((MAX_RSA_MODULUS_BITS + 1) / 2)
|
| 796 | #define MAX_RSA_PRIME_LEN ((MAX_RSA_PRIME_BITS + 7) / 8)
|
| 797 |
|
| 798 |
|
| 799 | typedef struct {
|
| 800 | unsigned short int bits; /* length in bits of modulus */
|
| 801 | unsigned char modulus[VSIM_MAX_RSA_MODULUS_LEN]; /* modulus */
|
| 802 | //unsigned char publicExponent[VSIM_MAX_RSA_MODULUS_LEN]; /* public exponent */
|
| 803 | //unsigned char exponent[VSIM_MAX_RSA_MODULUS_LEN]; /* private exponent */
|
| 804 | unsigned char prime[2][MAX_RSA_PRIME_LEN]; /* prime factors */
|
| 805 | unsigned char primeExponent[2][MAX_RSA_PRIME_LEN]; /* exponents for CRT */
|
| 806 | unsigned char coefficient[MAX_RSA_PRIME_LEN]; /* CRT coefficient */
|
| 807 | } R_RSA_PRIVATE_KEY;
|
| 808 |
|
| 809 | typedef struct {
|
| 810 | unsigned short int bits; /* length in bits of modulus */
|
| 811 | BYTE modulus[VSIM_MAX_RSA_MODULUS_LEN]; /* modulus */
|
| 812 | BYTE exponent[VSIM_MAX_RSA_MODULUS_LEN]; /* public exponent */
|
| 813 | } R_RSA_PUBLIC_KEY;
|
| 814 |
|
| 815 |
|
| 816 | void VSIM_Decode(VSIM_DIGIT *, unsigned int, unsigned char *, unsigned int);
|
| 817 | void VSIM_Encode(unsigned char *, unsigned int, VSIM_DIGIT *, unsigned int);
|
| 818 |
|
| 819 | void VSIM_Assign (VSIM_DIGIT *, VSIM_DIGIT *, unsigned int);
|
| 820 | void VSIM_AssignZero (VSIM_DIGIT *, unsigned int);
|
| 821 | void VSIM_Assign2Exp (VSIM_DIGIT *, unsigned int, unsigned int);
|
| 822 |
|
| 823 | VSIM_DIGIT VSIM_Add (VSIM_DIGIT *, VSIM_DIGIT *, VSIM_DIGIT *, unsigned int);
|
| 824 | VSIM_DIGIT VSIM_Sub(VSIM_DIGIT *, VSIM_DIGIT *, VSIM_DIGIT *, unsigned int);
|
| 825 | void VSIM_Mult (VSIM_DIGIT *, VSIM_DIGIT *, VSIM_DIGIT *, unsigned int);
|
| 826 | void VSIM_Div(VSIM_DIGIT *, VSIM_DIGIT *, VSIM_DIGIT *, unsigned int, VSIM_DIGIT *,unsigned int);
|
| 827 | VSIM_DIGIT VSIM_LShift(VSIM_DIGIT *, VSIM_DIGIT *, unsigned int, unsigned int);
|
| 828 | VSIM_DIGIT VSIM_RShift (VSIM_DIGIT *, VSIM_DIGIT *, unsigned int, unsigned int);
|
| 829 |
|
| 830 | void VSIM_Mod(VSIM_DIGIT *, VSIM_DIGIT *, unsigned int, VSIM_DIGIT *, unsigned int);
|
| 831 | void VSIM_ModMult(VSIM_DIGIT *, VSIM_DIGIT *, VSIM_DIGIT *, VSIM_DIGIT *, unsigned int);
|
| 832 | void VSIM_ModExp (VSIM_DIGIT *, VSIM_DIGIT *, VSIM_DIGIT *, unsigned int, VSIM_DIGIT *,unsigned int);
|
| 833 |
|
| 834 | int VSIM_Cmp (VSIM_DIGIT *, VSIM_DIGIT *, unsigned int);
|
| 835 | unsigned int VSIM_Digits (VSIM_DIGIT *, unsigned int);
|
| 836 |
|
| 837 | #define VSIM_ASSIGN_DIGIT(a, b, digits) {VSIM_AssignZero (a, digits); a[0] = b;}
|
| 838 |
|
| 839 |
|
| 840 | int RSAPublicDecrypt(unsigned char *output, /* output block */
|
| 841 | unsigned int *outputLen, /* length of output block */
|
| 842 | unsigned char *input, /* input block */
|
| 843 | unsigned int inputLen, /* length of input block */
|
| 844 | R_RSA_PUBLIC_KEY *publicKey /* RSA public key */);
|
| 845 |
|
| 846 | extern SINT32 zAmt_GetPublicKey(BYTE *pE, UINT32 *pELen, BYTE *pN, UINT32 *pModulusLen);
|
| 847 |
|
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 848 | /**************************************************************************
|
| 849 | * º¯ÊýÃû³Æ: zVcard_CmpOpK
|
| 850 | * ¹¦ÄÜÃèÊö: ÑéÖ¤KºÍOPÊÇ·ñÒ»ÖÂ
|
| 851 | * ²ÎÊý˵Ã÷: (IN) pbK 16 byte ´ýУÑéxmlÖеÄabKÖµ
|
| 852 | pbOp 16 byte ´ýУÑéxmlÖеÄabOpcÖµ
|
| 853 | pbEncExp 128 byte vsim.binÖеÚ0x8-0x87×Ö½ÚÄÚÈÝ£¬Æ«ÒÆÁ¿´Ó0¿ªÊ¼
|
| 854 | pbEncMod 128 byte vsim.binÖеÚ0x88-0x107×Ö½ÚÄÚÈÝ
|
| 855 | pbEncK 128 byte vsim.binÖеÚ0x108-0x187×Ö½ÚÄÚÈÝ
|
| 856 | pbEncOP 128 byte vsim.binÖеÚ0x188-0x207×Ö½ÚÄÚÈÝ
|
| 857 | * ·µ »Ø Öµ: 0 УÑéͨ¹ý
|
| 858 | 1 УÑéʧ°Ü
|
| 859 | * ÆäËü˵Ã÷: ½ö¹©²úÏßУÑéʱʹÓÃ
|
| 860 | **************************************************************************/
|
| 861 | BYTE zVcard_CmpOpK(BYTE *pbK, BYTE *pbOp, BYTE *pbEncExp, BYTE *pbEncMod, BYTE *pbEncK, BYTE *pbEncOP);
|
| 862 |
|
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 863 | #endif
|
| 864 |
|