@@ -230,6 +230,10 @@ func (card *Gemalto) selectFile(name []byte, selectionMethod, selectionOption by
230230 return nil , fmt .Errorf ("selecting file: %w" , err )
231231 }
232232
233+ if ! responseOK (rsp ) {
234+ return nil , fmt .Errorf ("selecting file: response %s" , hex .EncodeToString (rsp ))
235+ }
236+
233237 return rsp , nil
234238}
235239
@@ -253,7 +257,7 @@ func (card *Gemalto) InitCrypto() error {
253257 }
254258
255259 if ! responseOK (rsp ) {
256- return errors . New ("cryptography application not selected" )
260+ return fmt . Errorf ("cryptography application not selected: response %s" , hex . EncodeToString ( rsp ) )
257261 }
258262
259263 return nil
@@ -289,7 +293,7 @@ func (card *Gemalto) ChangePin(newPin, oldPin string) (int, error) {
289293 }
290294
291295 if ! responseOK (rsp ) {
292- return PinTriesLeft (rsp ), errors . New ("verifying old pin" )
296+ return PinTriesLeft (rsp ), fmt . Errorf ("verifying old pin: response %s" , hex . EncodeToString ( rsp ) )
293297 }
294298
295299 data := make ([]byte , 0 , 8 )
@@ -303,7 +307,7 @@ func (card *Gemalto) ChangePin(newPin, oldPin string) (int, error) {
303307 }
304308
305309 if ! responseOK (rsp ) {
306- return PinTriesLeft (rsp ), errors . New ( "changing pin" )
310+ return PinTriesLeft (rsp ), fmt . Errorf ( "verifying old pin: response %s" , hex . EncodeToString ( rsp ) )
307311 }
308312
309313 err = card .smartCard .EndTransaction (scard .LeaveCard )
0 commit comments