Changeset 438cf4b in OpenSC
- Timestamp:
- 06/02/11 19:06:43 (12 months ago)
- Branches:
- master, staging
- Children:
- a479c36
- Parents:
- da0a77b
- git-author:
- vtarasov <vtarasov@…> (06/02/11 19:06:43)
- git-committer:
- vtarasov <vtarasov@…> (06/02/11 19:06:43)
- Location:
- src
- Files:
-
- 3 edited
-
libopensc/card-rtecp.c (modified) (1 diff)
-
pkcs15init/pkcs15-rtecp.c (modified) (4 diffs)
-
pkcs15init/rutoken_ecp.profile (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libopensc/card-rtecp.c
r661cc0d r438cf4b 487 487 int r; 488 488 489 (void)type, (void)puk, (void)puklen , (void)newref, (void)newlen; /* no warning */489 (void)type, (void)puk, (void)puklen; /* no warning */ 490 490 assert(card && card->ctx); 491 491 492 sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x2C, 0x03, ref_qualifier); 492 493 r = sc_transmit_apdu(card, &apdu); 493 494 SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); 494 495 r = sc_check_sw(card, apdu.sw1, apdu.sw2); 496 SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Unblock card failed"); 497 498 if (newref && newlen) { 499 u8 tmp[2], buf[SC_MAX_APDU_BUFFER_SIZE]; 500 u8 *p = buf; 501 502 tmp[0] = (newlen >> 8) & 0xFF; 503 tmp[1] = newlen & 0xFF; 504 sc_asn1_put_tag(0x80, tmp, sizeof(tmp), p, sizeof(buf) - (p - buf), &p); 505 r = sc_asn1_put_tag(0xA5, newref, newlen, p, sizeof(buf) - (p - buf), &p); 506 SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Invalid new PIN length"); 507 508 sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x24, 0x01, ref_qualifier); 509 apdu.lc = p - buf; 510 apdu.data = buf; 511 apdu.datalen = p - buf; 512 513 r = sc_transmit_apdu(card, &apdu); 514 SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); 515 r = sc_check_sw(card, apdu.sw1, apdu.sw2); 516 SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Set PIN failed"); 517 } 518 495 519 SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r); 496 520 } -
src/pkcs15init/pkcs15-rtecp.c
r5e50a14 r438cf4b 169 169 sc_context_t *ctx; 170 170 sc_pkcs15_pin_info_t *pin_info; 171 sc_file_t *file ;171 sc_file_t *file = NULL; 172 172 /* GCHV min-length Flags Attempts Reserve */ 173 173 unsigned char prop[] = { 0x01, '?', 0x01, '?', 0, 0 }; 174 174 /* AccessMode Unblock Change Delete */ 175 175 unsigned char sec[15] = { 0x43, '?', '?', 0, 0, 0, 0, 0xFF }; 176 int r; 176 char pin_sname[0x10]; 177 int r, reset_by_sopin = 0; 177 178 178 179 (void)puk; /* no warning */ … … 183 184 ctx = p15card->card->ctx; 184 185 SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE); 186 185 187 if (puk_len != 0) 186 188 { … … 197 199 return SC_ERROR_NOT_SUPPORTED; 198 200 } 201 202 snprintf(pin_sname, sizeof(pin_sname), "CHV%i", pin_info->reference); 203 if (pin_info->reference == RTECP_USER_PIN_REF) { 204 r = sc_profile_get_file(profile, pin_sname, &file); 205 if (!r) { 206 const struct sc_acl_entry *acl = NULL; 207 208 r = sc_pkcs15init_fixup_file(profile, p15card, file); 209 SC_TEST_RET(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, r, "Cannot fixup the ACLs of PIN file"); 210 211 acl = sc_file_get_acl_entry(file, SC_AC_OP_PIN_RESET); 212 if (acl && acl->method == SC_AC_CHV && acl->key_ref == RTECP_SO_PIN_REF) { 213 sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Allow reset of User PIN with SoPIN\n"); 214 reset_by_sopin = 1; 215 } 216 sc_file_free(file); 217 } 218 } 219 199 220 file = sc_file_new(); 200 221 if (!file) … … 204 225 assert(sizeof(sec)/sizeof(sec[0]) > 2); 205 226 sec[1] = (pin_info->reference == RTECP_SO_PIN_REF) ? 0xFF : RTECP_SO_PIN_REF; 206 sec[2] = (unsigned char)pin_info->reference ;227 sec[2] = (unsigned char)pin_info->reference | (reset_by_sopin ? RTECP_SO_PIN_REF : 0); 207 228 r = sc_file_set_sec_attr(file, sec, sizeof(sec)); 208 229 if (r == SC_SUCCESS) -
src/pkcs15init/rutoken_ecp.profile
r659db6f r438cf4b 24 24 # Have a lastUpdate field in the EF(TokenInfo)? 25 25 do-last-update = yes; 26 27 pkcs15-id-style = mozilla; 26 28 } 27 29 … … 46 48 auth-id = 2; 47 49 reference = 2; 48 attempts = 10;49 min-length = 8;50 attempts = 5; 51 min-length = 4; 50 52 max-length = 32; 51 53 flags = case-sensitive, initialized; … … 70 72 71 73 filesystem { 74 EF CHV2 { 75 file-id = 0002; 76 ACL = *=NEVER, UPDATE=$SOPIN, PIN-RESET=$SOPIN; 77 } 72 78 73 79 DF MF {
Note: See TracChangeset
for help on using the changeset viewer.
