yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 1 | #ifndef __LPA_INNER_H__
|
| 2 | #define __LPA_INNER_H__
|
| 3 |
|
| 4 | #include <openssl/ssl.h>
|
| 5 | #include <openssl/bio.h>
|
| 6 |
|
| 7 | #include "lpa_api.h"
|
| 8 |
|
| 9 | #include "cjson.h"
|
| 10 | #include "md5.h"
|
| 11 | #include "errno.h"
|
| 12 |
|
| 13 | #define MAX_IMEI_LEN 17
|
| 14 | #define MAX_TRANSID_LEN 41
|
| 15 |
|
| 16 | #define CSIM_REQ_LEN 600
|
| 17 | #define CSIM_RESP_LEN 600
|
| 18 | #define APDU_REQ_LEN 520 //tag10+255*2+00
|
| 19 | #define APDU_RESP_LEN 520 //0xFF*2+sw1+sw2=514
|
| 20 | #define APDU_BYTE_LEN 261 //csimÐÒéÕ»·µ»Ø×î´ó³¤¶È255 APDU_RESP_LEN/2+1
|
| 21 | #define MIN_APDU_LEN 16 //80E2910004TG01XX
|
| 22 |
|
| 23 | #define SMDP_HTTP_MAX_LEN 0x20000 //128K
|
| 24 | #define TRIG_HTTP_MAX_LEN 0x2000 //8K
|
| 25 | #define HTTP_CHUNKED_FLAG 0x7FFFFFFF
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 | #define ICCID_LEN 20
|
| 31 |
|
| 32 | //#define CSIM_APDU_LEN 511 //csimÐÒéÕ»·µ»Ø×î´ó³¤¶È255
|
| 33 |
|
| 34 | #ifndef BOOL
|
| 35 | #define BOOL unsigned char
|
| 36 | #endif
|
| 37 | #ifndef TRUE
|
| 38 | #define TRUE 1
|
| 39 | #endif
|
| 40 | #ifndef FALSE
|
| 41 | #define FALSE 0
|
| 42 | #endif
|
| 43 |
|
| 44 |
|
| 45 | typedef struct
|
| 46 | {
|
| 47 | int sock_fd;
|
| 48 | SSL_CTX *ssl_ct;
|
| 49 | SSL *ssl;
|
| 50 |
|
| 51 | //url ½âÎö³öÀ´µÄÐÅÏ¢
|
| 52 | char *host;
|
| 53 | char *path;
|
| 54 | int port;
|
| 55 | } https_context_t;
|
| 56 |
|
| 57 | //https
|
| 58 | int https_init(https_context_t *context);
|
| 59 | int https_uninit(https_context_t *context);
|
| 60 | int https_read(https_context_t *context,void* buff,int len);
|
| 61 | int https_write(https_context_t *context,const void* buff,int len);
|
| 62 | int https_get_status_code(https_context_t *context, int *content_len);
|
| 63 | int https_read_content(https_context_t *context,char *resp_contet,int max_len);
|
| 64 |
|
| 65 | //es10b
|
| 66 | char *GetEUICCChallenge(void);
|
| 67 | char *GetEUICCInfo(BOOL flag);
|
| 68 | char *AuthenticateServer(char *signd1Hex, char *signature1Hex, char *ciPKIdHex, char *certificateHex, char *matchingId, char *imeiHex);
|
| 69 | char *PrepareDownload(char *transId ,char *signed2Hex,char *signature2Hex,char *certiHex,char *confirmCode);
|
| 70 | char *LoadBoundProfilePackage(char * bppHex);
|
| 71 |
|
| 72 |
|
| 73 | //es10c
|
| 74 | char *EnableProfile(char *iccidHex);
|
| 75 | char *EUICCMemoryReset(void);
|
| 76 | char *GetProfilesInfo(char *iccidHex);
|
| 77 | char *DisableProfile(char *iccidHex);
|
| 78 | char *DeleteProfile (char *iccidHex);
|
| 79 | char *GetEID(void);
|
| 80 |
|
| 81 | //es9+
|
| 82 | char *InitiateAuthentication(char *euiccChallenge, char *euiccInfo1, char *smdpAddress);
|
| 83 | char *AuthenticateClient(char *transactionId,char *authSerRespHex);
|
| 84 | char *GetBoundProfilePackage (char *transactionId, char *predlRespHex);
|
| 85 | char *HandleNotification(char *pnfHex);
|
| 86 |
|
| 87 | //channel
|
| 88 | char *OpenLogicalChannel(void);
|
| 89 | int CloseLogicalChannel(int chan_id);
|
| 90 |
|
| 91 |
|
| 92 | //edcode
|
| 93 | char *lpa_tlv_get_val_by_tag(unsigned char *apdu_byte, int apdu_len, unsigned int tag);
|
| 94 | char *lpa_tag_apdu_from_atresp(char *atres_apdu, unsigned int tag);
|
| 95 | char *lpa_get_apdu_from_atresp(char *atres_apdu);
|
| 96 | int lpa_csim_resp_code(char *atres_apdu, int *second_len);
|
| 97 | int lpa_csim_resp_normal(char *atres_apdu);
|
| 98 |
|
| 99 | int string2bytes(const char* pSrc, unsigned char* pDst, int nSrcLength);
|
| 100 | int bytes2string(const unsigned char* pSrc, char* pDst, int nSrcLength);
|
| 101 |
|
| 102 | char *lpa_base64_encode(const char*data, int data_len);
|
| 103 | unsigned char *lpa_base64_decode(const unsigned char *src, int len, int *out_len);
|
| 104 |
|
| 105 | void lpa_trans_iccid(char *iccid, int len);
|
| 106 |
|
| 107 | #endif
|