summaryrefslogtreecommitdiff
path: root/scard.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-08-06 21:35:51 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-08-06 21:35:51 +0000
commitf7db3bb64caf8d7822a18d6fd4c0480df7d0086d (patch)
tree3167ed1f115185df591dc1c28c8aa33476194cbb /scard.c
parent3ab1dfa2a654b6764eaa121f7111e94c35175894 (diff)
- markus@cvs.openbsd.org 2001/08/01 22:03:33
[authfd.c authfd.h readconf.c readconf.h scard.c scard.h ssh-add.c ssh-agent.c ssh.c] use strings instead of ints for smartcard reader ids
Diffstat (limited to 'scard.c')
-rw-r--r--scard.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/scard.c b/scard.c
index 8c53c66df..8b3abcfa0 100644
--- a/scard.c
+++ b/scard.c
@@ -24,7 +24,7 @@
24 24
25#ifdef SMARTCARD 25#ifdef SMARTCARD
26#include "includes.h" 26#include "includes.h"
27RCSID("$OpenBSD: scard.c,v 1.10 2001/07/31 12:53:34 jakob Exp $"); 27RCSID("$OpenBSD: scard.c,v 1.11 2001/08/01 22:03:33 markus Exp $");
28 28
29#include <openssl/engine.h> 29#include <openssl/engine.h>
30#include <sectok.h> 30#include <sectok.h>
@@ -43,7 +43,7 @@ RCSID("$OpenBSD: scard.c,v 1.10 2001/07/31 12:53:34 jakob Exp $");
43#define MAX_BUF_SIZE 256 43#define MAX_BUF_SIZE 256
44 44
45static int sc_fd = -1; 45static int sc_fd = -1;
46static int sc_reader_num = -1; 46static char *sc_reader_id = NULL;
47static int cla = 0x00; /* class */ 47static int cla = 0x00; /* class */
48 48
49/* interface to libsectok */ 49/* interface to libsectok */
@@ -56,14 +56,14 @@ sc_open(void)
56 if (sc_fd >= 0) 56 if (sc_fd >= 0)
57 return sc_fd; 57 return sc_fd;
58 58
59 sc_fd = sectok_open(sc_reader_num, STONOWAIT, &sw); 59 sc_fd = sectok_friendly_open(sc_reader_id, STONOWAIT, &sw);
60 if (sc_fd < 0) { 60 if (sc_fd < 0) {
61 error("sectok_open failed: %s", sectok_get_sw(sw)); 61 error("sectok_open failed: %s", sectok_get_sw(sw));
62 return SCARD_ERROR_FAIL; 62 return SCARD_ERROR_FAIL;
63 } 63 }
64 if (! sectok_cardpresent(sc_fd)) { 64 if (! sectok_cardpresent(sc_fd)) {
65 debug("smartcard in reader %d not present, skipping", 65 debug("smartcard in reader %s not present, skipping",
66 sc_reader_num); 66 sc_reader_id);
67 sc_close(); 67 sc_close();
68 return SCARD_ERROR_NOCARD; 68 return SCARD_ERROR_NOCARD;
69 } 69 }
@@ -326,12 +326,15 @@ sc_close(void)
326} 326}
327 327
328Key * 328Key *
329sc_get_key(int num) 329sc_get_key(const char *id)
330{ 330{
331 Key *k; 331 Key *k;
332 int status; 332 int status;
333 333
334 sc_reader_num = num; 334 if (sc_reader_id != NULL)
335 xfree(sc_reader_id);
336 sc_reader_id = xstrdup(id);
337
335 k = key_new(KEY_RSA); 338 k = key_new(KEY_RSA);
336 if (k == NULL) { 339 if (k == NULL) {
337 return NULL; 340 return NULL;