SmartCard target disabled

Hello,

I am trying to use the ChipWhisperer for a SCA on a self programmed SC.
The main problem at the moment is that when I open the original ChipWhispererCapture tool it gives the message that the SmartCard target is disabled due to the fact that no module named CardType could be found. In fact none of these modules (CardType, CardRequest, CardConnection, util) can be loaded. Therefore I am not able to choose SmartCard as the target in the general settings.

Does somebody now what needs to be changed in order to make it work?

Thanks in advance.

The smartcard module requires you to install pyscard, see “http://sourceforge.net/projects/pyscard/” for the installers.

Thanks for the fast and helpful reply :slight_smile:

But I now have another issue.
When I choose the ChipWhispererSCard as reader and my own protocol skript, which is basically the same as for the SASEBO board but with adapted values and then try to connect the Target, i.e. klick on the red Button of the Target to connect it, I get the error which I attached and it does not connect

The Scope is set to ChripWhisperer/OpenADC and the Target is set to Smart Card.

Error Message:
[size=85]

[/size]

Hello,

Is the OpenADC/ChipWhisperer connected already? It will give you that error if you try to connect to the target first. Is this on a SASEBO-W board?

Regards,

-Colin

Hey,

indeed we tried to connect the target first, since connecting the scope also gave a message that we did not understand, in especially we had no idea where this value is coming from and could not find it in the source code.

Connecting the scope first and then the target leads to following error message. The target itself is a self programmed smart card plugged directly into the smart card reader on the multi target victim board. There is no SASEBO involved.

Thanks,
BSMK

Hi BMSK, in the CW software, under target settings , you not only need to select ‘Reader Hardware’, but also ‘Protocol’.

From your setup description, reader hardware should be ‘Chipwhisperer-SCARD’. For ‘Protocol’ you should select JCARD test. Do note that you need to modify SmartCard.py with the appropriate APDUs for your smartcard.

Perhaps you could also take a look at this forum post where I documented how I got it to work?

Hey,

I added a protocol myself, since it was choosen automatically when I chose Reader Hardware, I thought he put it in, but actually I had to change it to a different protocol and then change it back in order to set this protocol.

Now I am finally able to connect to the scope and the target. But when I connect the scope it still gives me this error message with the weird value and as soon as I try to reset to get an ATR I get the following error message. I am also measuring the reset pin with a different scope and there is no reaction (I know that you said that the reset pin is not routed to the smart card, but i am measuring at the first pin of JP23)

The “Timeout in read: 0” comes from
ChipWhispererTargets.py (line 451)
-> class CWSCardIntegrated
-> scGetStatus
-> sets =selft.oa.sendMessage(CODE_READ, ADDR_STATUS, Validate=False)
and sets is afterwards NONE.

Do I need to change there something? And if yes, where and what?

Thanks in advance,
cheers,
BSMK

I am not sure, but one thought is that maybe passthru is enabled.
You should not enable passthru here. It enables ‘stream’ mode which not necessary and dangerous

passthru mode is enabled by default in the reset function. all you need in the reset function is the following to raise RESET high:

        cmd = bytearray(1)
        cmd[0] = FLAG_RESET;
        self.oa.sendMessage(CODE_WRITE, ADDR_STATUS, cmd, Validate=False)
        time.sleep(0.1)

I hope this helps

First of all sorry for so many messages, but I am trying to trace the error down but cannot really find the cause.

I really think that the scope is not connected properly at the beginning, causing the other errors.
I found the string “OpenADC Found, Connecting” in OpenADC.py, but this is not causing any error. I don’t know what is called next which causes the error:

invalid literal for int() with base 10: ‘1420468405.95918’
0

Any ideas where this error message, the value, or the ‘0’ is coming from?

Thanks again,
Cheers,
BSMK

Through disabling the passtthru I got rid of the TypeError, so thanks for that.

But the OpenADC error remains and ‘Update Status’ gives me a timeout. Both, ‘Update Status’ and ‘Reset Card’ raise an IOError in the read function of OpenADC (It only returns an empty array, but the debugging string I entered is printed.) I still don’t get an ATR.

Hello,

Those two messages are debug, you can ignore them. I’ve got to improve my list of to-fix on the 0.9 release sorry! But to your problem at hand:

The following message

    if (result[0] & 0x80) == 0:
    TypeError: 'NoneType' object has no attribute '__getitem__'

Is indicative of comms failure, the ChipWhisperer didn’t respond to messages. It sounds like this was due to the stream mode enabled.

Which was the OpenADC error? Can you see any activity on the physical I/O lines?

