Now I have only one problem

NIIBE Yutaka gniibe at fsij.org
Wed Mar 13 07:00:05 CET 2013


On 2013-03-13 at 05:28 +0100, Alina Friedrichsen wrote:
> So, card death, reader waggly:
> I will send it back to factory.

I'm very sorry.  I did, and my card was also died (once).

For my card, I managed to get its life back again with following script.

   $ python come-back-openpgpcard.py

You need to install python-pyscard (this is package name in Debian),
the PyScard library to use this.


--------------------------- come-back-openpgpcard.py
#! /usr/bin/python

# Assume only single CCID device is attached to computer with card

from smartcard.CardType import AnyCardType
from smartcard.CardRequest import CardRequest
from smartcard.util import toHexString

class Card(object):
    def __init__(self):
        cardtype = AnyCardType()
        cardrequest = CardRequest(timeout=10, cardType=cardtype)
        cardservice = cardrequest.waitforcard()
        self.connection = cardservice.connection

if __name__ == '__main__':
    card = Card()
    card.connection.connect()

    ident = card.connection.getReader()
    print "Reader:", ident
    print "ATR:", toHexString( card.connection.getATR() )

    apdu = [ 0x00, 0xa4, 0x04, 0x00, 6, 0xd2, 0x76, 0x00, 0x01, 0x24, 0x01 ]
    response, sw1, sw2 = card.connection.transmit(apdu)
    print "%02x %02x %s" % (sw1, sw2, response)
    apdu = [ 0x00, 0x44, 0x00, 0x00 ]
    response, sw1, sw2 = card.connection.transmit(apdu)
    print "%02x %02x %s" % (sw1, sw2, response)
    card.connection.disconnect()
-- 





More information about the Gnupg-devel mailing list