diff options
author | Jim Rees <rees@cvs.openbsd.org> | 2001-08-02 17:09:20 +0000 |
---|---|---|
committer | Jim Rees <rees@cvs.openbsd.org> | 2001-08-02 17:09:20 +0000 |
commit | aefe568b0d71b6a07fe087eb9a30b4a941656db1 (patch) | |
tree | 0f6b8cbea694ad60e5bc313252e3dbf9555a79cb /usr.bin | |
parent | 68d6b9fe3cbf15afeeed672a3e917bb2f525c9a8 (diff) |
Mods for PalmOS
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sectok/cmds.c | 50 | ||||
-rw-r--r-- | usr.bin/sectok/cyberflex.c | 42 | ||||
-rw-r--r-- | usr.bin/sectok/sc.h | 7 |
3 files changed, 80 insertions, 19 deletions
diff --git a/usr.bin/sectok/cmds.c b/usr.bin/sectok/cmds.c index 1c1fc307ab6..0246c6c8e17 100644 --- a/usr.bin/sectok/cmds.c +++ b/usr.bin/sectok/cmds.c @@ -1,4 +1,4 @@ -/* $Id: cmds.c,v 1.14 2001/07/27 14:13:08 rees Exp $ */ +/* $Id: cmds.c,v 1.15 2001/08/02 17:09:18 rees Exp $ */ /* * Smartcard commander. @@ -35,21 +35,34 @@ if it has been or is hereafter advised of the possibility of such damages. */ +#ifdef __palmos__ +#pragma pack(2) +#include <Common.h> +#include <System/SysAll.h> +#include <UI/UIAll.h> +#include <System/Unix/sys_types.h> +#include <System/Unix/unix_stdio.h> +#include <System/Unix/unix_stdlib.h> +#include <System/Unix/unix_string.h> +#include <string.h> +#include "getopt.h" +#include "sectok.h" +#include "field.h" +#else #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <signal.h> #include <string.h> #include <sectok.h> +#endif #include "sc.h" +#define MAXFILELEN 0xffff #define CARDIOSIZE 200 -struct { - char *cmd, *help; - int (*action) (int ac, char *av[]); -} dispatch_table[] = { +struct dispatchtable dispatch_table[] = { /* Non-card commands */ { "help", "[command]", help }, { "?", "[command]", help }, @@ -64,7 +77,9 @@ struct { { "isearch", "", isearch }, { "class", "[ class ]", class }, { "read", "[ -x ] filesize", dread }, +#ifndef __palmos__ { "write", "input-filename", dwrite }, +#endif /* Cyberflex commands */ { "ls", "[ -l ]", ls }, @@ -75,10 +90,14 @@ struct { { "jatr", "", jatr }, { "jdata", "", jdata }, { "login", "[ -d ] [ -k keyno ] [ -v ] [ -x hex-aut0 ]", jlogin }, +#ifndef __palmos__ { "jaut", "", jaut }, { "jload", "[ -p progID ] [ -c contID ] [ -s cont_size ] [ -i inst_size ] [ -a aid ] [ -v ] filename", jload }, +#endif { "junload", "[ -p progID ] [ -c contID ]", junload }, +#ifndef __palmos__ { "setpass", "[ -d ] [ -x hex-aut0 ]", jsetpass }, +#endif { NULL, NULL, NULL } }; @@ -185,7 +204,11 @@ int dclose(int ac, char *av[]) int quit(int ac, char *av[]) { +#ifndef __palmos__ exit(0); +#else + return -1; +#endif } int apdu(int ac, char *av[]) @@ -321,8 +344,9 @@ int class(int ac, char *av[]) int dread(int ac, char *av[]) { - int i, n, col = 0, p3, fsize, xflag = 0, sw; - unsigned char buf[CARDIOSIZE]; + int i, n, col = 0, fsize, xflag = 0, sw; + unsigned int p3; + unsigned char buf[CARDIOSIZE+1]; optind = optreset = 1; @@ -344,7 +368,7 @@ int dread(int ac, char *av[]) if (fd < 0 && reset(0, NULL) < 0) return -1; - for (p3 = 0; fsize && p3 < 100000; p3 += n) { + for (p3 = 0; fsize && p3 < MAXFILELEN; p3 += n) { n = (fsize < CARDIOSIZE) ? fsize : CARDIOSIZE; n = sectok_apdu(fd, cla, 0xb0, p3 >> 8, p3 & 0xff, 0, NULL, n, buf, &sw); if (!sectok_swOK(sw)) { @@ -357,8 +381,14 @@ int dread(int ac, char *av[]) if (col++ % 16 == 15) printf("\n"); } - } else + } else { +#ifdef __palmos__ + buf[n] = '\0'; + printf("%s", buf); +#else fwrite(buf, 1, n, stdout); +#endif + } fsize -= n; } @@ -368,6 +398,7 @@ int dread(int ac, char *av[]) return 0; } +#ifndef __palmos__ int dwrite(int ac, char *av[]) { int n, p3, sw; @@ -401,3 +432,4 @@ int dwrite(int ac, char *av[]) return (n ? 0 : -1); } +#endif diff --git a/usr.bin/sectok/cyberflex.c b/usr.bin/sectok/cyberflex.c index 0f12c75e652..247398256bc 100644 --- a/usr.bin/sectok/cyberflex.c +++ b/usr.bin/sectok/cyberflex.c @@ -1,4 +1,4 @@ -/* $Id: cyberflex.c,v 1.17 2001/07/29 21:43:48 rees Exp $ */ +/* $Id: cyberflex.c,v 1.18 2001/08/02 17:09:18 rees Exp $ */ /* copyright 1999, 2000 @@ -30,6 +30,7 @@ if it has been or is hereafter advised of the possibility of such damages. */ +#ifndef __palmos__ #include <sys/types.h> #include <unistd.h> #include <stdlib.h> @@ -48,6 +49,19 @@ such damages. #else /* __linux */ #include <sha1.h> #endif +#else +#pragma pack(2) +#include <Common.h> +#include <System/SysAll.h> +#include <System/Unix/sys_types.h> +#include <System/Unix/unix_stdio.h> +#include <System/Unix/unix_stdlib.h> +#include <System/Unix/unix_string.h> +#include <UI/UIAll.h> +#include "getopt.h" +#include "field.h" +#define NO_SHA +#endif #include <sectok.h> #include "sc.h" @@ -70,14 +84,19 @@ static unsigned char AUT0[20]; int aut0_vfyd; +static void print_acl(int isdir, unsigned char *acl); + +#ifndef __palmos__ /* default signed applet key of Cyberflex Access */ static des_cblock app_key = {0x6A, 0x21, 0x36, 0xF5, 0xD8, 0x0C, 0x47, 0x83}; - -static void print_acl(int isdir, unsigned char *acl); +#endif static int get_AUT0(int ac, char *av[], char *prompt, int confirm, unsigned char *digest) { +#ifdef NO_SHA + memcpy(digest, DFLTAUT0, sizeof DFLTAUT0); +#else int i, dflag = 0, xflag = 0; SHA1_CTX ctx; char *s, *s2; @@ -88,7 +107,7 @@ get_AUT0(int ac, char *av[], char *prompt, int confirm, unsigned char *digest) while ((i = getopt(ac, av, "dk:x:")) != -1) { switch (i) { case 'd': - memmove(digest, DFLTAUT0, sizeof DFLTAUT0); + memcpy(digest, DFLTAUT0, sizeof DFLTAUT0); dflag = 1; break; case 'x': @@ -118,6 +137,7 @@ get_AUT0(int ac, char *av[], char *prompt, int confirm, unsigned char *digest) bzero(s, strlen(s)); SHA1Final(digest, &ctx); } +#endif return 0; } @@ -219,7 +239,7 @@ int jatr(int ac, char *av[]) n += sectok_parse_input(av[1], &buf[n], 15); } else { /* no historical bytes given, use default */ - memmove(&buf[n], DFLTATR, sizeof DFLTATR); + memcpy(&buf[n], DFLTATR, sizeof DFLTATR); n += sizeof DFLTATR; } buf[0] |= ((n - 2) & 0xf); @@ -349,7 +369,7 @@ sectok_fmt_aidname(char *aidname, int aidlen, unsigned char *aid) break; } if (istext) { - memmove(aidname, aid, aidlen); + memcpy(aidname, aid, aidlen); aidname[aidlen] = '\0'; if (aid[0] == 0xfc) aidname[0] = '#'; @@ -571,6 +591,7 @@ int jdelete(int ac, char *av[]) unsigned char progID[2], contID[2]; +#ifndef __palmos__ int jload(int ac, char *av[]) { char *cp, *filename, progname[5], contname[5]; @@ -776,7 +797,7 @@ int jload(int ac, char *av[]) data[8] = inst_size & 0xff; /* instance size 0x0400 (1024) byte, lower */ data[9] = 0x00; /* AID length 0x0005, upper */ data[10] = aidlen; /* AID length 0x0005, lower */ - memmove(&data[11], aid, aidlen); + memcpy(&data[11], aid, aidlen); sectok_apdu(fd, cla, 0x0c, 0x13, 0, 11 + aidlen, data, 0, NULL, &sw); if (!sectok_swOK(sw)) { @@ -788,6 +809,7 @@ int jload(int ac, char *av[]) /* That's it! :) */ return 0; } +#endif int junload(int ac, char *av[]) { @@ -796,9 +818,9 @@ int junload(int ac, char *av[]) /* Use old defaults */ if (progID[0] == 0) - memmove(progID, "ww", 2); + memcpy(progID, "ww", 2); if (contID[0] == 0) - memmove(contID, "wx", 2); + memcpy(contID, "wx", 2); optind = optreset = 1; @@ -861,6 +883,7 @@ int junload(int ac, char *av[]) return 0; } +#ifndef __palmos__ #define DELIMITER " :\t\n" #define KEY_BLOCK_SIZE 14 @@ -1046,3 +1069,4 @@ int cyberflex_load_rsa(int fd, unsigned char *buf) free(key_elements[i]); return 0; } +#endif diff --git a/usr.bin/sectok/sc.h b/usr.bin/sectok/sc.h index 64032ef6bd8..36537d7ab10 100644 --- a/usr.bin/sectok/sc.h +++ b/usr.bin/sectok/sc.h @@ -1,4 +1,4 @@ -/* $Id: sc.h,v 1.7 2001/07/26 16:10:01 rees Exp $ */ +/* $Id: sc.h,v 1.8 2001/08/02 17:09:19 rees Exp $ */ /* * Smartcard commander. @@ -38,6 +38,11 @@ such damages. extern int port, fd, cla, aut0_vfyd; extern FILE *cmdf; +extern struct dispatchtable { + char *cmd, *help; + int (*action) (int ac, char *av[]); +} dispatch_table[]; + int dispatch(int ac, char *av[]); int help(int ac, char *av[]); int reset(int ac, char *av[]); |