=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sectok/Attic/cyberflex.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- src/usr.bin/sectok/Attic/cyberflex.c 2001/07/17 15:16:46 1.6 +++ src/usr.bin/sectok/Attic/cyberflex.c 2001/07/17 17:10:44 1.7 @@ -1,4 +1,4 @@ -/* $Id: cyberflex.c,v 1.6 2001/07/17 15:16:46 rees Exp $ */ +/* $Id: cyberflex.c,v 1.7 2001/07/17 17:10:44 rees Exp $ */ /* copyright 1999, 2000 @@ -60,6 +60,7 @@ static unsigned char key_fid[] = {0x00, 0x11}; static unsigned char DFLTATR[] = {0x81, 0x10, 0x06, 0x01}; static unsigned char DFLTAUT0[] = {0xad, 0x9f, 0x61, 0xfe, 0xfa, 0x20, 0xce, 0x63}; +static unsigned char AUT0[20]; int aut0_vfyd; @@ -128,11 +129,16 @@ int jlogin(int ac, char *av[]) { int i, vflag = 0, sw; - unsigned char AUT0[20]; - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; + cla = cyberflex_inq_class(fd); + if (cla < 0) { + printf("can't determine Cyberflex application class\n"); + return -1; + } + optind = optreset = 1; while ((i = getopt(ac, av, "dvx:")) != -1) { @@ -146,8 +152,6 @@ if (get_AUT0(ac, av, "Enter AUT0 passphrase: ", AUT0) < 0) return -1; - cla = cyberflex_inq_class(fd); - if (vflag) { printf("Class %02x\n", cla); for (i = 0; i < 8; i++) @@ -188,8 +192,8 @@ } } - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; if (!aut0_vfyd) jaut(0, NULL); @@ -207,8 +211,8 @@ unsigned char buf[64]; int n = 0, sw; - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; buf[n++] = 0x90; buf[n++] = 0x94; /* TA1 */ @@ -237,8 +241,8 @@ unsigned char buf[32]; int i, sw; - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; sectok_apdu(fd, cla, 0xca, 0, 1, 0, NULL, 0x16, buf, &sw); if (sectok_swOK(sw)) { @@ -268,8 +272,8 @@ char ftype[32], fname[6]; unsigned char buf[JDIRSIZE]; - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; for (p2 = 0; ; p2++) { if (sectok_apdu(fd, cla, 0xa8, 0, p2, 0, NULL, JDIRSIZE, buf, &sw) < 0) @@ -311,8 +315,8 @@ sectok_parse_fname(av[1], fid); sscanf(av[2], "%d", &fsize); - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; if (!aut0_vfyd) jaut(0, NULL); @@ -336,8 +340,8 @@ sectok_parse_fname(av[1], fid); - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; if (!aut0_vfyd) jaut(0, NULL); @@ -423,8 +427,8 @@ if (analyze_load_options(ac, av) < 0) return -1; - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; if (!aut0_vfyd) jaut(0, NULL); @@ -588,8 +592,8 @@ if (analyze_load_options(ac, av) < 0) return -1; - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; if (!aut0_vfyd) jaut(0, NULL); @@ -638,8 +642,8 @@ if (analyze_load_options(ac, av) < 0) return -1; - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; printf ("select applet\n"); printf ("AID "); @@ -672,8 +676,8 @@ { int sw; - if (fd < 0) - reset(0, NULL); + if (fd < 0 && reset(0, NULL) < 0) + return -1; sectok_apdu(fd, cla, 0xa4, 0x04, 0, 0, NULL, 0, NULL, &sw); if (!sectok_swOK(sw)) { @@ -732,7 +736,7 @@ /* Now let's do it. :) */ /* add the AUT0 */ - cyberflex_fill_key_block (data, 0, 1, DFLTAUT0); + cyberflex_fill_key_block (data, 0, 1, AUT0); /* add the applet sign key */ cyberflex_fill_key_block (data+KEY_BLOCK_SIZE, 5, 0, app_key);