comparison libutil/pinentry.c @ 157:f064dbcc5f41

libutil split from libcommon
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 26 Feb 2021 20:19:58 +0000
parents libcommon/pinentry.c@e9e8ce12f5a5
children
comparison
equal deleted inserted replaced
156:5f1f3f6fd865 157:f064dbcc5f41
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 }