Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CardConnection transmit error while generating RSA Keys longer than 64 bytes (SAM) #28

Closed
juanmardefago opened this issue Nov 30, 2017 · 2 comments

Comments

@juanmardefago
Copy link

Hello,

I'm trying to generate a RSA key pair using a SAM (Secure Access Module), I followed all instructions from the documentation, but if I try to generate keys larger than 64 bytes (i.e. 128/256 bytes) I get a weird error related to the PCSC driver.

This is the most detailed stack trace that I could get, using cyberflex:

<class 'smartcard.Exceptions.CardConnectionException'>: Failed to transmit with protocol T1. Transaction failed.
  File "/home/cyberflex-shell/shell.py", line 126, in _run
    self.parse_and_execute(line)
  File "cyberflex-shell.py", line 309, in parse_and_execute
    result = Shell.parse_and_execute(self, line)
  File "/home/cyberflex-shell/shell.py", line 201, in parse_and_execute
    return function(*args)
  File "cyberflex-shell.py", line 244, in do_fancy_apdu
    return self.do_apdu(apdu)
  File "cyberflex-shell.py", line 267, in do_apdu
    response = self.card.send_apdu(apdu)
  File "/home/cyberflex-shell/cards/generic_card.py", line 173, in send_apdu
    result = self._send_with_retry(apdu)
  File "/home/cyberflex-shell/cards/iso_card.py", line 130, in _send_with_retry
    result = self._real_send(apdu)
  File "/home/cyberflex-shell/cards/iso_card.py", line 122, in _real_send
    result = Card._real_send(self, apdu)
  File "/home/cyberflex-shell/cards/generic_card.py", line 138, in _real_send
    result_binary = self.reader.transceive(apdu_binary)
  File "/home/cyberflex-shell/readers.py", line 115, in transceive
    data, sw1, sw2 = self._cardservice.connection.transmit(data_bytes, protocol=self.PROTOMAP[self.get_protocol()])
  File "/usr/local/lib/python2.7/dist-packages/smartcard/CardConnectionDecorator.py", line 82, in transmit
    return self.component.transmit(bytes, protocol)
  File "/usr/local/lib/python2.7/dist-packages/smartcard/CardConnection.py", line 146, in transmit
    data, sw1, sw2 = self.doTransmit(bytes, protocol)
  File "/usr/local/lib/python2.7/dist-packages/smartcard/pcsc/PCSCCardConnection.py", line 205, in doTransmit
    SCardGetErrorMessage(hresult))

Also, in the docs they said that this C-APDU execution takes a while (1 minute or so, for longer keys), when I tried generating 64 byte keys or less it didn't took as much (barely 1 or 2 seconds), but when generating larger keys it starts computing for about 3-5 seconds, and then this error happens. I thought that maybe there was a timer/timeout callback, but couldn't find anything related, even so, maybe that extra bit of information helps.

Thanks in advance!

@LudovicRousseau
Copy link
Owner

Hello,
Please provide the information listed at http:https://pcsclite.alioth.debian.org/pcsclite.html#support

@juanmardefago
Copy link
Author

Turns out I was using outdated versions of pcscd and libccid because I'm using Ubuntu 16.04.

I was using these versions:
libccid 1.4.22-1
pcscd 1.8.14-1ubuntu1

then we tested it on Debian (4.9.0) with these versions:
libccid 1.4.26-1
pcscd 1.8.20-1

It worked fine on Debian with those versions, even while trying to generate 256 byte keys (1 min approximately)

Sorry for the inconvenience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants