22 #include "../../log.h"
56 , prompt(
"Please enter PIN for token '%s' or <enter> to cancel: ")
72 this->prompt = prompt;
90 printf( prompt.c_str(), certificate.token.label.c_str() );
93 while ( (c = _getch()) !=
'\r' )
98 if ( i >= pinMax-1 || iscntrl( c ) )
101 fputc(
'\a', stdout );
104 pin[i++] =
static_cast<char>(c);
105 fputc(
'*', stdout );
109 fputs(
"[EOF]\n", stdout );
110 SignException e( __FILE__, __LINE__,
"PIN acquisition canceled with [EOF].");
117 c = ( c << 4 ) | _getch();
118 if ( c != 0xE53 && c != 0xE4B && c != 0x053 && c != 0x04b )
121 fputc(
'\a', stdout );
130 fputc(
'\a', stdout );
134 fputs(
"\b \b", stdout );
138 fputs(
"^C\n", stdout );
139 SignException e( __FILE__, __LINE__,
"PIN acquisition canceled with ^C.");
146 fputs(
"^Z\n", stdout );
147 SignException e( __FILE__, __LINE__,
"PIN acquisition canceled with ^Z.");
153 fputc(
'\n', stdout );
154 printf( prompt.c_str(), certificate.token.label.c_str() );
159 fputc(
'\n', stdout );
163 char* pwd = getpass(
Log::format(prompt.c_str(), certificate.token.label.c_str()).c_str());
164 strncpy(pin, pwd, pinMax);
167 pin[pinMax-1] =
'\0';
169 std::string result(pin);
172 SignException e( __FILE__, __LINE__,
"PIN acquisition canceled.");