@@ -157,9 +157,9 @@ esteid_compute_signature(sc_card_t *card, const u8 *data, size_t datalen, u8 *ou
157157}
158158
159159static int
160- esteid_get_pin_remaining_tries (sc_card_t * card , int pin_reference )
160+ esteid_get_pin_info (sc_card_t * card , struct sc_pin_cmd_data * data )
161161{
162- const u8 get_pin_info [] = {0xA0 , 0x03 , 0x83 , 0x01 , pin_reference };
162+ const u8 get_pin_info [] = {0xA0 , 0x03 , 0x83 , 0x01 , data -> pin_reference };
163163 struct sc_apdu apdu ;
164164 u8 apdu_resp [SC_MAX_APDU_RESP_SIZE ];
165165 size_t taglen ;
@@ -173,26 +173,26 @@ esteid_get_pin_remaining_tries(sc_card_t *card, int pin_reference)
173173 const u8 * tag = sc_asn1_find_tag (card -> ctx , apdu_resp + 2 , apdu .resplen - 2 , 0xDF21 , & taglen );
174174 if (tag == NULL || taglen == 0 )
175175 LOG_FUNC_RETURN (card -> ctx , SC_ERROR_INTERNAL );
176- return tag [0 ];
176+ data -> pin1 .tries_left = tag [0 ];
177+ data -> pin1 .max_tries = -1 ; // "no support, which means the one set in PKCS#15 emulation sticks
178+ data -> pin1 .logged_in = SC_PIN_STATE_UNKNOWN ;
179+ tag += taglen ;
180+ tag = sc_asn1_find_tag (card -> ctx , tag , apdu .resplen - (tag - apdu_resp ), 0xDF2F , & taglen );
181+ if (tag != NULL && taglen == 1 && tag [0 ] == 0x00 ) {
182+ data -> pin1 .logged_in |= SC_PIN_STATE_NEEDS_CHANGE ;
183+ }
184+ LOG_FUNC_RETURN (card -> ctx , SC_SUCCESS );
177185}
178186
179187static int
180188esteid_pin_cmd (sc_card_t * card , struct sc_pin_cmd_data * data , int * tries_left )
181189{
182- int r ;
183190 LOG_FUNC_CALLED (card -> ctx );
184191 sc_log (card -> ctx , "PIN CMD is %d" , data -> cmd );
185192 if (data -> cmd == SC_PIN_CMD_GET_INFO ) {
186193 sc_log (card -> ctx , "SC_PIN_CMD_GET_INFO for %d" , data -> pin_reference );
187- r = esteid_get_pin_remaining_tries (card , data -> pin_reference );
188- LOG_TEST_RET (card -> ctx , r , "GET DATA(pin info) failed" );
189-
190- data -> pin1 .tries_left = r ;
191- data -> pin1 .max_tries = -1 ; // "no support, which means the one set in PKCS#15 emulation sticks
192- data -> pin1 .logged_in = SC_PIN_STATE_UNKNOWN ;
193- LOG_FUNC_RETURN (card -> ctx , SC_SUCCESS );
194+ LOG_FUNC_RETURN (card -> ctx , esteid_get_pin_info (card , data ));
194195 }
195-
196196 LOG_FUNC_RETURN (card -> ctx , iso_ops -> pin_cmd (card , data , tries_left ));
197197}
198198
0 commit comments