2 Copyright (c) 2013 Eugene Crosser
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
12 1. The origin of this software must not be misrepresented; you must
13 not claim that you wrote the original software. If you use this
14 software in a product, an acknowledgment in the product documentation
15 would be appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must
18 not be misrepresented as being the original software.
20 3. This notice may not be removed or altered from any source
33 static void usage(const char *const cmd)
36 "usage: %s [-o backend:name=value] ... \"challenge\"\n",
40 int main(int argc, char *argv[])
42 unsigned char chal[64];
44 unsigned char rbuf[20];
45 size_t rsize = sizeof(rbuf);
50 while ((c = getopt(argc, argv, "ho:")) != -1) switch (c) {
55 if (pcsc_option(optarg)) {
56 fprintf(stderr, "Option \"%s\" bad\n", optarg);
64 if (optind != (argc - 1)) {
69 csize = strlen(argv[optind]);
70 if (csize > sizeof(chal)) {
71 fprintf(stderr, "Challenge longer than %d, cannot do that\n",
76 printf("\nIf the key is set to \"Jefe\" like this:\n"
77 "$ ykpersonalize -2 -o chal-resp -o chal-hmac -o hmac-lt64 \\\n"
78 "\t-a 4a65666500000000000000000000000000000000\n"
79 "and the challenge is \"what do ya want for nothing?\"\n"
81 "\"ef fc df 6a e5 eb 2f a2 d2 74 16 d5 f1 84 df 9c 25 9a 7c 79\"\n");
83 memset(chal, 0x00, sizeof(chal));
84 memcpy(chal, argv[optind], csize);
86 memset(rbuf, 0xFE, sizeof(rbuf));
87 rc = pcsc_cr(chal, csize, rbuf, &rsize);
88 printf("rc=%ld (%s) rsize=%d:", rc, pcsc_errstr(rc), (int)rsize);
89 for (i = 0; i < rsize; i++) printf(" %02x", rbuf[i]);