On 10/04/2009 12:38 PM, Péter Szabó wrote: > Hi, > > I need a function which can do fast modular exponentiation on 2048-bit > integers. I'd like to call this function from JavaScript running in > Mozilla (Firefox 3.0 or later) displaying a web page. Is there such a > function or do I have to implement in pure JavaScript? The short answer is 'no'.
The long answer is, "why". If you are just doing some sort of math library, then it probably makes sense, but given the type of math and the size of the integers, it seems like you are trying to implement some well known asymmetric protocol on top of that modular exponentiation (either RSA or some flavor of DH or DSA). It's not really a good idea to reimplement crypto protocols in your javascript programs (particularly if you are trying to roll you own security protocol). These things are easy to understand and hard to get right. Those of us who have done this for a living for 10+ years still approach the idea of making a new protocol with caution. You are much better off using some already standard protcol to handle your communication (like SSL or S/MIME). The the very least you should use the built in primitives for the algorithm you are implementing. That way you will be at least pushed toward some good crypto hygiene in your app. > Although it is > quite optimized, the pure JavaScript implementation > http://www.leemon.com/crypto/BigInt.html seems to be slow: 77 seconds > for a single 2048-bit modular exponentiation. I need a function which > runs in at most half a second. Is it possible to do this with NSS/JSS? > NSS and JSS doe not export their modular exponentiation engine, pretty much for the above reasons. > Am I asking this question on the right mailing list? If not, where > should I ask? I know that if the Java plugin is available, then I can > use java.math.BigInteger.modPow, which is very fast. (See > http://stackoverflow.com/questions/1450608/fastest-modular-exponentiation-in-javascript > for the example code.) But what can I use if Java is not available in > the browser? Is there something in vanilla Mozilla (or Firefox) which > can be used to do quick modular exponentiation? > If you just want modExp, you are in the wrong group, if you want to do crypto, you are mostly in the right group, but we do not control what NSS exports to javascript (though those that do lurk here as well). bob
-- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto