blob: b4ebc99835b6ebfb2c9faa891fa25fc8b0edff8c [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * WPA Supplicant / PC/SC smartcard interface for USIM, GSM SIM
Dmitry Shmidt04949592012-07-19 12:16:46 -07003 * Copyright (c) 2004-2006, 2012, Jouni Malinen <j@w1.fi>
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07004 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
8
9#ifndef PCSC_FUNCS_H
10#define PCSC_FUNCS_H
11
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070012typedef enum {
13 SCARD_GSM_SIM_ONLY,
14 SCARD_USIM_ONLY,
15 SCARD_TRY_BOTH
16} scard_sim_type;
17
18
19#ifdef PCSC_FUNCS
Dmitry Shmidt04949592012-07-19 12:16:46 -070020struct scard_data * scard_init(scard_sim_type sim_type, const char *reader);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070021void scard_deinit(struct scard_data *scard);
22
23int scard_set_pin(struct scard_data *scard, const char *pin);
24int scard_get_imsi(struct scard_data *scard, char *imsi, size_t *len);
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -080025int scard_get_mnc_len(struct scard_data *scard);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070026int scard_gsm_auth(struct scard_data *scard, const unsigned char *_rand,
27 unsigned char *sres, unsigned char *kc);
28int scard_umts_auth(struct scard_data *scard, const unsigned char *_rand,
29 const unsigned char *autn,
30 unsigned char *res, size_t *res_len,
31 unsigned char *ik, unsigned char *ck, unsigned char *auts);
Dmitry Shmidt04949592012-07-19 12:16:46 -070032int scard_get_pin_retry_counter(struct scard_data *scard);
33int scard_supports_umts(struct scard_data *scard);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070034
35#else /* PCSC_FUNCS */
36
Dmitry Shmidt04949592012-07-19 12:16:46 -070037#define scard_init(s, r) NULL
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070038#define scard_deinit(s) do { } while (0)
39#define scard_set_pin(s, p) -1
40#define scard_get_imsi(s, i, l) -1
Dmitry Shmidt04949592012-07-19 12:16:46 -070041#define scard_get_mnc_len(s) -1
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070042#define scard_gsm_auth(s, r, s2, k) -1
43#define scard_umts_auth(s, r, a, r2, rl, i, c, a2) -1
Dmitry Shmidt04949592012-07-19 12:16:46 -070044#define scard_get_pin_retry_counter(s) -1
45#define scard_supports_umts(s) 0
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070046
47#endif /* PCSC_FUNCS */
48
49#endif /* PCSC_FUNCS_H */