version 1.10, 2001/07/31 12:53:34 |
version 1.11, 2001/08/01 22:03:33 |
|
|
#define MAX_BUF_SIZE 256 |
#define MAX_BUF_SIZE 256 |
|
|
static int sc_fd = -1; |
static int sc_fd = -1; |
static int sc_reader_num = -1; |
static char *sc_reader_id = NULL; |
static int cla = 0x00; /* class */ |
static int cla = 0x00; /* class */ |
|
|
/* interface to libsectok */ |
/* interface to libsectok */ |
|
|
if (sc_fd >= 0) |
if (sc_fd >= 0) |
return sc_fd; |
return sc_fd; |
|
|
sc_fd = sectok_open(sc_reader_num, STONOWAIT, &sw); |
sc_fd = sectok_friendly_open(sc_reader_id, STONOWAIT, &sw); |
if (sc_fd < 0) { |
if (sc_fd < 0) { |
error("sectok_open failed: %s", sectok_get_sw(sw)); |
error("sectok_open failed: %s", sectok_get_sw(sw)); |
return SCARD_ERROR_FAIL; |
return SCARD_ERROR_FAIL; |
} |
} |
if (! sectok_cardpresent(sc_fd)) { |
if (! sectok_cardpresent(sc_fd)) { |
debug("smartcard in reader %d not present, skipping", |
debug("smartcard in reader %s not present, skipping", |
sc_reader_num); |
sc_reader_id); |
sc_close(); |
sc_close(); |
return SCARD_ERROR_NOCARD; |
return SCARD_ERROR_NOCARD; |
} |
} |
|
|
} |
} |
|
|
Key * |
Key * |
sc_get_key(int num) |
sc_get_key(const char *id) |
{ |
{ |
Key *k; |
Key *k; |
int status; |
int status; |
|
|
sc_reader_num = num; |
if (sc_reader_id != NULL) |
|
xfree(sc_reader_id); |
|
sc_reader_id = xstrdup(id); |
|
|
k = key_new(KEY_RSA); |
k = key_new(KEY_RSA); |
if (k == NULL) { |
if (k == NULL) { |
return NULL; |
return NULL; |