Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaCard - pure software implementation of ECC over GF(2^n)

I have smartcards by NXP that support ECC over GF(p) and that do not support ECC over GF(2^n).

In my project I need to use this particular type of smartcard (thousands of instances are used already). However, I need to add verification of EC signature over sect193r1, which is a curve over GF(2^n).

Performance is not an issue for me. It can take some time. Signature verification does not involve any private keys, so the security and key management are not issues, either. Unfortunately, I have to verify the signature inside my smartcard, not in the device equipped with smartcard reader.

Is there any solution? Is there any existing source code of a pure software JavaCard implementation of EC cryptography over GF(2^n)?

like image 785
vojta Avatar asked Feb 12 '15 09:02

vojta


2 Answers

Smart cards that are able to perform asymmetric cryptography always do this using a co-processor (that usually contains a Montgomery multiplier). Most smart cards (e.g. the initial NXP SmartMX processors) still operate using an 8 bit or 16 bit CPU. Those CPU's are not designed to perform operations on large numbers. Unfortunately Java Card doesn't provide direct support for calls to the multiplier - if that would be of use at all. Most cards (e.g. again the SmartMX) also don't support 32 bit (Java int) operations.

So if you want to perform such calculations you will have to program it yourself, using signed 8 bit and signed 16 bit primitives. This will require a lot of work and will be very slow. Add to this the overhead required to process Java byte-code and you will have an amazing amount of sluggishness.

like image 150
Maarten Bodewes Avatar answered Oct 18 '22 03:10

Maarten Bodewes


Just updating with some extra info in case someone is still looking for a solution.

The OpenCryptoJC lib indeed provides BigNumbers, EC curve primitive operations etc. So you should be able to load your own curve and its parameters.

However, if this curve is not supported natively by the card, you use the lib to implement the operations on the curve yourself. That's not-trivial though...

Alternatively, if there is any mapping between the GF(2^n) curve you want to use and another GF(p) you could try do all operations in GF(p) and them map the results back to GF(2^n). That could be easier to do assuming that there is such a mapping.

Disclaimer: I'm one of the lib authors. :)

like image 22
Vasilios Mavroudis Avatar answered Oct 18 '22 04:10

Vasilios Mavroudis