Using <keygen> to get an RSA key for use with javascript?
I need a pair of RSA keys for my web project, and although there are several libraries, I think it would be nice to rely on the browser (for security and speed) to generate the key for me. Is it possible to use keygen or some other browser API for this? I do not know how to get keys from keygen. It seems that they are generated when sending, but I do not want to send them to the server.
What you're probably looking for looks like a Mozilla DOMCrypt API proposal . It allows you to generate a key pair through window.mozCrypto.pk.generateKeypair() ( window.mozCrypto assumed to be changed to window.crypto ), you can get the public key, and also encrypt or decrypt the text using the private key. It still will not give you direct access to the private key, but you will only get the key identifier.
Unfortunately, this API is not yet supported by any browser. There is only a Firefox extension that can be used to validate it, so the offer is still at a very early stage. But I think the best you can get at this moment.
Let's say this is a scary idea because of the ability to enter code that steals the private key.