$search

pcsc_funcs.c File Reference

#include "includes.h"
#include <winscard.h>
#include "common.h"
#include "pcsc_funcs.h"
Include dependency graph for pcsc_funcs.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  scard_data

Defines

#define AKA_AUTN_LEN   16
#define AKA_AUTS_LEN   14
#define AKA_RAND_LEN   16
#define CK_LEN   16
#define IK_LEN   16
#define mingw_load_symbols()   0
#define mingw_unload_symbols()   do { } while (0)
#define RES_MAX_LEN   16
#define SIM_CMD_GET_RESPONSE   0xa0, 0xc0, 0x00, 0x00
#define SIM_CMD_READ_BIN   0xa0, 0xb0, 0x00, 0x00
#define SIM_CMD_READ_RECORD   0xa0, 0xb2, 0x00, 0x00
#define SIM_CMD_RUN_GSM_ALG   0xa0, 0x88, 0x00, 0x00, 0x10
#define SIM_CMD_SELECT   0xa0, 0xa4, 0x00, 0x00, 0x02
#define SIM_CMD_VERIFY_CHV1   0xa0, 0x20, 0x00, 0x01, 0x08
#define SIM_RECORD_MODE_ABSOLUTE   0x04
#define USIM_CLA   0x00
#define USIM_CMD_GET_RESPONSE   0x00, 0xc0, 0x00, 0x00
#define USIM_CMD_RUN_UMTS_ALG   0x00, 0x88, 0x00, 0x81, 0x22
#define USIM_FSP_TEMPL_TAG   0x62
#define USIM_PS_DO_TAG   0x90
#define USIM_TLV_DF_NAME   0x84
#define USIM_TLV_FILE_DESC   0x82
#define USIM_TLV_FILE_ID   0x83
#define USIM_TLV_FILE_SIZE   0x80
#define USIM_TLV_LIFE_CYCLE_STATUS   0x8A
#define USIM_TLV_PIN_STATUS_TEMPLATE   0xC6
#define USIM_TLV_PROPR_INFO   0xA5
#define USIM_TLV_SHORT_FILE_ID   0x88
#define USIM_TLV_TOTAL_FILE_SIZE   0x81

Enumerations

enum  sim_types { SCARD_GSM_SIM, SCARD_USIM }

Functions

static int _scard_select_file (struct scard_data *scard, unsigned short file_id, unsigned char *buf, size_t *buf_len, sim_types sim_type, unsigned char *aid, size_t aidlen)
void scard_deinit (struct scard_data *scard)
static int scard_get_aid (struct scard_data *scard, unsigned char *aid, size_t maxlen)
int scard_get_imsi (struct scard_data *scard, char *imsi, size_t *len)
static int scard_get_record_len (struct scard_data *scard, unsigned char recnum, unsigned char mode)
int scard_gsm_auth (struct scard_data *scard, const unsigned char *_rand, unsigned char *sres, unsigned char *kc)
struct scard_datascard_init (scard_sim_type sim_type)
static int scard_parse_fsp_templ (unsigned char *buf, size_t buf_len, int *ps_do, int *file_len)
static int scard_pin_needed (struct scard_data *scard, unsigned char *hdr, size_t hlen)
static int scard_read_file (struct scard_data *scard, unsigned char *data, size_t len)
static int scard_read_record (struct scard_data *scard, unsigned char *data, size_t len, unsigned char recnum, unsigned char mode)
static int scard_select_file (struct scard_data *scard, unsigned short file_id, unsigned char *buf, size_t *buf_len)
int scard_set_pin (struct scard_data *scard, const char *pin)
static long scard_transmit (struct scard_data *scard, unsigned char *_send, size_t send_len, unsigned char *_recv, size_t *recv_len)
int scard_umts_auth (struct scard_data *scard, const unsigned char *_rand, const unsigned char *autn, unsigned char *res, size_t *res_len, unsigned char *ik, unsigned char *ck, unsigned char *auts)
static int scard_verify_pin (struct scard_data *scard, const char *pin)

Define Documentation

#define AKA_AUTN_LEN   16

Definition at line 83 of file pcsc_funcs.c.

#define AKA_AUTS_LEN   14

Definition at line 84 of file pcsc_funcs.c.

#define AKA_RAND_LEN   16

Definition at line 82 of file pcsc_funcs.c.

#define CK_LEN   16

Definition at line 87 of file pcsc_funcs.c.

#define IK_LEN   16

Definition at line 86 of file pcsc_funcs.c.

 
#define mingw_load_symbols (  )     0

