summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--authfd.c6
-rw-r--r--authfd.h6
-rw-r--r--readconf.c8
-rw-r--r--readconf.h4
-rw-r--r--scard.c17
-rw-r--r--scard.h4
-rw-r--r--ssh-add.c19
-rw-r--r--ssh-agent.c19
-rw-r--r--ssh.c6
10 files changed, 53 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index e69d9479a..aba6d3792 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -87,6 +87,10 @@
87 - jakob@cvs.openbsd.org 2001/07/31 12:53:34 87 - jakob@cvs.openbsd.org 2001/07/31 12:53:34
88 [scard.c] 88 [scard.c]
89 close smartcard connection if card is missing 89 close smartcard connection if card is missing
90 - markus@cvs.openbsd.org 2001/08/01 22:03:33
91 [authfd.c authfd.h readconf.c readconf.h scard.c scard.h ssh-add.c
92 ssh-agent.c ssh.c]
93 use strings instead of ints for smartcard reader ids
90 94
9120010803 9520010803
92 - (djm) Fix interrupted read in entropy gatherer. Spotted by markus@ on 96 - (djm) Fix interrupted read in entropy gatherer. Spotted by markus@ on
@@ -6197,4 +6201,4 @@
6197 - Wrote replacements for strlcpy and mkdtemp 6201 - Wrote replacements for strlcpy and mkdtemp
6198 - Released 1.0pre1 6202 - Released 1.0pre1
6199 6203
6200$Id: ChangeLog,v 1.1448 2001/08/06 21:33:44 mouring Exp $ 6204$Id: ChangeLog,v 1.1449 2001/08/06 21:35:51 mouring Exp $
diff --git a/authfd.c b/authfd.c
index b3c0d9d87..da4a32e0f 100644
--- a/authfd.c
+++ b/authfd.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: authfd.c,v 1.42 2001/06/26 04:59:59 markus Exp $"); 38RCSID("$OpenBSD: authfd.c,v 1.43 2001/08/01 22:03:33 markus Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41 41
@@ -535,7 +535,7 @@ ssh_remove_identity(AuthenticationConnection *auth, Key *key)
535} 535}
536 536
537int 537int
538ssh_update_card(AuthenticationConnection *auth, int add, int reader_id) 538ssh_update_card(AuthenticationConnection *auth, int add, const char *reader_id)
539{ 539{
540 Buffer msg; 540 Buffer msg;
541 int type; 541 int type;
@@ -543,7 +543,7 @@ ssh_update_card(AuthenticationConnection *auth, int add, int reader_id)
543 buffer_init(&msg); 543 buffer_init(&msg);
544 buffer_put_char(&msg, add ? SSH_AGENTC_ADD_SMARTCARD_KEY : 544 buffer_put_char(&msg, add ? SSH_AGENTC_ADD_SMARTCARD_KEY :
545 SSH_AGENTC_REMOVE_SMARTCARD_KEY); 545 SSH_AGENTC_REMOVE_SMARTCARD_KEY);
546 buffer_put_int(&msg, reader_id); 546 buffer_put_cstring(&msg, reader_id);
547 if (ssh_request_reply(auth, &msg, &msg) == 0) { 547 if (ssh_request_reply(auth, &msg, &msg) == 0) {
548 buffer_free(&msg); 548 buffer_free(&msg);
549 return 0; 549 return 0;
diff --git a/authfd.h b/authfd.h
index 5aac78bda..b7e88fde8 100644
--- a/authfd.h
+++ b/authfd.h
@@ -11,7 +11,7 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: authfd.h,v 1.19 2001/06/26 17:27:22 markus Exp $"); */ 14/* RCSID("$OpenBSD: authfd.h,v 1.20 2001/08/01 22:03:33 markus Exp $"); */
15 15
16#ifndef AUTHFD_H 16#ifndef AUTHFD_H
17#define AUTHFD_H 17#define AUTHFD_H
@@ -62,9 +62,9 @@ int ssh_get_num_identities(AuthenticationConnection *, int);
62Key *ssh_get_first_identity(AuthenticationConnection *, char **, int); 62Key *ssh_get_first_identity(AuthenticationConnection *, char **, int);
63Key *ssh_get_next_identity(AuthenticationConnection *, char **, int); 63Key *ssh_get_next_identity(AuthenticationConnection *, char **, int);
64int ssh_add_identity(AuthenticationConnection *, Key *, const char *); 64int ssh_add_identity(AuthenticationConnection *, Key *, const char *);
65int ssh_remove_identity(AuthenticationConnection *, Key *); 65int ssh_remove_identity(AuthenticationConnection *, Key *);
66int ssh_remove_all_identities(AuthenticationConnection *, int); 66int ssh_remove_all_identities(AuthenticationConnection *, int);
67int ssh_update_card(AuthenticationConnection *, int, int); 67int ssh_update_card(AuthenticationConnection *, int, const char *);
68 68
69int 69int
70ssh_decrypt_challenge(AuthenticationConnection *, Key *, BIGNUM *, u_char[16], 70ssh_decrypt_challenge(AuthenticationConnection *, Key *, BIGNUM *, u_char[16],
diff --git a/readconf.c b/readconf.c
index a4ae73333..c556b8338 100644
--- a/readconf.c
+++ b/readconf.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: readconf.c,v 1.85 2001/07/31 09:28:44 jakob Exp $"); 15RCSID("$OpenBSD: readconf.c,v 1.86 2001/08/01 22:03:33 markus Exp $");
16 16
17#include "ssh.h" 17#include "ssh.h"
18#include "xmalloc.h" 18#include "xmalloc.h"
@@ -470,8 +470,8 @@ parse_string:
470 goto parse_string; 470 goto parse_string;
471 471
472 case oSmartcardDevice: 472 case oSmartcardDevice:
473 intptr = &options->smartcard_device; 473 charptr = &options->smartcard_device;
474 goto parse_int; 474 goto parse_string;
475 475
476 case oProxyCommand: 476 case oProxyCommand:
477 charptr = &options->proxy_command; 477 charptr = &options->proxy_command;
@@ -777,7 +777,7 @@ initialize_options(Options * options)
777 options->log_level = (LogLevel) - 1; 777 options->log_level = (LogLevel) - 1;
778 options->preferred_authentications = NULL; 778 options->preferred_authentications = NULL;
779 options->bind_address = NULL; 779 options->bind_address = NULL;
780 options->smartcard_device = -1; 780 options->smartcard_device = NULL;
781} 781}
782 782
783/* 783/*
diff --git a/readconf.h b/readconf.h
index 623a44810..802fd1908 100644
--- a/readconf.h
+++ b/readconf.h
@@ -11,7 +11,7 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: readconf.h,v 1.36 2001/07/31 09:28:44 jakob Exp $"); */ 14/* RCSID("$OpenBSD: readconf.h,v 1.37 2001/08/01 22:03:33 markus Exp $"); */
15 15
16#ifndef READCONF_H 16#ifndef READCONF_H
17#define READCONF_H 17#define READCONF_H
@@ -87,7 +87,7 @@ typedef struct {
87 char *user_hostfile2; 87 char *user_hostfile2;
88 char *preferred_authentications; 88 char *preferred_authentications;
89 char *bind_address; /* local socket address for connection to sshd */ 89 char *bind_address; /* local socket address for connection to sshd */
90 int smartcard_device; /* Smartcard reader device */ 90 char *smartcard_device; /* Smartcard reader device */
91 91
92 int num_identity_files; /* Number of files for RSA/DSA identities. */ 92 int num_identity_files; /* Number of files for RSA/DSA identities. */
93 char *identity_files[SSH_MAX_IDENTITY_FILES]; 93 char *identity_files[SSH_MAX_IDENTITY_FILES];
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;
diff --git a/scard.h b/scard.h
index 4a6531580..57189df1c 100644
--- a/scard.h
+++ b/scard.h
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25/* $OpenBSD: scard.h,v 1.5 2001/07/30 16:06:07 jakob Exp $ */ 25/* $OpenBSD: scard.h,v 1.6 2001/08/01 22:03:33 markus Exp $ */
26 26
27#include <openssl/engine.h> 27#include <openssl/engine.h>
28 28
@@ -33,7 +33,7 @@
33#define SCARD_ERROR_NOCARD -2 33#define SCARD_ERROR_NOCARD -2
34#define SCARD_ERROR_APPLET -3 34#define SCARD_ERROR_APPLET -3
35 35
36Key *sc_get_key(int); 36Key *sc_get_key(const char*);
37ENGINE *sc_get_engine(void); 37ENGINE *sc_get_engine(void);
38void sc_close(void); 38void sc_close(void);
39 39
diff --git a/ssh-add.c b/ssh-add.c
index 711dca5ea..b44c306b2 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: ssh-add.c,v 1.43 2001/06/27 06:26:36 markus Exp $"); 38RCSID("$OpenBSD: ssh-add.c,v 1.44 2001/08/01 22:03:33 markus Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41 41
@@ -150,13 +150,13 @@ add_file(AuthenticationConnection *ac, const char *filename)
150} 150}
151 151
152static void 152static void
153update_card(AuthenticationConnection *ac, int add, int id) 153update_card(AuthenticationConnection *ac, int add, const char *id)
154{ 154{
155 if (ssh_update_card(ac, add, id)) 155 if (ssh_update_card(ac, add, id))
156 fprintf(stderr, "Card %s: %d\n", 156 fprintf(stderr, "Card %s: %s\n",
157 add ? "added" : "removed", id); 157 add ? "added" : "removed", id);
158 else 158 else
159 fprintf(stderr, "Could not %s card: %d\n", 159 fprintf(stderr, "Could not %s card: %s\n",
160 add ? "add" : "remove", id); 160 add ? "add" : "remove", id);
161} 161}
162 162
@@ -211,7 +211,8 @@ main(int argc, char **argv)
211 AuthenticationConnection *ac = NULL; 211 AuthenticationConnection *ac = NULL;
212 struct passwd *pw; 212 struct passwd *pw;
213 char buf[1024]; 213 char buf[1024];
214 int i, ch, deleting = 0, sc_reader_num = -1; 214 char *sc_reader_id = NULL;
215 int i, ch, deleting = 0;
215 216
216 __progname = get_progname(argv[0]); 217 __progname = get_progname(argv[0]);
217 init_rng(); 218 init_rng();
@@ -240,11 +241,11 @@ main(int argc, char **argv)
240 goto done; 241 goto done;
241 break; 242 break;
242 case 's': 243 case 's':
243 sc_reader_num = atoi(optarg); 244 sc_reader_id = optarg;
244 break; 245 break;
245 case 'e': 246 case 'e':
246 deleting = 1; 247 deleting = 1;
247 sc_reader_num = atoi(optarg); 248 sc_reader_id = optarg;
248 break; 249 break;
249 default: 250 default:
250 usage(); 251 usage();
@@ -254,8 +255,8 @@ main(int argc, char **argv)
254 } 255 }
255 argc -= optind; 256 argc -= optind;
256 argv += optind; 257 argv += optind;
257 if (sc_reader_num != -1) { 258 if (sc_reader_id != NULL) {
258 update_card(ac, !deleting, sc_reader_num); 259 update_card(ac, !deleting, sc_reader_id);
259 goto done; 260 goto done;
260 } 261 }
261 if (argc == 0) { 262 if (argc == 0) {
diff --git a/ssh-agent.c b/ssh-agent.c
index 46a1199b1..1df3ccd11 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-agent.c,v 1.68 2001/07/20 14:46:11 markus Exp $ */ 1/* $OpenBSD: ssh-agent.c,v 1.69 2001/08/01 22:03:33 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -36,7 +36,7 @@
36 */ 36 */
37 37
38#include "includes.h" 38#include "includes.h"
39RCSID("$OpenBSD: ssh-agent.c,v 1.68 2001/07/20 14:46:11 markus Exp $"); 39RCSID("$OpenBSD: ssh-agent.c,v 1.69 2001/08/01 22:03:33 markus Exp $");
40 40
41#include <openssl/evp.h> 41#include <openssl/evp.h>
42#include <openssl/md5.h> 42#include <openssl/md5.h>
@@ -451,12 +451,13 @@ process_add_smartcard_key (SocketEntry *e)
451{ 451{
452 Idtab *tab; 452 Idtab *tab;
453 Key *n = NULL, *k = NULL; 453 Key *n = NULL, *k = NULL;
454 char *sc_reader_id = NULL;
454 int success = 0; 455 int success = 0;
455 int sc_reader_num = 0;
456 456
457 sc_reader_num = buffer_get_int(&e->input); 457 sc_reader_id = buffer_get_string(&e->input, NULL);
458 k = sc_get_key(sc_reader_id);
459 xfree(sc_reader_id);
458 460
459 k = sc_get_key(sc_reader_num);
460 if (k == NULL) { 461 if (k == NULL) {
461 error("sc_get_pubkey failed"); 462 error("sc_get_pubkey failed");
462 goto send; 463 goto send;
@@ -510,11 +511,13 @@ process_remove_smartcard_key(SocketEntry *e)
510 Key *k = NULL, *private; 511 Key *k = NULL, *private;
511 int idx; 512 int idx;
512 int success = 0; 513 int success = 0;
513 int sc_reader_num = 0; 514 char *sc_reader_id = NULL;
514 515
515 sc_reader_num = buffer_get_int(&e->input); 516 sc_reader_id = buffer_get_string(&e->input, NULL);
517 k = sc_get_key(sc_reader_id);
518 xfree(sc_reader_id);
516 519
517 if ((k = sc_get_key(sc_reader_num)) == NULL) { 520 if (k == NULL) {
518 error("sc_get_pubkey failed"); 521 error("sc_get_pubkey failed");
519 } else { 522 } else {
520 k->type = KEY_RSA1; 523 k->type = KEY_RSA1;
diff --git a/ssh.c b/ssh.c
index 70eaa772b..8f1d6ac73 100644
--- a/ssh.c
+++ b/ssh.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include "includes.h" 41#include "includes.h"
42RCSID("$OpenBSD: ssh.c,v 1.132 2001/07/31 09:28:44 jakob Exp $"); 42RCSID("$OpenBSD: ssh.c,v 1.133 2001/08/01 22:03:33 markus Exp $");
43 43
44#include <openssl/evp.h> 44#include <openssl/evp.h>
45#include <openssl/err.h> 45#include <openssl/err.h>
@@ -372,7 +372,7 @@ again:
372 break; 372 break;
373 case 'I': 373 case 'I':
374#ifdef SMARTCARD 374#ifdef SMARTCARD
375 options.smartcard_device = atoi(optarg); 375 options.smartcard_device = xstrdup(optarg);
376#else 376#else
377 fprintf(stderr, "no support for smartcards.\n"); 377 fprintf(stderr, "no support for smartcards.\n");
378#endif 378#endif
@@ -1151,7 +1151,7 @@ load_public_identity_files(void)
1151 int i = 0; 1151 int i = 0;
1152 1152
1153#ifdef SMARTCARD 1153#ifdef SMARTCARD
1154 if (options.smartcard_device >= 0 && 1154 if (options.smartcard_device != NULL &&
1155 options.num_identity_files + 1 < SSH_MAX_IDENTITY_FILES && 1155 options.num_identity_files + 1 < SSH_MAX_IDENTITY_FILES &&
1156 (public = sc_get_key(options.smartcard_device)) != NULL ) { 1156 (public = sc_get_key(options.smartcard_device)) != NULL ) {
1157 Key *new; 1157 Key *new;