FreeCalypso > hg > fc-sim-tools
comparison libutil/pinentry.c @ 8:34bbb0585cab
libutil: import from previous fc-pcsc-tools version
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Mar 2021 05:42:37 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:b25d4dfe5798 | 8:34bbb0585cab |
---|---|
1 #include <sys/types.h> | |
2 #include <ctype.h> | |
3 #include <stdio.h> | |
4 | |
5 encode_pin_entry(arg, dest) | |
6 char *arg; | |
7 u_char *dest; | |
8 { | |
9 unsigned n; | |
10 | |
11 n = 0; | |
12 while (*arg) { | |
13 if (!isdigit(*arg)) { | |
14 fprintf(stderr, | |
15 "error: PIN argument contains a non-digit character\n"); | |
16 return(-1); | |
17 } | |
18 if (n >= 8) { | |
19 fprintf(stderr, "error: PIN argument is too long\n"); | |
20 return(-1); | |
21 } | |
22 *dest++ = *arg++; | |
23 n++; | |
24 } | |
25 for (; n < 8; n++) | |
26 *dest++ = 0xFF; | |
27 return(0); | |
28 } |