Overview
Comment: | Fixed issues with PIN handling |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | 780bd59a252078419f62109ee749437fd198b8a7 |
User & Date: | rkeene on 2010-05-13 18:24:24 |
Other Links: | manifest | tags |
Context
2010-05-13
| ||
18:26 | Corrected warning check-in: ebb5a279f5 user: rkeene tags: trunk | |
18:24 | Fixed issues with PIN handling check-in: 780bd59a25 user: rkeene tags: trunk | |
18:22 | Updated to use unified return codes check-in: 123c71d946 user: rkeene tags: trunk | |
Changes
Modified test.c from [dcf2fb997e] to [a3fe09560a].
106 106 CK_ULONG byte_idx; 107 107 CK_UTF8CHAR user_pin[1024], *pucValue; 108 108 CK_OBJECT_CLASS objectClass; 109 109 CK_BYTE signature[1024], encrypted_buf[16384], decrypted_buf[16384]; 110 110 CK_ULONG signature_len, encrypted_buflen, decrypted_buflen; 111 111 CK_MECHANISM mechanism = {CKM_RSA_PKCS, NULL, 0}; 112 112 CK_RV chk_rv; 113 + char *fgets_ret; 113 114 int i; 114 115 115 116 privateKeyObjects = malloc(sizeof(*privateKeyObjects) * 1024); 116 117 privateKeyObjects_root = privateKeyObjects; 117 118 for (i = 0; i < 1024; i++) { 118 119 privateKeyObjects[i] = CK_INVALID_HANDLE; 119 120 } ................................................................................ 261 262 printf("\n"); 262 263 } 263 264 } 264 265 265 266 chk_rv = C_OpenSession(slots[0], CKF_SERIAL_SESSION, NULL, NULL, &hSession); 266 267 if (chk_rv == CKR_OK) { 267 268 if ((tokenInfo.flags & CKF_LOGIN_REQUIRED) == CKF_LOGIN_REQUIRED) { 268 - printf("** ENTER PIN: "); 269 - fflush(stdout); 269 + fgets_ret = NULL; 270 270 271 - fgets((char *) user_pin, sizeof(user_pin), stdin); 272 - while (user_pin[strlen((char *) user_pin) - 1] < ' ') { 273 - user_pin[strlen((char *) user_pin) - 1] = '\0'; 271 + while (fgets_ret == NULL) { 272 + printf("** ENTER PIN: "); 273 + fflush(stdout); 274 + 275 + fgets_ret = fgets((char *) user_pin, sizeof(user_pin), stdin); 276 + } 277 + 278 + if (strlen(user_pin) >= 1) { 279 + while (user_pin[strlen((char *) user_pin) - 1] < ' ') { 280 + user_pin[strlen((char *) user_pin) - 1] = '\0'; 281 + } 274 282 } 275 283 276 284 chk_rv = C_Login(hSession, CKU_USER, user_pin, strlen((char *) user_pin)); 277 285 } else { 278 286 chk_rv = C_Login(hSession, CKU_USER, NULL, 0); 279 287 } 280 288 if (chk_rv == CKR_OK) {