kjur / jsrsasign

The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES and JSON Web Signature/Token in pure JavaScript.
https://kjur.github.io/jsrsasign
Other
3.25k stars 645 forks source link

React performance issue with generateKeypair #524

Closed develop1992 closed 2 years ago

develop1992 commented 2 years ago

Could you please help me with the below issue?

I need to use jsrsasign in my nextjs app, so I am using generateKeypair function of KEYUTIL to generate a keypair. However, it takes too long for generateKeypair to return value.

Here is my code:

const keypair = rs.KEYUTIL.generateKeypair("RSA", 3072); // the app crashes!!

kjur commented 2 years ago

Sorry but jsrsasign's RSA key generation is slow for large key size because it depends on Tom Wu's library. http://www-cs-students.stanford.edu/~tjw/jsbn/ I would recommend to use W3C Web Crypto API, Web Assembly or Node.JS "crypto" module key generation if you need more performance.