Changeset 40cb1c9e in OpenSC


Ignore:
Timestamp:
06/14/11 12:00:18 (11 months ago)
Author:
Ludovic Rousseau <ludovic.rousseau+github@…>
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)
Message:

Merge remote branch 'upstream/master'

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/libopensc/pkcs15.h

    r226bfaa ra6b7743  
    7171 
    7272#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 */ 
    7678struct sc_pkcs15_pin_attributes { 
    7779        unsigned int  flags, type; 
     
    8082        u8  pad_char; 
    8183}; 
     84/* AuthKeyAttributes of the authKey authentication object */ 
    8285struct sc_pkcs15_authkey_attributes { 
    8386        int derived; 
    8487        struct sc_pkcs15_id skey_id; 
    8588}; 
     89/* BiometricAttributes of the biometricTemplate authentication object */ 
    8690struct sc_pkcs15_biometric_attributes { 
    8791        unsigned int flags; 
     
    9094}; 
    9195struct sc_pkcs15_auth_info { 
     96        /* CommonAuthenticationObjectAttributes */ 
    9297        struct sc_pkcs15_id  auth_id; 
     98 
     99        /* AuthObjectAttributes */ 
    93100        struct sc_path  path; 
    94101        unsigned auth_type; 
     
    98105                struct sc_pkcs15_authkey_attributes authkey; 
    99106        } attrs; 
     107 
     108        /* authentication method: CHV, SEN, SYMBOLIC, ... */ 
    100109        unsigned int  auth_method; 
     110 
    101111        int  tries_left, max_tries; 
    102112 }; 
  • src/pkcs11/framework-pkcs15.c

    rd888b3f rba64c55  
    14101410        auth_info = (sc_pkcs15_auth_info_t *) auth_obj->data; 
    14111411        return CKR_OK; 
     1412} 
     1413 
     1414static unsigned long 
     1415pkcs15_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; 
    14121424} 
    14131425 
     
    14941506                                bn = &gost->d;  
    14951507                        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;   
    14971523                default: 
    14981524                        /* ignore unknown attrs, or flag error? */ 
  • src/pkcs11/pkcs11-opensc.h

    rdd045ff r98630728  
    33 
    44/* 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) 
    511 
    612#endif 
  • src/pkcs15init/pkcs15-cardos.c

    rd888b3f r93cc9be  
    6363static int      do_cardos_extract_pubkey(sc_card_t *card, int nr, u8 tag, 
    6464                        sc_pkcs15_bignum_t *bn); 
     65static int      cardos_have_verifyrc_package(sc_card_t *card); 
    6566 
    6667/* Object IDs for PIN objects. 
     
    414415        struct tlv      tlv; 
    415416        unsigned int    attempts, minlen, maxlen; 
    416         int             r; 
     417        int             r, hasverifyrc; 
    417418 
    418419        if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN) 
     
    446447        tlv_next(&tlv, 0x85); 
    447448        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  */ 
    448453        tlv_add(&tlv, attempts & 0xf);  /* flags byte */ 
    449454        tlv_add(&tlv, CARDOS_ALGO_PIN); /* algorithm = pin-test */ 
     
    787792} 
    788793 
     794static 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 
    789844static struct sc_pkcs15init_operations sc_pkcs15init_cardos_operations = { 
    790845        cardos_erase, 
  • src/libopensc/reader-pcsc.c

    r44cf3d0 r8936901  
    10301030        unsigned int num_watch; 
    10311031        int r = SC_ERROR_INTERNAL; 
     1032        DWORD dwtimeout; 
    10321033 
    10331034        SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL); 
     
    11681169                /* Set the timeout if caller wants to time out */ 
    11691170                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); 
    11741177 
    11751178                if (rv == (LONG) SCARD_E_CANCELLED) { 
  • src/pkcs15init/pkcs15-lib.c

    rd888b3f r9027279  
    10661066} 
    10671067 
    1068 int 
     1068static int 
    10691069sc_pkcs15init_encode_prvkey_content(struct sc_pkcs15_card *p15card, struct sc_pkcs15_prkey *prvkey, 
    10701070                struct sc_pkcs15_object *object) 
Note: See TracChangeset for help on using the changeset viewer.