1 /* 2 * WPA Supplicant / PC/SC smartcard interface for USIM, GSM SIM 3 * Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi> 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #ifndef PCSC_FUNCS_H 10 #define PCSC_FUNCS_H 11 12 /* GSM files 13 * File type in first octet: 14 * 3F = Master File 15 * 7F = Dedicated File 16 * 2F = Elementary File under the Master File 17 * 6F = Elementary File under a Dedicated File 18 */ 19 #define SCARD_FILE_MF 0x3F00 20 #define SCARD_FILE_GSM_DF 0x7F20 21 #define SCARD_FILE_UMTS_DF 0x7F50 22 #define SCARD_FILE_GSM_EF_IMSI 0x6F07 23 #define SCARD_FILE_GSM_EF_AD 0x6FAD 24 #define SCARD_FILE_EF_DIR 0x2F00 25 #define SCARD_FILE_EF_ICCID 0x2FE2 26 #define SCARD_FILE_EF_CK 0x6FE1 27 #define SCARD_FILE_EF_IK 0x6FE2 28 29 #define SCARD_CHV1_OFFSET 13 30 #define SCARD_CHV1_FLAG 0x80 31 32 typedef enum { 33 SCARD_GSM_SIM_ONLY, 34 SCARD_USIM_ONLY, 35 SCARD_TRY_BOTH 36 } scard_sim_type; 37 38 39 #ifdef PCSC_FUNCS 40 struct scard_data * scard_init(scard_sim_type sim_type); 41 void scard_deinit(struct scard_data *scard); 42 43 int scard_set_pin(struct scard_data *scard, const char *pin); 44 int scard_get_imsi(struct scard_data *scard, char *imsi, size_t *len); 45 int scard_get_mnc_len(struct scard_data *scard); 46 int scard_gsm_auth(struct scard_data *scard, const unsigned char *_rand, 47 unsigned char *sres, unsigned char *kc); 48 int scard_umts_auth(struct scard_data *scard, const unsigned char *_rand, 49 const unsigned char *autn, 50 unsigned char *res, size_t *res_len, 51 unsigned char *ik, unsigned char *ck, unsigned char *auts); 52 53 #else /* PCSC_FUNCS */ 54 55 #define scard_init(s) NULL 56 #define scard_deinit(s) do { } while (0) 57 #define scard_set_pin(s, p) -1 58 #define scard_get_imsi(s, i, l) -1 59 #define scard_gsm_auth(s, r, s2, k) -1 60 #define scard_umts_auth(s, r, a, r2, rl, i, c, a2) -1 61 62 #endif /* PCSC_FUNCS */ 63 64 #endif /* PCSC_FUNCS_H */ 65