Toporin / SatochipApplet

The open source hardware wallet smartcard - Satochip.io
https://satochip.io/shop
GNU Affero General Public License v3.0
117 stars 42 forks source link

Compatibility with JC30M48CR #3

Closed 9500 closed 4 years ago

9500 commented 4 years ago

Tried to test the applet with Infineon JC30M48CR, details about the card here: https://github.com/crocs-muni/JCAlgTest/blob/master/Profiles/results/JavaCardOS_Infineon_JC30M48CR_ALGSUPPORT__3b_80_80_01_01_(provided_by_JavaCardOS_and_Thotheolh_Tay).csv

Cap was loaded successfully, and electron cash recognized the hardware wallet, however when I tried to initialize it, I got the error "Unable to setup the device with error code:0x6f 0x0".

Does this mean that this particular java card is not supported? Is it possible to know why? I see that it supports ALG_ECDSA_SHA_256 algorithm.

Toporin commented 4 years ago

Hello,

It seems that this card does not support ALG_EC_SVDP_PLAIN. This algorithm is initialized during setup as can be seen in method setup() in CardEdge.java: keyAgreement = KeyAgreement.getInstance(ALG_EC_SVDP_DH_PLAIN, false);

This is required to recover the public key from the private part derived with Bip32.

As far as I can tell, this card is not suitable for the purpose of Satochip wallet.

9500 commented 4 years ago

Thanks, looking for another card... This card was very cheap for the card that supports ECDSA, too bad it won't work.

9500 commented 4 years ago

Theoretically, ALG_EC_SVDP_DH_PLAIN could be performed in software by using https://github.com/OpenCryptoProject/JCMathLib

Logically, it's just the result of the multiply operation between public and private key.

Some examples here: https://github.com/bcgit/bc-java/blob/master/core/src/main/java/org/bouncycastle/crypto/agreement/ECDHBasicAgreement.java https://github.com/anonghosteam/outlook-privacy-plugin/blob/82a3620343254b5204599a0ae0eae377887871d6/3rdParty/bccrypto-net-1.7/crypto/src/crypto/agreement/ECDHBasicAgreement.cs

Not sure how feasible it is to implement that.

EDIT: Looked it up, ECPoint multiplication takes about 4 seconds in sw, so - useless. Getting better card.