summaryrefslogtreecommitdiff
path: root/ssh-keygen.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r--ssh-keygen.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c
index bcb7ab2c3..8b0b4d8dd 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: ssh-keygen.c,v 1.71 2001/06/29 07:11:01 markus Exp $"); 15RCSID("$OpenBSD: ssh-keygen.c,v 1.72 2001/07/02 22:40:18 markus Exp $");
16 16
17#include <openssl/evp.h> 17#include <openssl/evp.h>
18#include <openssl/pem.h> 18#include <openssl/pem.h>
@@ -400,10 +400,10 @@ do_upload(struct passwd *pw, int reader)
400 struct stat st; 400 struct stat st;
401 u_char *elements[NUM_RSA_KEY_ELEMENTS]; 401 u_char *elements[NUM_RSA_KEY_ELEMENTS];
402 u_char key_fid[2]; 402 u_char key_fid[2];
403 u_char atr[256]; 403 u_char atr[256];
404 u_char AUT0[] = {0xad, 0x9f, 0x61, 0xfe, 0xfa, 0x20, 0xce, 0x63}; 404 u_char AUT0[] = {0xad, 0x9f, 0x61, 0xfe, 0xfa, 0x20, 0xce, 0x63};
405 int len, status = 1, i, fd = -1, ret; 405 int len, status = 1, i, fd = -1, ret;
406 int r1 = 0, r2 = 0, cla = 0x00; 406 int sw = 0, cla = 0x00;
407 407
408 for (i = 0; i < NUM_RSA_KEY_ELEMENTS; i++) 408 for (i = 0; i < NUM_RSA_KEY_ELEMENTS; i++)
409 elements[i] = NULL; 409 elements[i] = NULL;
@@ -425,16 +425,16 @@ do_upload(struct passwd *pw, int reader)
425 COPY_RSA_KEY(dmp1, 4); 425 COPY_RSA_KEY(dmp1, 4);
426 COPY_RSA_KEY(n, 5); 426 COPY_RSA_KEY(n, 5);
427 len = BN_num_bytes(prv->rsa->n); 427 len = BN_num_bytes(prv->rsa->n);
428 fd = scopen(reader, 0, NULL); 428 fd = sectok_open(reader, 0, NULL);
429 if (fd < 0) { 429 if (fd < 0) {
430 error("scopen failed"); 430 error("sectok_open failed");
431 goto done; 431 goto done;
432 } 432 }
433 ret = screset(fd, atr, NULL); 433 ret = sectok_reset(fd, 0, atr, &sw);
434 if (ret <= 0) { 434 if (ret <= 0) {
435 error("screset failed"); 435 error("sectok_reset failed");
436 goto done; 436 goto done;
437 } 437 }
438 if ((cla = cyberflex_inq_class(fd)) < 0) { 438 if ((cla = cyberflex_inq_class(fd)) < 0) {
439 error("cyberflex_inq_class failed"); 439 error("cyberflex_inq_class failed");
440 goto done; 440 goto done;
@@ -446,21 +446,21 @@ do_upload(struct passwd *pw, int reader)
446 key_fid[0] = 0x00; 446 key_fid[0] = 0x00;
447 key_fid[1] = 0x12; 447 key_fid[1] = 0x12;
448 if (cyberflex_load_rsa_priv(fd, cla, key_fid, 5, 8*len, elements, 448 if (cyberflex_load_rsa_priv(fd, cla, key_fid, 5, 8*len, elements,
449 &r1, &r2) < 0) { 449 &sw) < 0) {
450 error("cyberflex_load_rsa_priv failed: %s", get_r1r2s(r1, r1)); 450 error("cyberflex_load_rsa_priv failed: %s", sectok_get_sw(sw));
451 goto done; 451 goto done;
452 } 452 }
453 if (r1 != 0x90 && r1 != 0x61) 453 if (!sectok_swOK(sw))
454 goto done; 454 goto done;
455 log("cyberflex_load_rsa_priv done"); 455 log("cyberflex_load_rsa_priv done");
456 key_fid[0] = 0x73; 456 key_fid[0] = 0x73;
457 key_fid[1] = 0x68; 457 key_fid[1] = 0x68;
458 if (cyberflex_load_rsa_pub(fd, cla, key_fid, len, elements[5], 458 if (cyberflex_load_rsa_pub(fd, cla, key_fid, len, elements[5],
459 &r1, &r2) < 0) { 459 &sw) < 0) {
460 error("cyberflex_load_rsa_pub failed: %s", get_r1r2s(r1, r1)); 460 error("cyberflex_load_rsa_pub failed: %s", sectok_get_sw(sw));
461 goto done; 461 goto done;
462 } 462 }
463 if (r1 != 0x90 && r1 != 0x61) 463 if (!sectok_swOK(sw))
464 goto done; 464 goto done;
465 log("cyberflex_load_rsa_pub done"); 465 log("cyberflex_load_rsa_pub done");
466 status = 0; 466 status = 0;
@@ -469,9 +469,10 @@ done:
469 if (prv) 469 if (prv)
470 key_free(prv); 470 key_free(prv);
471 for (i = 0; i < NUM_RSA_KEY_ELEMENTS; i++) 471 for (i = 0; i < NUM_RSA_KEY_ELEMENTS; i++)
472 xfree(elements[i]); 472 if (elements[i])
473 xfree(elements[i]);
473 if (fd != -1) 474 if (fd != -1)
474 scclose(fd); 475 sectok_close(fd);
475 exit(status); 476 exit(status);
476#endif 477#endif
477} 478}