diff options
Diffstat (limited to 'include/sec.h')
-rw-r--r-- | include/sec.h | 141 |
1 files changed, 62 insertions, 79 deletions
diff --git a/include/sec.h b/include/sec.h index 74e1ff8..692e7ad 100644 --- a/include/sec.h +++ b/include/sec.h @@ -41,7 +41,6 @@ * Values */ -/* SIM status */ #define IPC_SEC_SIM_STATUS_READY 0x00 #define IPC_SEC_SIM_STATUS_SIM_LOCK_REQUIRED 0x01 #define IPC_SEC_SIM_STATUS_INSIDE_PF_ERROR 0x02 @@ -56,141 +55,125 @@ #define IPC_SEC_SIM_STATUS_INIT_COMPLETE 0x82 #define IPC_SEC_SIM_STATUS_PB_INIT_COMPLETE 0x83 -/* SIM/Network facility types */ -#define IPC_SEC_FACILITY_TYPE_SC 0x03 -#define IPC_SEC_FACILITY_TYPE_FD 0x04 -#define IPC_SEC_FACILITY_TYPE_PN 0x05 -#define IPC_SEC_FACILITY_TYPE_PU 0x06 -#define IPC_SEC_FACILITY_TYPE_PP 0x07 -#define IPC_SEC_FACILITY_TYPE_PC 0x08 - -/* SIM card (SC) facility lock types */ #define IPC_SEC_FACILITY_LOCK_TYPE_SC_UNLOCKED 0x00 #define IPC_SEC_FACILITY_LOCK_TYPE_SC_PIN1_REQ 0x01 #define IPC_SEC_FACILITY_LOCK_TYPE_SC_PUK_REQ 0x02 #define IPC_SEC_FACILITY_LOCK_TYPE_SC_CARD_BLOCKED 0x05 -/* PIN type */ #define IPC_SEC_PIN_TYPE_PIN1 0x03 #define IPC_SEC_PIN_TYPE_PIN2 0x09 -/* Type of the used SIM card */ -#define IPC_SEC_SIM_CARD_TYPE_UNKNOWN 0x00 -#define IPC_SEC_SIM_CARD_TYPE_SIM 0x01 -#define IPC_SEC_SIM_CARD_TYPE_USIM 0x02 +#define IPC_SEC_FACILITY_TYPE_SC 0x03 +#define IPC_SEC_FACILITY_TYPE_FD 0x04 +#define IPC_SEC_FACILITY_TYPE_PN 0x05 +#define IPC_SEC_FACILITY_TYPE_PU 0x06 +#define IPC_SEC_FACILITY_TYPE_PP 0x07 +#define IPC_SEC_FACILITY_TYPE_PC 0x08 -/* Possible RSIM commads (see TS 27.00.1 8.18) */ -#define IPC_SEC_RSIM_COMMAND_READ_BINARY 0xb0 -#define IPC_SEC_RSIM_COMMAND_READ_RECORD 0xb2 -#define IPC_SEC_RSIM_COMMAND_GET_RESPONSE 0xc0 -#define IPC_SEC_RSIM_COMMAND_UPDATE_BINARY 0xd6 -#define IPC_SEC_RSIM_COMMAND_UPDATE_RECORD 0xdc -#define IPC_SEC_RSIM_COMMAND_STATUS 0xf2 -#define IPC_SEC_RSIM_COMMAND_RETRIEVE_DATA 0xcb -#define IPC_SEC_RSIM_COMMAND_SET_DATA 0xdb +#define IPC_SEC_RSIM_COMMAND_READ_BINARY 0xB0 +#define IPC_SEC_RSIM_COMMAND_READ_RECORD 0xB2 +#define IPC_SEC_RSIM_COMMAND_GET_RESPONSE 0xC0 +#define IPC_SEC_RSIM_COMMAND_UPDATE_BINARY 0xD6 +#define IPC_SEC_RSIM_COMMAND_UPDATE_RECORD 0xDC +#define IPC_SEC_RSIM_COMMAND_STATUS 0xF2 +#define IPC_SEC_RSIM_COMMAND_RETRIEVE_DATA 0xCB +#define IPC_SEC_RSIM_COMMAND_SET_DATA 0xDB #define IPC_SEC_RSIM_FILE_STRUCTURE_TRANSPARENT 0x83 #define IPC_SEC_RSIM_FILE_STRUCTURE_LINEAR_FIXED 0x00 +#define IPC_SEC_SIM_CARD_TYPE_UNKNOWN 0x00 +#define IPC_SEC_SIM_CARD_TYPE_SIM 0x01 +#define IPC_SEC_SIM_CARD_TYPE_USIM 0x02 + /* * Structures */ -struct ipc_sec_sim_status_response { - /* IPC_SEC_SIM_STATUS_... */ - unsigned char status; - /* IPC_SEC_FACILITY_LOCK_TYPE_... */ - unsigned char facility_lock; +struct ipc_sec_sim_status_response_data { + unsigned char status; // IPC_SEC_SIM_STATUS + unsigned char facility_lock; // IPC_SEC_FACILITY_LOCK_TYPE } __attribute__((__packed__)); -struct ipc_sec_pin_status_set { - /* IPC_SEC_SIM_STATUS_... */ - unsigned char type; - unsigned char length1; - unsigned char length2; +struct ipc_sec_sim_status_request_data { + unsigned char type; // IPC_SEC_PIN_TYPE + unsigned char pin1_length; + unsigned char pin2_length; unsigned char pin1[8]; unsigned char pin2[8]; } __attribute__((__packed__)); -struct ipc_sec_phone_lock_set { - /* IPC_SEC_SIM_STATUS_... */ - unsigned char type; - unsigned char lock; /* 1: lock, 0: unlock */ - unsigned char length; +struct ipc_sec_phone_lock_request_set_data { + unsigned char facility_type; // IPC_SEC_FACILITY_TYPE + unsigned char active; + unsigned char password_length; unsigned char password[39]; } __attribute__((__packed__)); -struct ipc_sec_phone_lock_get { - /* IPC_SEC_FACILITY_TYPE_... */ - unsigned char facility; +struct ipc_sec_phone_lock_request_get_data { + unsigned char facility_type; // IPC_SEC_FACILITY_TYPE } __attribute__((__packed__)); -struct ipc_sec_phone_lock_response { - /* IPC_SEC_FACILITY_TYPE_... */ - unsigned char facility; - unsigned char status; /* 1: active, 0: not active */ +struct ipc_sec_phone_lock_response_data { + unsigned char facility_type; // IPC_SEC_FACILITY_TYPE + unsigned char active; } __attribute__((__packed__)); -struct ipc_sec_change_locking_pw_set { - /* IPC_SEC_FACILITY_TYPE_... */ - unsigned char facility; - unsigned char length_old; - unsigned char length_new; +struct ipc_sec_change_locking_pw_data { + unsigned char facility_type; // IPC_SEC_FACILITY_TYPE + unsigned char password_old_length; + unsigned char password_new_length; unsigned char password_old[39]; unsigned char password_new[39]; } __attribute__((__packed__)); -struct ipc_sec_rsim_access_get { - /* IPC_SEC_RSIM_COMMAND_... */ - unsigned char command; - unsigned short fileid; +struct ipc_sec_rsim_access_request_data { + unsigned char command; // IPC_SEC_RSIM_COMMAND + unsigned short file_id; unsigned char p1, p2, p3; } __attribute__((__packed__)); -struct ipc_sec_rsim_access_response { +struct ipc_sec_rsim_access_response_header { unsigned char sw1, sw2; - unsigned char len; + unsigned char length; } __attribute__((__packed__)); -// This is the data structure for SIM ICC type != 1 -struct ipc_sec_rsim_access_response_data { - unsigned char unk1[3]; +struct ipc_sec_rsim_access_usim_response_header { + unsigned char unknown1[3]; unsigned char offset; - unsigned char unk2[2]; - unsigned char file_structure; - unsigned char record_length; + unsigned char unknown2[2]; + unsigned char file_structure; // IPC_SEC_RSIM_FILE_STRUCTURE + unsigned char length; } __attribute__((__packed__)); -struct ipc_sec_lock_info_get { - unsigned char unk0; /* needs to be "1" */ - /* IPC_SEC_PIN_TYPE_... */ - unsigned char pin_type; +struct ipc_sec_sim_icc_type { + unsigned char type; // IPC_SEC_SIM_CARD_TYPE } __attribute__((__packed__)); -struct ipc_sec_lock_info_response { - unsigned char num; - /* IPC_SEC_PIN_TYPE_... */ - unsigned char type; - unsigned char key; - unsigned char attempts; +struct ipc_sec_lock_info_request_data { + unsigned char magic; + unsigned char type; // IPC_SEC_PIN_TYPE } __attribute__((__packed__)); -struct ipc_sec_sim_icc_type { - unsigned char type; +struct ipc_sec_lock_info_response_data { + unsigned char unknown; + unsigned char type; // IPC_SEC_PIN_TYPE + unsigned char key; + unsigned char retry_count; } __attribute__((__packed__)); /* * Helpers */ -void ipc_sec_pin_status_set_setup(struct ipc_sec_pin_status_set *message, +void ipc_sec_sim_status_setup(struct ipc_sec_sim_status_request_data *message, unsigned char pin_type, char *pin1, char *pin2); -void ipc_sec_lock_info_get_setup(struct ipc_sec_lock_info_get *message, +void ipc_sec_lock_info_setup(struct ipc_sec_lock_info_request_data *message, unsigned char pin_type); -void ipc_sec_phone_lock_set_setup(struct ipc_sec_phone_lock_set *message, +void ipc_sec_phone_lock_request_set_setup(struct ipc_sec_phone_lock_request_set_data *message, int pin_type, int enable, char *passwd); char *ipc_sec_rsim_access_response_get_file_data(struct ipc_message_info *response); -void ipc_sec_change_locking_pw_set_setup(struct ipc_sec_change_locking_pw_set *message, +void ipc_sec_change_locking_pw_setup(struct ipc_sec_change_locking_pw_data *message, int type, char *passwd_old, char *passwd_new); #endif |