Regards,

-Colin

Hey,

thanks again, but still not quiet there.
I already disabled the passthru in the reset function, so that sould not be the problem.
When I connect the OpenADC and the Target I only get the messages that I am supposed to ignore, so far so good. A Update Status does not give me a checked box at Card Present but a Timeout in read: 0. Reset does not give a signal on the reset pin (measured directly, not on the smart card).

When I try to capture one trace it gives me this error:

I do not see any activity on the I/O line. (And yes, the Chip Whisperer is plugged in :wink: )

There are some possibilities:
a) Is the smartcard module present in the FPGA? (In the ztex xilinx project file from github, it’s commented out .)
b) Is the RST signal to the card’s RST pin driven high? (Otherwise the card will never respond)

Best Regards
Alvin

FYI: The latest release of chipwhisperer (0.09RC1) now includes an improved smartcard module. This has been tested with the “SASEBO-W CardOS” and the “DPA Contest v4.2” images. I haven’t tested with JavaCard or similar, but should be possible to get working.

Basically the new system includes (a) support for controlling the reset pin an (b) moves the UART into hardware rather than software, so it’s much faster than before.

See http://www.newae.com/sidechannel/cwdocs/tutorialsasebowcard.html for an updated tutorial, the release itself is available from chipwhisperer.com . It’s current a release candidate so let me know if there is problems!

Hey,

thanks for the notice.
But when I try to run the makeproject_win.bat file in order to create a project file for ISE (to make the according changes on the .v file for using a smart card) it gives me the following error:

When I copy the required file from common to the desired location the project file is generated, but when I try to generate the programming file with ISE, it gives the error that IN_ADCSampleClock can not be found.
I will uncomment this in the file, since it seems not to be used.

Hmm thanks for the notice - I’ll check into that! As a side-note the new FPGA firmware is pre-built, so if you just want to take advantage of the new module you don’t need to rebuild the bitstream. The provided .zip which includes the bitstream should work.

If you are making further changes of course ignore that!

We have been doing some experiments to see what possibly is going wrong. First we made the connection on the target board between the RXD signal and the reset pin of the smart card connector. After that we modified ztex_cw_interface.v to include the scard register and scard hls module. There are three more lines that need to be modified to tie the module to the different buses. We routed the target_io1 pin to the smartcard_rst output pin of the scard register module. After building the bit file we tested with the following settings in the capture software:
General settings:
Scope Module: ChipWhisperer/OpenADC
Target Module: Smart card
Trace Format: ChipWhisperer Native

Target settings:
Reader hardware: ChipWhisperer-SCARD
Smartcard Protocol: MYCARD (which at this level does not matter much yet)

We connected an oscilloscope to the smart card pins. When pushing the reset button in the capture software target settings panel after connecting a nice reset pulse appears on the smart card reset pin. So the reset works fine. The smart card answers with a proper ATR. The software however still gives the same error message:
Timeout in read: 0
Traceback (most recent call last):
File “c:\08400 rd chip whisperer\chipwhisperer-0.09rc1\chipwhisperer-0.09rc1\openadc\controlsw\python\openadc\ExtendedParameter.py”, line 73, in change
linked.setValue(linked.opts’get’)
File “c:\08400 rd chip whisperer\chipwhisperer-0.09rc1\chipwhisperer-0.09rc1\openadc\controlsw\python\openadc\openadc.py”, line 664, in dcmADCLocked
result = self.DCMStatus()
File “c:\08400 rd chip whisperer\chipwhisperer-0.09rc1\chipwhisperer-0.09rc1\openadc\controlsw\python\openadc\openadc.py”, line 673, in DCMStatus
if (result[0] & 0x80) == 0:
TypeError: ‘NoneType’ object has no attribute ‘getitem

So we modified the ztex_cw_interface.v again to route the signal ‘scard_async_data’ to output pin target_io4, that of course was decoupled from other drivers. When we monitor this signal we can see that it gives a high pulse for every byte received from the smart card when we press the reset button. So internally the ATR is received. It simply does not show up in the software.
Question1: is there a simple way to monitor the communication between the python software and the CW hardware to see what is going wrong?
Question2: do you have any clue why the software does not receive the response?
Question3: are the settings correct?

Thanks.

Hello,

That error sounds like communication has been lost - most likely the smartcard module is acting up, possible still in ‘passthru’ mode. You might disable that in the FPGA to ensure you don’t run into issues.

You can also try the new 0.09RC1 and see if that improves anything. See the link above for the updated tutorial, as it has a more robust smartcard module.