Changeset 40cb1c9e in OpenSC
- Timestamp:
- 06/14/11 12:00:18 (11 months ago)
- Branches:
- master, staging
- Children:
- ce2d3c0, 3b63bf3
- Parents:
- 8936901 (diff), a6b7743 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Ludovic Rousseau <ludovic.rousseau+github@…> (06/14/11 12:00:18)
- git-committer:
- Ludovic Rousseau <ludovic.rousseau+github@…> (06/14/11 12:00:18)
- Location:
- src
- Files:
-
- 6 edited
-
libopensc/pkcs15.h (modified) (4 diffs)
-
pkcs11/framework-pkcs15.c (modified) (2 diffs)
-
pkcs11/pkcs11-opensc.h (modified) (1 diff)
-
pkcs15init/pkcs15-cardos.c (modified) (4 diffs)
-
libopensc/reader-pcsc.c (modified) (2 diffs)
-
pkcs15init/pkcs15-lib.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/libopensc/pkcs15.h
r226bfaa ra6b7743 71 71 72 72 #define SC_PKCS15_PIN_AUTH_TYPE_PIN 0 73 #define SC_PKCS15_PIN_AUTH_TYPE_AUTH_KEY 1 74 #define SC_PKCS15_PIN_AUTH_TYPE_SM_KEY 2 75 73 #define SC_PKCS15_PIN_AUTH_TYPE_BIOMETRIC 1 74 #define SC_PKCS15_PIN_AUTH_TYPE_AUTH_KEY 2 75 #define SC_PKCS15_PIN_AUTH_TYPE_SM_KEY 3 76 77 /* PinAttributes as they defined in PKCS#15 v1.1 for PIN authentication object */ 76 78 struct sc_pkcs15_pin_attributes { 77 79 unsigned int flags, type; … … 80 82 u8 pad_char; 81 83 }; 84 /* AuthKeyAttributes of the authKey authentication object */ 82 85 struct sc_pkcs15_authkey_attributes { 83 86 int derived; 84 87 struct sc_pkcs15_id skey_id; 85 88 }; 89 /* BiometricAttributes of the biometricTemplate authentication object */ 86 90 struct sc_pkcs15_biometric_attributes { 87 91 unsigned int flags; … … 90 94 }; 91 95 struct sc_pkcs15_auth_info { 96 /* CommonAuthenticationObjectAttributes */ 92 97 struct sc_pkcs15_id auth_id; 98 99 /* AuthObjectAttributes */ 93 100 struct sc_path path; 94 101 unsigned auth_type; … … 98 105 struct sc_pkcs15_authkey_attributes authkey; 99 106 } attrs; 107 108 /* authentication method: CHV, SEN, SYMBOLIC, ... */ 100 109 unsigned int auth_method; 110 101 111 int tries_left, max_tries; 102 112 }; -
src/pkcs11/framework-pkcs15.c
rd888b3f rba64c55 1410 1410 auth_info = (sc_pkcs15_auth_info_t *) auth_obj->data; 1411 1411 return CKR_OK; 1412 } 1413 1414 static unsigned long 1415 pkcs15_check_bool_cka(CK_ATTRIBUTE_PTR attr, unsigned long flag) 1416 { 1417 if (attr->ulValueLen != sizeof(CK_BBOOL) || !attr->pValue) 1418 return 0; 1419 1420 if (*((CK_BBOOL *)attr->pValue)) 1421 return flag; 1422 1423 return 0; 1412 1424 } 1413 1425 … … 1494 1506 bn = &gost->d; 1495 1507 break; 1496 1508 case CKA_SIGN: 1509 args.usage |= pkcs15_check_bool_cka(attr, SC_PKCS15_PRKEY_USAGE_SIGN); 1510 break; 1511 case CKA_SIGN_RECOVER: 1512 args.usage |= pkcs15_check_bool_cka(attr, SC_PKCS15_PRKEY_USAGE_SIGNRECOVER); 1513 break; 1514 case CKA_DECRYPT: 1515 args.usage |= pkcs15_check_bool_cka(attr, SC_PKCS15_PRKEY_USAGE_DECRYPT); 1516 break; 1517 case CKA_UNWRAP: 1518 args.usage |= pkcs15_check_bool_cka(attr, SC_PKCS15_PRKEY_USAGE_UNWRAP); 1519 break; 1520 case OPENSC_CKA_NON_REPUDIATION: 1521 args.usage |= pkcs15_check_bool_cka(attr, SC_PKCS15_PRKEY_USAGE_NONREPUDIATION); 1522 break; 1497 1523 default: 1498 1524 /* ignore unknown attrs, or flag error? */ -
src/pkcs11/pkcs11-opensc.h
rdd045ff r98630728 3 3 4 4 /* OpenSC specific extensions */ 5 /* 6 * In PKCS#11 there is no CKA_ attribute dedicated to the NON-REPUDIATION flag. 7 * We need this flag in PKCS#15/libopensc to make dinstinction between 8 * 'signature' and 'qualified signature' key slots. 9 */ 10 #define OPENSC_CKA_NON_REPUDIATION (CKA_VENDOR_DEFINED | 1UL) 5 11 6 12 #endif -
src/pkcs15init/pkcs15-cardos.c
rd888b3f r93cc9be 63 63 static int do_cardos_extract_pubkey(sc_card_t *card, int nr, u8 tag, 64 64 sc_pkcs15_bignum_t *bn); 65 static int cardos_have_verifyrc_package(sc_card_t *card); 65 66 66 67 /* Object IDs for PIN objects. … … 414 415 struct tlv tlv; 415 416 unsigned int attempts, minlen, maxlen; 416 int r ;417 int r, hasverifyrc; 417 418 418 419 if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN) … … 446 447 tlv_next(&tlv, 0x85); 447 448 tlv_add(&tlv, 0x02); /* options byte */ 449 hasverifyrc = cardos_have_verifyrc_package(card); 450 if (hasverifyrc == 1) 451 /* Use 9 byte OCI parameters to be able to set VerifyRC bit */ 452 tlv_add(&tlv, 0x04); /* options_2 byte with bit 2 set to return CurrentErrorCounter */ 448 453 tlv_add(&tlv, attempts & 0xf); /* flags byte */ 449 454 tlv_add(&tlv, CARDOS_ALGO_PIN); /* algorithm = pin-test */ … … 787 792 } 788 793 794 static int cardos_have_verifyrc_package(sc_card_t *card) 795 { 796 sc_apdu_t apdu; 797 u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; 798 int r; 799 const u8 *p = rbuf, *q; 800 size_t len, tlen = 0, ilen = 0; 801 802 sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x88); 803 apdu.resp = rbuf; 804 apdu.resplen = sizeof(rbuf); 805 apdu.lc = 0; 806 apdu.le = 256; 807 r = sc_transmit_apdu(card, &apdu); 808 SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); 809 810 if ((len = apdu.resplen) == 0) 811 /* looks like no package has been installed */ 812 return 0; 813 814 while (len != 0) { 815 p = sc_asn1_find_tag(card->ctx, p, len, 0xe1, &tlen); 816 if (p == NULL) 817 return 0; 818 if (card->type == SC_CARD_TYPE_CARDOS_M4_3) { 819 /* the verifyRC package on CardOS 4.3B use Manufacturer ID 0x01 */ 820 /* and Package Number 0x07 */ 821 q = sc_asn1_find_tag(card->ctx, p, tlen, 0x01, &ilen); 822 if (q == NULL || ilen != 4) 823 return 0; 824 if (q[0] == 0x07) 825 return 1; 826 } else if (card->type == SC_CARD_TYPE_CARDOS_M4_4) { 827 /* the verifyRC package on CardOS 4.4 use Manufacturer ID 0x03 */ 828 /* and Package Number 0x02 */ 829 q = sc_asn1_find_tag(card->ctx, p, tlen, 0x03, &ilen); 830 if (q == NULL || ilen != 4) 831 return 0; 832 if (q[0] == 0x02) 833 return 1; 834 } else { 835 return 0; 836 } 837 p += tlen; 838 len -= tlen + 2; 839 } 840 841 return 0; 842 } 843 789 844 static struct sc_pkcs15init_operations sc_pkcs15init_cardos_operations = { 790 845 cardos_erase, -
src/libopensc/reader-pcsc.c
r44cf3d0 r8936901 1030 1030 unsigned int num_watch; 1031 1031 int r = SC_ERROR_INTERNAL; 1032 DWORD dwtimeout; 1032 1033 1033 1034 SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL); … … 1168 1169 /* Set the timeout if caller wants to time out */ 1169 1170 if (timeout == -1) { 1170 timeout = INFINITE; 1171 } 1172 1173 rv = gpriv->SCardGetStatusChange(gpriv->pcsc_wait_ctx, timeout, rgReaderStates, num_watch); 1171 dwtimeout = INFINITE; 1172 } 1173 else 1174 dwtimeout = timeout; 1175 1176 rv = gpriv->SCardGetStatusChange(gpriv->pcsc_wait_ctx, dwtimeout, rgReaderStates, num_watch); 1174 1177 1175 1178 if (rv == (LONG) SCARD_E_CANCELLED) { -
src/pkcs15init/pkcs15-lib.c
rd888b3f r9027279 1066 1066 } 1067 1067 1068 int1068 static int 1069 1069 sc_pkcs15init_encode_prvkey_content(struct sc_pkcs15_card *p15card, struct sc_pkcs15_prkey *prvkey, 1070 1070 struct sc_pkcs15_object *object)
Note: See TracChangeset
for help on using the changeset viewer.
