Math library for JavaCard?

孤者浪人 提交于 2019-12-01 12:32:51

The javacard 2.2.2 only supports boolean, byte, short, and optionally int. If you really need to perform Math, then you need to create your own class with tricky ways and of course the result is not precise.

Best practice is the card only stores data and do simple calculation/encryption and the server/terminal side calculates the complex things. The workaround to store double in the card is to use byte array.

There is javacardx.framework.math package in JavaCard API since 2.2.2 with limited functionality (add, subtract, multiply only). However, is frequently unsupported by physical cards and even when supported, it might be only 8 bytes long.

JCAlgTest now also provides results for all JavaCard packages including all versions as supported by cards in the database (including the javacardx.framework.math).

Alternatively, you may consider trying JCMathLib library. This library uses only public JC API calls to provide BigInteger with arbitrary length (as well as ECPoint operations) and is an improved version of older BigNat library. It will consume around 1KB RAM and requires card supporting ECC (if you like to use ECPoint, for BigInteger only it is not required). The implementation is done only partly in hardware (using RSA and ECC co-processors) and partly in software so is less resistant against side-channel and fault-induction attacks.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!