BigInteger subtraction in JavaCard

烂漫一生 提交于 2019-12-06 11:25:01

Well, in fact there is no such thing like native real BigInteger support for JavaCard. There is BigNumber, but I don't think it will fit your requirements.

However, there is a way to undertake this limitation.

There is some JavaCard library that should allow you to deal with arbitrary long big integers - the problem is that your applet could run out of memory. Sources of library are here, and here is the prebuilt .jar.

This approach might work but also likely to be drastically slow on real card. However this isn't an issue, if you run such code in simulator just for PoC.

I've no idea what is your IDE but this is how you can add this library for IntelliJ.


However, as Maarten Bodewes pointed out, you might be better focus on bytes substraction, just because of probable inefficency of any BigInteger JavaCard library.


Hope this helps.

UPD

BigNumber is guaranteed to be at least 8 bytes, but as far, as I tried it, it allows exactly 8 bytes, which is way to small to hold some security-robust parameters. Say, it cat not contain safe prime p that equals to 57896044618658097711785492504343953926634992332820282019728792003956564821041.

You can try this yourself with method getMaxBytesSupported() just to ensure the fact.

So, as you can see, BigNumber is relatively big for JavaCard, but still smaller, than most crypto protocols needs.

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