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

[Add] CardOS 5.x Initialisation with cardos-tool #1119

Closed
ghost opened this issue Aug 2, 2017 · 17 comments
Closed

[Add] CardOS 5.x Initialisation with cardos-tool #1119

ghost opened this issue Aug 2, 2017 · 17 comments
Labels

Comments

@ghost
Copy link

ghost commented Aug 2, 2017

Hello everyone,

Today I tried initializing a brand new Atos CardOS 5.3 smartcard without success. As I saw that 5.3 is still fresh on the repo, I'm proposing my help.

Specs

Gentoo Linux (Linux 4.9.34-gentoo)
OpenSC version 0.17.0 (custom ebuild, branch master, last commit 3d187d9)
pcsc-lite version 1.8.22 (Enabled features: Linux x86_64-pc-linux-gnu serial usb libudev)
Gemalto IDBridge K30 (Generic CCID USB SmartCard Reader)
Atos CardOS V5.3 (Infineon Solid Flash Chip - SLE78CFX3000P)

Actual behaviour

cardos-tool -f -r 1
currently only CardOS M4.2B, M4.2C, M4.3B and M4.4 are supported, aborting

Expected behaviour

cardos-tool -f -r 1
Good job man, you did it !

Steps to reproduce

1- Plug a uninitialized (Current life cycle: 52 (manufacturing)) CardOS V5.3 chip into a reader
2- Try to cardos-tool -f

Logs

opensc-tool --reader 1 --atr

3b:d2:18:00:81:31:fe:58:c9:03:16

cardos-tool -vv -i -r 1

Connecting to card in reader Generic CCID Reader (F3A36122) 01 00...                                                                                                                                                                                                   
0x7fca808fc700 16:45:29.968 [cardos-tool] card.c:200:sc_connect_card: called                                                                                                                                                                                           
Using card driver Siemens CardOS.                                                                                                                                                                                                                                      
Card ATR:                                                                                                                                                                                                                                                              
3B D2 18 00 81 31 FE 58 C9 03 16 ;....1.X...                                                                                                                                                                                                                           
Info : CardOS V5.3, 2014                                                                                                                                                                                                                                               
Serial number: 02 05 a1 55 00 19 XX XX                                                                                                                                                                                                                                 
OS Version: 201.3 (unknown Version)                                                                                                                                                                                                                                    
Current life cycle: 52 (manufacturing)                                                                                                                                                                                                                                 
Security Status of current DF:                                                                                                                                                                                                                                         
Free memory : 13315                                                                                                                                                                                                                                                    
ATR Status: 0x0 ROM-ATR                                                                                                                                                                                                                                                
Packages installed:                                                                                                                                                                                                                                                    
Ram size: 7, Eeprom size: 83, cpu type: 78, chip config: 63, chip manufacturer: 5                                                                                                                                                                                      
Free eeprom memory: 84826                                                                                                                                                                                                                                              
Current Maximum Data Field Length: 384                                                                                                                                                                                                                                 
Complete chip production data:                                                                                                                                                                                                                                         
CC 78 33 CE 01 00 01 00 0E 00 00 01 0B 02 00 00 .x3.............                                                                                                                                                                                                       
00 00 00 00 00 00 00 61 75 38 30 FF FF FF FF 78 .......au80....x                                                                                                                                                                                                       
01 51 41 78 05 16 07 00 00 83 12 05 E7 55 21 02 .QAx.........U!.                                                                                                                                                                                                       
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................                                                                                                                                                                                                       
00 00 00 00 00 00 00 00 00 00 00 00             ............                                                                                                                                                                                                           
System keys: PackageLoadKey (version 0x00, retries 10)                                                                                                                                                                                                                 
System keys: StartKey (version 0x00, retries 10)
Some error occurred. Use '-v' several times to enable debug output.0x7fca808fc700 16:45:30.107 [cardos-tool] ctx.c:870:sc_release_context: called

Debug log of cardos-tool -vvv -i -r 1

Informations

I am at your disposal for testing as well as brute-forcing apdu commands into my chip.

References

#947
#1003
#1079

Edit 1: Forgot my manners :)

@ghost
Copy link
Author

ghost commented Aug 2, 2017

