blob: d77bd68434fd272c8ce3730cf1ce7ba3e3890c3c [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#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
45typedef 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
58int https_init(https_context_t *context);
59int https_uninit(https_context_t *context);
60int https_read(https_context_t *context,void* buff,int len);
61int https_write(https_context_t *context,const void* buff,int len);
62int https_get_status_code(https_context_t *context, int *content_len);
63int https_read_content(https_context_t *context,char *resp_contet,int max_len);
64
65//es10b
66char *GetEUICCChallenge(void);
67char *GetEUICCInfo(BOOL flag);
68char *AuthenticateServer(char *signd1Hex, char *signature1Hex, char *ciPKIdHex, char *certificateHex, char *matchingId, char *imeiHex);
69char *PrepareDownload(char *transId ,char *signed2Hex,char *signature2Hex,char *certiHex,char *confirmCode);
70char *LoadBoundProfilePackage(char * bppHex);
71
72
73//es10c
74char *EnableProfile(char *iccidHex);
75char *EUICCMemoryReset(void);
76char *GetProfilesInfo(char *iccidHex);
77char *DisableProfile(char *iccidHex);
78char *DeleteProfile (char *iccidHex);
79char *GetEID(void);
80
81//es9+
82char *InitiateAuthentication(char *euiccChallenge, char *euiccInfo1, char *smdpAddress);
83char *AuthenticateClient(char *transactionId,char *authSerRespHex);
84char *GetBoundProfilePackage (char *transactionId, char *predlRespHex);
85char *HandleNotification(char *pnfHex);
86
87//channel
88char *OpenLogicalChannel(void);
89int CloseLogicalChannel(int chan_id);
90
91
92//edcode
93char *lpa_tlv_get_val_by_tag(unsigned char *apdu_byte, int apdu_len, unsigned int tag);
94char *lpa_tag_apdu_from_atresp(char *atres_apdu, unsigned int tag);
95char *lpa_get_apdu_from_atresp(char *atres_apdu);
96int lpa_csim_resp_code(char *atres_apdu, int *second_len);
97int lpa_csim_resp_normal(char *atres_apdu);
98
99int string2bytes(const char* pSrc, unsigned char* pDst, int nSrcLength);
100int bytes2string(const unsigned char* pSrc, char* pDst, int nSrcLength);
101
102char *lpa_base64_encode(const char*data, int data_len);
103unsigned char *lpa_base64_decode(const unsigned char *src, int len, int *out_len);
104
105void lpa_trans_iccid(char *iccid, int len);
106
107#endif