Definition at line 220 of file pcsc_funcs.c.

 
#define mingw_unload_symbols (  )     do { } while (0)

Definition at line 221 of file pcsc_funcs.c.

#define RES_MAX_LEN   16

Definition at line 85 of file pcsc_funcs.c.

#define SIM_CMD_GET_RESPONSE   0xa0, 0xc0, 0x00, 0x00

Definition at line 56 of file pcsc_funcs.c.

#define SIM_CMD_READ_BIN   0xa0, 0xb0, 0x00, 0x00

Definition at line 57 of file pcsc_funcs.c.

#define SIM_CMD_READ_RECORD   0xa0, 0xb2, 0x00, 0x00

Definition at line 58 of file pcsc_funcs.c.

#define SIM_CMD_RUN_GSM_ALG   0xa0, 0x88, 0x00, 0x00, 0x10

Definition at line 55 of file pcsc_funcs.c.

#define SIM_CMD_SELECT   0xa0, 0xa4, 0x00, 0x00, 0x02

Definition at line 54 of file pcsc_funcs.c.

#define SIM_CMD_VERIFY_CHV1   0xa0, 0x20, 0x00, 0x01, 0x08

Definition at line 59 of file pcsc_funcs.c.

#define SIM_RECORD_MODE_ABSOLUTE   0x04

Definition at line 66 of file pcsc_funcs.c.

#define USIM_CLA   0x00

Definition at line 62 of file pcsc_funcs.c.

#define USIM_CMD_GET_RESPONSE   0x00, 0xc0, 0x00, 0x00

Definition at line 64 of file pcsc_funcs.c.

#define USIM_CMD_RUN_UMTS_ALG   0x00, 0x88, 0x00, 0x81, 0x22

Definition at line 63 of file pcsc_funcs.c.

#define USIM_FSP_TEMPL_TAG   0x62

Definition at line 68 of file pcsc_funcs.c.

#define USIM_PS_DO_TAG   0x90

Definition at line 80 of file pcsc_funcs.c.

#define USIM_TLV_DF_NAME   0x84

Definition at line 72 of file pcsc_funcs.c.

#define USIM_TLV_FILE_DESC   0x82

Definition at line 70 of file pcsc_funcs.c.

#define USIM_TLV_FILE_ID   0x83

Definition at line 71 of file pcsc_funcs.c.

#define USIM_TLV_FILE_SIZE   0x80

Definition at line 75 of file pcsc_funcs.c.

#define USIM_TLV_LIFE_CYCLE_STATUS   0x8A

Definition at line 74 of file pcsc_funcs.c.

#define USIM_TLV_PIN_STATUS_TEMPLATE   0xC6

Definition at line 77 of file pcsc_funcs.c.

#define USIM_TLV_PROPR_INFO   0xA5

Definition at line 73 of file pcsc_funcs.c.

#define USIM_TLV_SHORT_FILE_ID   0x88

Definition at line 78 of file pcsc_funcs.c.

#define USIM_TLV_TOTAL_FILE_SIZE   0x81

Definition at line 76 of file pcsc_funcs.c.


Enumeration Type Documentation

enum sim_types
Enumerator:
SCARD_GSM_SIM 
SCARD_USIM 

Definition at line 90 of file pcsc_funcs.c.


Function Documentation

static int _scard_select_file ( struct scard_data scard,
unsigned short  file_id,
unsigned char *  buf,
size_t *  buf_len,
sim_types  sim_type,
unsigned char *  aid,
size_t  aidlen 
) [static]

Definition at line 701 of file pcsc_funcs.c.

void scard_deinit ( struct scard_data scard  ) 

scard_deinit - Deinitialize SIM/USIM connection : Pointer to private data from scard_init()

This function closes the SIM/USIM connect opened with scard_init().

Definition at line 646 of file pcsc_funcs.c.

static int scard_get_aid ( struct scard_data scard,
unsigned char *  aid,
size_t  maxlen 
) [static]

Definition at line 325 of file pcsc_funcs.c.

int scard_get_imsi ( struct scard_data scard,
char *  imsi,
size_t *  len 
)

scard_get_imsi - Read IMSI from SIM/USIM card : Pointer to private data from scard_init() : Buffer for IMSI : Length of imsi buffer; set to IMSI length on success Returns: 0 on success, -1 if IMSI file cannot be selected, -2 if IMSI file selection returns invalid result code, -3 if parsing FSP template file fails (USIM only), -4 if IMSI does not fit in the provided imsi buffer (len is set to needed length), -5 if reading IMSI file fails.

This function can be used to read IMSI from the SIM/USIM card. If the IMSI file is PIN protected, scard_set_pin() must have been used to set the correct PIN code before calling scard_get_imsi().