After bypassing the version info check (

if ((rbuf[0] != 0xc8 || rbuf[1] != 0x09) && /* M4.2B */
), i get:

startkey version is 0x00, currently we support only 0xff
aborting

@frankmorgner
Copy link
Member

@Jakuje?

@Jakuje
Copy link
Member

Jakuje commented Aug 3, 2017

That would be one of the thing I would like to have a look at some point, but currently I don't have any uninitialized CardOS 5 card I could play with nor I have a lot of time to do that. It is hard with these closed-specification cards.
I am able to offer help such as listing what is/should be in successfully initialized card, but probably not much more in close future.

@ghost ghost changed the title CardOS 5.3 Initialisation broken [Add] CardOS 5.x Initialisation with cardos-tool Aug 3, 2017
@ghost
Copy link
Author

ghost commented Aug 3, 2017

If you want, I can plug the card into a server at home and let you play with it inside a virtual machine. I mean, it's not that I can use it right now so... :)

I edited the title to match what this ticket is about, new code for improved compatibility.

@ghost
Copy link
Author

ghost commented Aug 3, 2017

As I was browsing the web for informations, I stumbled upon #768. My problem is somewhat related to this issue.

@Jakuje
Copy link
Member

Jakuje commented Aug 3, 2017

The problem that the card management of CardOS 5 should be substantially different from the 4.x versions, according to the #283. I recommend reading also that PR, which also discuss some of the issues with 5.x and might give you some hints what is missing. Unfortunately, the code as a whole is not available and therefore ready for re-implementation, which is huge task without any substantial knowledge about the card.

@ghost
Copy link
Author

ghost commented Aug 3, 2017

The only thing I'm able to do is to try to initialize the card with the CardOS API Driver on a Windows VM and sniff the USB data to reverse engineer the apdu codes sent to it. But I have one shot, unless I order more chips. The code itself is a whole new problem as I am no developer.

Also, would you be kind to confirm that an initialized 5.3 card works with OpenSC ?

@Jakuje
Copy link
Member

Jakuje commented Aug 3, 2017

Yes, the initialized CardOS 5.3 cards work with OpenSC, at least to the extend of pkcs11-tool --test using PKCS#11 interface with RSA keys.

@ghost
Copy link
Author

ghost commented Aug 4, 2017

I tried to initialise the chip with the CardOS API Windows app but it didn't ask for a custom SO PIN. The card is now in operational status but cannot talk with OpenSC. I dumped the CCID commands with Wireshark and usbmon. If you want the dump file, just ask for it, i'm not sure if I can share it publicly (cause of NDAs and whatnot).

The card is working fine with Windows Crypto API but is unreadable by pcks15-tool on Linux. Also, pkcs11-tool --test is segfaulting.

@ghost ghost closed this as completed Aug 4, 2017
@ghost ghost reopened this Aug 4, 2017
@frankmorgner
Copy link
Member

@Jakuje @NainKult what's the status of this issue, did you resolve it?

@Jakuje
Copy link
Member

Jakuje commented Nov 6, 2017

No. I don't have any update. The pkcs11-tool --test is segfaulting for @NainKult, but without any backtrace or debug logs, it is hard to guess what went wrong or if it was resolved by the same fix as the #1134 pushed later (ECC support).

@ghost
Copy link
Author

ghost commented Nov 6, 2017

I was planning to purchase more CardOS 5.x chips to improve support but because of the Infineon chips thingy, I changed my mind. All my chips are in Operative Mode as of now and I have no way to test pkcs11-tool on a uninitialised chip (Manufacturing).

I can however confirm that #1134 solved the segfault on an initialized chip.

Statement from my card provider:

We would like to inform you of a potential security issue regarding all CardOS V5 products, which is related to RSA key generation based on the Infineon "Asymmetric Crypto Library (ACL)" of the SLE78 chip platform. A researcher team [...] recently found a method to identify mathematical weaknesses of particular algorithms for prime number generation.

@Jakuje
Copy link
Member

Jakuje commented Nov 6, 2017

Thank you for confirmation. The uninitialized chips are not supposed to work with pkcs11-tool, though it should not segfault. So in case you will be able to reproduce the issue, please come back with findings.

I see that CardOS is clearly using Infineon chips and potentially their Fastprime library, but I did not find any official announcement about this issue from Atos confirming or declining what everything is affected in their case. You can always test the public keys on your own with the following tool: https://keychest.net/roca
I found only several references that 2048 and 4096 bit keys should not be affected (well .. they might be, but the complexity of the factorization should be still too expensive), which should be used already in any case.

@ghost
Copy link
Author

ghost commented Nov 6, 2017

Here is the complete and official Atos statement sent to their customers (me included). This document has been approved for public distribution.

According to your link, and for a 2048 RSA Key generated on one of my chips:
Test result | Subject to ROCA, insecure.

So in case you will be able to reproduce the issue, please come back with findings.

Wiiiiiiill dooooo ! (in Meeseeks voice)

@sgtstadanko
Copy link

I was able to use my Atos card, but only with Firefox and loading the module directly. Tokend/Safari/Chrome not working. Not sure about initializing a card.

@htgoebel
Copy link

htgoebel commented Jan 9, 2018

@sgtstadanko Can you please elaborate how you achieved this? Thanks in advance

@frankmorgner
Copy link
Member

Hopefully fixed with #2045

please reopen if the issue persists. If so, please attach a debug log and run the program with debug symbols in valgrind or gdb

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

No branches or pull requests

4 participants