comparison src/aci2/aci/aci_slock.h @ 3:93999a60b835

src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Sep 2016 00:29:36 +0000
parents
children
comparison
equal deleted inserted replaced
2:c41a534f33c6 3:93999a60b835
1 /*
2 +-----------------------------------------------------------------------------
3 | Project :
4 | Modul : J:\g23m-aci\aci\aci_slock.h
5 +-----------------------------------------------------------------------------
6 | Copyright 2002 Texas Instruments Berlin, AG
7 | All rights reserved.
8 |
9 | This file is confidential and a trade secret of Texas
10 | Instruments Berlin, AG
11 | The receipt of or possession of this file does not convey
12 | any rights to reproduce or disclose its contents or to
13 | manufacture, use, or sell anything it may describe, in
14 | whole, or in part, without the specific written consent of
15 | Texas Instruments Berlin, AG.
16 +-----------------------------------------------------------------------------
17 | Purpose :
18 +-----------------------------------------------------------------------------
19 */
20
21 #ifndef ACI_SLOCK_H
22 #define ACI_SLOCK_H
23
24 #ifdef SIM_PERS
25 /* Shared globals ------------------------------------------------ */
26
27 typedef struct{
28 T_SIMLOCK_STATUS status[SIMLOCK_FIRST_SIM+1]; /* lint */ /* one status for every personalisation lock type */
29 UINT16 dependency[SIMLOCK_FIRST_SIM+1];
30 UBYTE blocked; /* blocked flag */
31 T_SIMLOCK_TYPE current_lock; /* currently checked lock */
32 UBYTE pb_load ;
33 T_SIMLOCK_CHECK check_lock;
34 T_SIMLOCK_TYPE lock_type;
35 CHAR * lock_passwd;
36 }T_ACI_SLOCK_SHARED;
37
38
39 EXTERN T_ACI_SLOCK_SHARED AciSLockShrd;
40 EXTERN UBYTE sim_code_present_in_me;
41 #endif
42
43 #define NOT_PRESENT_8BIT 0xFF
44 #define MAX_GID 5
45 #define MAX_AD 0
46 #define CHECK_FAIL 2
47
48 #ifdef SIM_PERS
49 /*Max number of user codes for each category- To be defined*/
50 #define MAX_NW_USER_CODES 20
51 #define MAX_NS_USER_CODES 10
52 #define MAX_SP_USER_CODES 10
53 #define MAX_CP_USER_CODES 10
54 #define MAX_SIM_USER_CODES 10
55 /*Normal code length for each category*/
56 #define NW_USER_CODE_LEN 3
57 #define NS_USER_CODE_LEN 4
58 #define SP_USER_CODE_LEN 7
59 #define CP_USER_CODE_LEN 11
60 #define SIM_USER_CODE_LEN 8
61
62 #define MAX_NUM_USERCODE_SIZE 1
63 #define NUM_OPCODE_SIZE 1
64 #define NUM_USER_CODE_SIZE 1
65 #define CURR_USER_CODE_INDEX_SIZE 1
66 #define OPCODE_LEN_SIZE 1 // can be 2
67 #define OPCODE_LEN_INDEX 2
68 #define CODE_TYPE_SIZE 1
69
70 #define FC_MAX_INFINITE 0xff //04-08-2005
71
72
73 /*
74 * BCD length
75 */
76 #define NW_CODE_LEN 4 // Parity +MNC + MCC may require 4 bytes in packed bcd format if MNC length is 3
77 #define NS_CODE_LEN 1 // NS requires 1 byte in packed bcd format
78 #define NW_NS_CODE_LEN 5
79 #define NW_NS_MSIN_CODE_LEN 8
80 #define NW_NS_MSIN_MSIN_CODE_LEN 13
81 #define NW_NS_NS_CODE_LEN 6
82 #define NW_DIGIT_MAP_TABLE_LEN 24 // Network code (4) + digit mapping table (10 * 2)
83
84
85 #define NORMAL_CODE 0x0a
86 #define INTERVAL_TYPE1 0x0b // Range
87 #define INTERVAL_TYPE2 0x0d // digit interval
88 #define REGULAR_EXP 0x0c // Regular expession
89
90 #define GID1_LEN 4 // GID1 is not stored in BCD format
91 #define GID2_LEN 4 // GID2 is not stored in BCD format
92 #define GID_LEN_TO_BE_COMPARED 1 //depends on what the length is in the sim
93
94 enum
95 {
96 ALWAYS_ACCEPTED=0x00,
97 ALWAYS_REJECTED= 0x01,
98 UNTIL_NORMAL_SIM=0x02
99 } ;
100
101 typedef enum
102 {
103 SIM_NORMAL =0,
104 SIM_TYPEAPPROVAL,
105 SIM_TEST
106 }T_SIM_TYPE ;
107
108 #endif
109
110 /* SIM configuration information */
111 typedef struct
112 {
113 UBYTE deper_key [16];
114 UBYTE phase;
115 UBYTE oper_mode; /* SIM card functionality */
116 UBYTE pref_lang[5];
117 UBYTE access_acm;
118 UBYTE access_acmmax;
119 UBYTE access_puct;
120 UBYTE sim_gidl1[MAX_GID];
121 UBYTE sim_gidl2[MAX_GID];
122 #ifdef SIM_PERS
123 T_SIM_TYPE sim_type; /* */
124 UBYTE sim_read_gid1; /* added for SP, CP */
125 UBYTE sim_read_gid2; /* added for SP, CP */
126 UBYTE gid1_len;
127 UBYTE gid2_len;
128 UBYTE sim_read_ad_first_byte;
129 #endif
130
131 } T_ACI_SIM_CONFIG; // This is the same as T_MFW_SIM_CONFIG
132
133
134 /* Prototypes ----------------------------------------------------*/
135
136
137
138
139 #ifdef SIM_PERS
140 /*
141 Initialising of this module. Has to be called first and *once only* before calling any other method.
142 */
143 void aci_slock_init ( void );
144
145 /*
146 Reset the aci_slock variables
147 */
148 void aci_slock_reset();
149
150
151 /*
152 Unlocks the lock of the given type after verifying the given password.
153 The ACI extension for password verifying (see 2.3.9.1) will be used to
154 determine if the given password is correct or not.
155 On a successful unlock the actual status of the lock will be returned.
156 If an error occurred SIMLOCK_FAIL will be returned.
157 (Uses the ACI extension "personalisation data access".)
158 */
159 T_SIMLOCK_STATUS aci_slock_authenticate ( T_SIMLOCK_TYPE type, char *passwd );
160
161
162 /*
163 ACI method for retrieving the status of a single personalisation type. This method calls extension
164 methods which in turn calls Security Drv. API and retrn the status of a personalisation category.
165 The personalisation status is stored in MEPD which is directly accessed by Security Drv.
166 Added on 11/03/2005
167 */
168
169 T_SIMLOCK_STATUS aci_personalisation_get_status ( T_SIMLOCK_TYPE personalisation_type );
170 #endif
171 #ifdef SIM_PERS
172
173
174 /*
175 Locks the lock of the given type. On a successful lock the actual
176 status of the lock will be returned. If an error occurred SIMLOCK_FAIL
177 will be returned. This method will use the ACI extension for password
178 verifying (see 2.3.9.1) to determine if the given password is correct
179 or not. (Uses the ACI extension "personalisation data access".)
180 */
181 T_SIMLOCK_STATUS aci_slock_lock ( T_SIMLOCK_TYPE type, char *passwd );
182
183 /*
184 For Failure Counter reset. Use extension methods
185 added on 11/03/2005
186 */
187 T_OPER_RET_STATUS aci_slock_reset_fc ( char *fcKey );
188
189 /*--------------------------------------
190 For Supplementary Info( e.g. FC MAX, MC Current value).
191 Uses extension method aci_slock_sup_info
192 added on 11/03/2005
193 ----------------------------------------*/
194 T_OPER_RET_STATUS aci_slock_sup_info(T_SUP_INFO *sup_info);
195
196
197 /* change the password */
198 T_SIMLOCK_STATUS aci_slock_change_password ( T_SIMLOCK_TYPE type, char *passwd, char *new_passwd );
199
200
201
202 #endif
203 /*
204 Unlocks the lock of the given type after verifying the given password.
205 The ACI extension for password verifying (see 2.3.9.1) will be used to
206 determine if the given password is correct or not.
207 On a successful unlock the actual status of the lock will be returned.
208 If an error occurred SIMLOCK_FAIL will be returned.
209 (Uses the ACI extension "personalisation data access".)
210 */
211 T_SIMLOCK_STATUS aci_slock_unlock ( T_SIMLOCK_TYPE type, char *passwd );
212 /*
213 Checks for all kinds of personalisation locks. The given IMSI will be checked against the internal
214 personalisation data. Returns SIMLOCK_BLOCKED, if one lock was not matching the given IMSI.
215 */
216 T_SIMLOCK_STATUS aci_slock_checkpersonalisation( T_SIMLOCK_TYPE current_lock );
217
218
219 /*
220 PURPOSE : Install information found in the primitive into configuration buffers.
221 */
222 void aci_slock_sim_init ( T_SIM_MMI_INSERT_IND *sim_mmi_insert_ind );
223
224
225 /*
226 PURPOSE : read SIM group identifier 1 from SIM card
227
228 */
229 void aci_slock_sim_gid1_cnf(USHORT error, UBYTE *data);
230
231 /*
232 PURPOSE : read SIM group identifier 2 from SIM card
233
234 */
235 void aci_slock_sim_gid2_cnf(USHORT error, UBYTE *data);
236
237
238
239 /*
240 PURPOSE : Call back for SIM read.
241
242 */
243 void aci_slock_sim_read_sim_cb(SHORT table_id);
244
245 /*
246 PURPOSE : Request to read SIM card.
247
248 */
249 void aci_slock_sim_read_sim(USHORT data_id, UBYTE len, UBYTE max_length);
250
251 #ifdef SIM_PERS
252 /*
253
254 PURPOSE : Setting the sim_type value (Normal, Test SIM, Type Approval SIM)
255
256 */
257
258 void aci_slock_set_simtype(T_SIM_TYPE sim_type );
259
260 /*
261 PURPOSE : To set global variable for configuration data ( part1 of Security Driver)
262 */
263 void aci_slock_set_CFG(void);
264
265
266 void aci_slock_check_NWlock( UBYTE* imsi_sim, UBYTE personalisation );
267
268 void aci_slock_check_NSlock( UBYTE* imsi_sim, UBYTE personalisation );
269
270 void aci_slock_check_SPlock( UBYTE* imsi_sim, UBYTE personalisation );
271 void aci_slock_check_CPlock( UBYTE* imsi_sim, UBYTE personalisation);
272
273 void aci_slock_check_SMlock( UBYTE* imsi_sim, UBYTE personalisation);
274
275 GLOBAL void aci_slock_psaSIM_decodeIMSI (UBYTE* imsi_field, UBYTE imsi_c_field, CHAR* imsi_asciiz);
276
277 GLOBAL void aci_slock_psaSIM_decodeIMSI_without_parity(UBYTE* imsi_field, UBYTE imsi_c_field, CHAR* imsi_asciiz);
278
279 GLOBAL void aci_set_cme_error(T_SIMLOCK_TYPE slocktype);
280 GLOBAL void aci_set_cme_error_code(T_SIMLOCK_TYPE current_lock , T_ACI_CME_ERR *err_code);
281
282 #endif //SIM_PERS
283 #endif /* ACI_SLOCK_H */