Reputation: 21
I am working on a crypto application for Android that is compute intensive. I have to handle positive integers of size between 80 and 1024 bits. I need modular exponentiation and a compositeness test. I realized that the only option (if I want to code in Java only) is to use the BigInteger class. Is there any better solution in terms of performance? For example I thought of writing the application in C using the The GNU MP Bignum library and JNI. Would this be worth it performance-wise? Would that require JNI glue code just for the application entry point or there are other problems?
Upvotes: 2
Views: 620
Reputation: 2042
Android uses OpenSSL's BN API for part of its BigInteger arithmetic, so it should be fairly fast as it is. To find the slow methods, look at Android's BigInteger documentation for anything that has "Implementation Note" attached to it.
As others have noted: don't implement your own crypto primitives, because you're going to run into troubles. GMP leaks timing information for instance.
Upvotes: 4