Changeset 76

Show
Ignore:
Timestamp:
06/20/06 11:00:36 (2 years ago)
Author:
jps
Message:

OpenSC.Tokend: PIN can be changed in KeyChain? Access. Provided by Yannick LEPLARD.

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/Makefile

    r75 r76  
    484484        -i opensc-pack/Info.plist -r opensc-pack/resources -d opensc-pack/Description.plist 
    485485        cp opensc-pack/InstallationCheck.strings OpenSC.pkg/Contents/Resources/English.lproj 
     486        cp opensc-pack/InstallationCheck.strings OpenSC.pkg/Contents/Resources 
    486487        touch package-opensc 
    487488 
  • trunk/opensc.tokend/OpenSC/OpenSCToken.cpp

    r44 r76  
    7272} 
    7373 
     74 
    7475void OpenSCToken::changePIN(int pinNum, 
    7576        const unsigned char *oldPin, size_t oldPinLength, 
     
    8081                CssmError::throwMe(CSSM_ERRCODE_SAMPLE_VALUE_NOT_SUPPORTED); 
    8182         
    82         if (oldPinLength < 0 || oldPinLength > 14 || 
    83                 newPinLength < 0 || newPinLength > 14) 
    84                 CssmError::throwMe(CSSM_ERRCODE_INVALID_SAMPLE_VALUE); 
    85          
     83  if( _changePIN( pinNum, oldPin, oldPinLength, newPin, newPinLength ) )  
     84  { 
     85                mLocked = false; 
     86        }  
     87  else  
     88  { 
     89                CssmError::throwMe(CSSM_ERRCODE_OPERATION_AUTH_DENIED); 
     90        } 
     91   
     92} 
     93                            
     94bool OpenSCToken:: _changePIN( int pinNum, 
     95                               const unsigned char *oldPin, size_t oldPinLength, 
     96                               const unsigned char *newPin, size_t newPinLength ) 
     97{ 
     98        otdLog("In OpenSCToken::_changePIN(), PIN num is: %d\n", pinNum); 
     99         
     100        int r, i, rv; 
     101        struct sc_pkcs15_object *objs[32]; 
     102   
     103        // pinNum -> AuthID 
     104        const sc_pkcs15_id_t *auth_id = getIdFromPinMap(pinNum); 
     105        if (auth_id == NULL) { 
     106                otdLog("  ERR: getIdFromPinMap(): no AuthID found for pinNum %d\n", pinNum); 
     107                CssmError::throwMe(CSSM_ERRCODE_INVALID_DATA); 
     108        } 
     109   
     110        // AuthID -> pin object  +  change pin 
     111        r = sc_pkcs15_get_objects(mScP15Card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32); 
     112        otdLog("  sc_pkcs15_get_objects(pin_id=%s): %d\n", sc_pkcs15_print_id(auth_id),  r); 
     113        if (r >= 0) { 
     114                for (i = 0; i < r; i++)  { 
     115                        sc_pkcs15_pin_info_t *pin_info = (sc_pkcs15_pin_info_t *) objs[i]->data; 
     116                        if (sc_pkcs15_compare_id(auth_id, &pin_info->auth_id)) { 
     117         
     118                                rv = sc_pkcs15_change_pin( mScP15Card, pin_info, oldPin, oldPinLength, newPin, newPinLength ); 
     119                                otdLog("  In OpenSCToken::sc_pkcs15_change_pin returned %d for pin %d\n", rv, pinNum ); 
     120                                if (rv==0)  
     121        { 
     122                                        cachePIN(pin_info, newPin, newPinLength); 
     123                                        return true; 
     124                                } 
     125                                else 
     126                                        return false; 
     127                        } 
     128                } 
     129        } 
     130        return false; 
    86131} 
    87132 
  • trunk/opensc.tokend/OpenSC/OpenSCToken.h

    r44 r76  
    7777        bool _verifyPIN(int pinNum, const unsigned char *pin, size_t pinLength); 
    7878 
     79  bool OpenSCToken:: _changePIN( int pinNum, 
     80                                 const unsigned char *oldPin, size_t oldPinLength, 
     81                                 const unsigned char *newPin, size_t newPinLength ); 
     82     
     83 
    7984        // To manipulate mPinMap 
    8085        void addToPinMap(const sc_pkcs15_id_t *id);