Definition at line 962 of file pcsc_funcs.c.

static int scard_get_record_len ( struct scard_data scard,
unsigned char  recnum,
unsigned char  mode 
) [static]

Definition at line 790 of file pcsc_funcs.c.

int scard_gsm_auth ( struct scard_data scard,
const unsigned char *  _rand,
unsigned char *  sres,
unsigned char *  kc 
)

scard_gsm_auth - Run GSM authentication command on SIM card : Pointer to private data from scard_init() : 16-byte RAND value from HLR/AuC : 4-byte buffer for SRES : 8-byte buffer for Kc Returns: 0 on success, -1 if SIM/USIM connection has not been initialized, -2 if authentication command execution fails, -3 if unknown response code for authentication command is received, -4 if reading of response fails, -5 if if response data is of unexpected length

This function performs GSM authentication using SIM/USIM card and the provided RAND value from HLR/AuC. If authentication command can be completed successfully, SRES and Kc values will be written into sres and kc buffers.

Definition at line 1041 of file pcsc_funcs.c.

struct scard_data* scard_init ( scard_sim_type  sim_type  )  [read]

scard_init - Initialize SIM/USIM connection using PC/SC : Allowed SIM types (SIM, USIM, or both) Returns: Pointer to private data structure, or NULL on failure

This function is used to initialize SIM/USIM connection. PC/SC is used to open connection to the SIM/USIM card and the card is verified to support the selected sim_type. In addition, local flag is set if a PIN is needed to access some of the card functions. Once the connection is not needed anymore, scard_deinit() can be used to close it.

Definition at line 434 of file pcsc_funcs.c.

static int scard_parse_fsp_templ ( unsigned char *  buf,
size_t  buf_len,
int *  ps_do,
int *  file_len 
) [static]

Definition at line 240 of file pcsc_funcs.c.

static int scard_pin_needed ( struct scard_data scard,
unsigned char *  hdr,
size_t  hlen 
) [static]

Definition at line 300 of file pcsc_funcs.c.

static int scard_read_file ( struct scard_data scard,
unsigned char *  data,
size_t  len 
) [static]

Definition at line 872 of file pcsc_funcs.c.

static int scard_read_record ( struct scard_data scard,
unsigned char *  data,
size_t  len,
unsigned char  recnum,
unsigned char  mode 
) [static]

Definition at line 825 of file pcsc_funcs.c.

static int scard_select_file ( struct scard_data scard,
unsigned short  file_id,
unsigned char *  buf,
size_t *  buf_len 
) [static]

Definition at line 782 of file pcsc_funcs.c.

int scard_set_pin ( struct scard_data scard,
const char *  pin 
)

scard_set_pin - Set PIN (CHV1/PIN1) code for accessing SIM/USIM commands : Pointer to private data from scard_init() : PIN code as an ASCII string (e.g., "1234") Returns: 0 on success, -1 on failure

Definition at line 617 of file pcsc_funcs.c.

static long scard_transmit ( struct scard_data scard,
unsigned char *  _send,
size_t  send_len,
unsigned char *  _recv,
size_t *  recv_len 
) [static]

Definition at line 674 of file pcsc_funcs.c.

int scard_umts_auth ( struct scard_data scard,
const unsigned char *  _rand,
const unsigned char *  autn,
unsigned char *  res,
size_t *  res_len,
unsigned char *  ik,
unsigned char *  ck,
unsigned char *  auts 
)

scard_umts_auth - Run UMTS authentication command on USIM card : Pointer to private data from scard_init() : 16-byte RAND value from HLR/AuC : 16-byte AUTN value from HLR/AuC : 16-byte buffer for RES : Variable that will be set to RES length : 16-byte buffer for IK : 16-byte buffer for CK : 14-byte buffer for AUTS Returns: 0 on success, -1 on failure, or -2 if USIM reports synchronization failure

This function performs AKA authentication using USIM card and the provided RAND and AUTN values from HLR/AuC. If authentication command can be completed successfully, RES, IK, and CK values will be written into provided buffers and res_len is set to length of received RES value. If USIM reports synchronization failure, the received AUTS value will be written into auts buffer. In this case, RES, IK, and CK are not valid.

Definition at line 1139 of file pcsc_funcs.c.

static int scard_verify_pin ( struct scard_data scard,
const char *  pin 
) [static]

Definition at line 916 of file pcsc_funcs.c.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


wpa_supplicant_node
Author(s): Package maintained by Blaise Gassend
autogenerated on Fri Mar 1 16:00:32 2013