OSDN Git Service

initial commit
[openbsd-octeon/openbsd-octeon.git] / src / lib / libsectok / cmdtab.c
1 /* $Id: cmdtab.c,v 1.7 2003/04/02 22:57:51 deraadt Exp $ */
2
3 /*
4 copyright 1999
5 the regents of the university of michigan
6 all rights reserved
7
8 permission is granted to use, copy, create derivative works 
9 and redistribute this software and such derivative works 
10 for any purpose, so long as the name of the university of 
11 michigan is not used in any advertising or publicity 
12 pertaining to the use or distribution of this software 
13 without specific, written prior authorization.  if the 
14 above copyright notice or any other identification of the 
15 university of michigan is included in any copy of any 
16 portion of this software, then the disclaimer below must 
17 also be included.
18
19 this software is provided as is, without representation 
20 from the university of michigan as to its fitness for any 
21 purpose, and without warranty by the university of 
22 michigan of any kind, either express or implied, including 
23 without limitation the implied warranties of 
24 merchantability and fitness for a particular purpose. the 
25 regents of the university of michigan shall not be liable 
26 for any damages, including special, indirect, incidental, or 
27 consequential damages, with respect to any claim arising 
28 out of or in connection with the use of the software, even 
29 if it has been or is hereafter advised of the possibility of 
30 such damages.
31 */
32
33 /*
34  * Translate from apdu P1 to apdu name
35  */
36
37 #ifdef __palmos__
38 #include <Common.h>
39 #include <System/SysAll.h>
40 #include <System/Unix/sys_types.h>
41 #include <System/Unix/unix_stdlib.h>
42 #include <System/Unix/unix_string.h>
43 #include <UI/UIAll.h>
44 #include "field.h"
45 #else
46 #include <stdio.h>
47 #endif
48
49 #include "sectok.h"
50
51 static struct cmd {
52     int ins, inout;
53     char *name;
54 } cmdtab[] = {
55     /* 7816-4 */
56     {0x0e, 0, "erase binary"},
57     {0x20, 0, "verify"},
58     {0x70, 0, "manage channel"},
59     {0x82, 0, "ext auth"},
60     {0x84, 1, "get challenge"},
61     {0x88, 0, "int auth"},
62     {0xa4, 0, "select"},
63     {0xb0, 1, "read binary"},
64     {0xb2, 1, "read record"},
65     {0xc0, 1, "get response"},
66     {0xc2, 0, "envelope"},
67     {0xca, 0, "get data"},
68     {0xd0, 0, "write binary"},
69     {0xd2, 0, "write record"},
70     {0xd6, 0, "update binary"},
71     {0xda, 0, "put data"},
72     {0xdc, 0, "update record"},
73     {0xe2, 0, "append record"},
74     /* Webcard */
75     {0xfe, 0, "ip7816"},
76     /* Cyberflex Access */
77     {0x04, 0, "invalidate"},
78     {0x08, 0, "manage instance"},
79     {0x0a, 0, "manage program"},
80     {0x0c, 0, "execute method"},
81     {0x22, 0, "logout all"},
82     {0x24, 0, "change PIN"},
83     {0x2a, 0, "verify key"},
84     {0x2c, 0, "unblock"},
85     {0x44, 0, "rehabilitate"},
86     {0xa8, 1, "directory"},
87     {0xe0, 0, "create"},
88     {0xe4, 0, "delete"},
89     {0xfa, 0, "change java atr"},
90     {0xfc, 0, "change acl"},
91 /*    {0xfe, 1, "get acl"},*/
92     /* GSM */
93     {0x26, 0, "disable PIN"},
94     {0x28, 0, "enable PIN"},
95     {0x30, 0, "decrease"},
96     {0x32, 0, "increase"},
97     {0xf2, 1, "get status"},
98     /* Visa cash / open platform */
99     {0x50, 0, "init update"},
100     {0x80, 0, "install default app"},
101 #ifdef PAYFLEX
102     /* Payflex */
103     {0x52, 0, "credit"},
104     {0x54, 0, "debit"},
105     {0x56, 0, "replace debit"},
106     {0x58, 0, "token debit"},
107     {0x5a, 0, "token purchase"},
108     {0x5c, 0, "update currency"},
109     {0x8a, 0, "cert credit"},
110     {0x8c, 0, "cert debit"},
111     {0x8e, 0, "generate diversified key"},
112     {0xd8, 0, "load key"},
113     {0xde, 0, "update max amount"},
114     {0xf4, 0, "load exe"},
115 #endif /* PAYFLEX */
116     {0, 0, NULL}
117 };
118
119 char *
120 sectok_get_ins(int ins)
121 {
122     struct cmd *p;
123     static char name[32];
124
125     for (p = &cmdtab[0]; p->name; p++)
126         if (p->ins == ins)
127             break;
128
129     if (!p->name) {
130         snprintf(name, sizeof name, "unknown ins %02x", ins);
131         return name;
132     }
133
134     return p->name;
135 }