Changeset 438cf4b in OpenSC


Ignore:
Timestamp:
06/02/11 19:06:43 (12 months ago)
Author:
vtarasov <vtarasov@…>
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)
Message:

RuToken?-ECP: profile option to allow the reset of User PIN with SoPIN

 http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016716.html

git-svn-id:  https://www.opensc-project.org/svnp/opensc/trunk@5542 c6295689-39f2-0310-b995-f0e70906c6a9

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/libopensc/card-rtecp.c

    r661cc0d r438cf4b  
    487487        int r; 
    488488 
    489         (void)type, (void)puk, (void)puklen, (void)newref, (void)newlen; /* no warning */ 
     489        (void)type, (void)puk, (void)puklen; /* no warning */ 
    490490        assert(card && card->ctx); 
     491 
    491492        sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x2C, 0x03, ref_qualifier); 
    492493        r = sc_transmit_apdu(card, &apdu); 
    493494        SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); 
    494495        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 
    495519        SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r); 
    496520} 
  • src/pkcs15init/pkcs15-rtecp.c

    r5e50a14 r438cf4b  
    169169        sc_context_t *ctx; 
    170170        sc_pkcs15_pin_info_t *pin_info; 
    171         sc_file_t *file; 
     171        sc_file_t *file = NULL; 
    172172        /*                        GCHV min-length Flags Attempts  Reserve */ 
    173173        unsigned char prop[]  = { 0x01,       '?', 0x01,     '?', 0, 0 }; 
    174174        /*                  AccessMode Unblock Change             Delete */ 
    175175        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; 
    177178 
    178179        (void)puk; /* no warning */ 
     
    183184        ctx = p15card->card->ctx; 
    184185        SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE); 
     186 
    185187        if (puk_len != 0) 
    186188        { 
     
    197199                return SC_ERROR_NOT_SUPPORTED; 
    198200        } 
     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 
    199220        file = sc_file_new(); 
    200221        if (!file) 
     
    204225        assert(sizeof(sec)/sizeof(sec[0]) > 2); 
    205226        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); 
    207228        r = sc_file_set_sec_attr(file, sec, sizeof(sec)); 
    208229        if (r == SC_SUCCESS) 
  • src/pkcs15init/rutoken_ecp.profile

    r659db6f r438cf4b  
    2424    # Have a lastUpdate field in the EF(TokenInfo)? 
    2525    do-last-update      = yes; 
     26 
     27    pkcs15-id-style     = mozilla; 
    2628} 
    2729 
     
    4648    auth-id     = 2; 
    4749    reference   = 2; 
    48     attempts    = 10; 
    49     min-length  = 8; 
     50    attempts    = 5; 
     51    min-length  = 4; 
    5052    max-length  = 32; 
    5153    flags       = case-sensitive, initialized; 
     
    7072 
    7173filesystem { 
     74    EF CHV2 { 
     75        file-id = 0002; 
     76        ACL     = *=NEVER, UPDATE=$SOPIN, PIN-RESET=$SOPIN; 
     77    } 
    7278 
    7379    DF MF { 
Note: See TracChangeset for help on using the changeset viewer.