FreeCalypso > hg > fc-pcsc-tools
comparison libcommon/pinentry.c @ 3:e9e8ce12f5a5
encode_pin_entry() factored out into libcommon
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 11 Feb 2021 23:11:57 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:5b69dfc789f2 | 3:e9e8ce12f5a5 |
---|---|
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 } |