clear test results
[pam_pcsc_cr.git] / test_cr.c
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <unistd.h>
7 #include <string.h>
8 #include "pcsc_cr.h"
9
10 unsigned char chal[] = {
11 0x0f,0x65,0xd1,0x3a,0xfe,0xcb,0xc4,0xb9,0x52,0xb1,0x60,0xcf,0xe8,0x55,0x6a,0xdd,0xfb,0xef,0xf6,0x55,0x83,0x4c,0x8d,0xea,0x38,0xea,0x3b,0x26,0xf7,0x0a,0xe8,0x0d,0x31,0x38,0xee,0x16,0x5d,0xab,0x8b,0x7f,0xf0,0x1b,0xe3,0xbe,0xd8,0x4b,0x6e,0x44,0x42,0x8d,0x0f,0xc1,0x3b,0x23,0xea,0xfe,0xc0,0x68,0xc1,0x0f,0x60,0x6c,0xf4};
12
13 static void usage(const char const *cmd)
14 {
15         fprintf(stderr, "usage: %s [-o backend:name=value] ...\n", cmd);
16 }
17
18 int main(int argc, char *argv[])
19 {
20         unsigned char rbuf[20];
21         int rsize = sizeof(rbuf);
22         int i;
23         long rc;
24         int c;
25
26         while ((c = getopt(argc, argv, "ho:")) != -1) switch (c) {
27         case 'h':
28                 usage(argv[0]);
29                 exit(0);
30         case 'o':
31                 if (pcsc_option(optarg)) {
32                         fprintf(stderr, "Option \"%s\" bad\n", optarg);
33                         exit(1);
34                 }
35                 break;
36         default:
37                 usage(argv[0]);
38                 exit(1);
39         }
40
41         memset(rbuf, 0xFE, sizeof(rbuf));
42         rc = pcsc_cr(chal, sizeof(chal), rbuf, &rsize);
43         printf("rc=%ld (%s) rsize=%d:", rc, pcsc_errstr(rc), rsize);
44         for (i = 0; i < rsize; i++) printf(" %02x", rbuf[i]);
45         printf("\n");
46         return rc;
47 }