javascriptcryptographyaesrsasjcl

How do I implement public/private key cryptography in SJCL?


I have used Stanford Javascript Crypto Library (SJCL) for symmetric AES encryption (based on the examples on their demo page). However I have an additional requirement to generate a key pair, encrypt data with a public key, and decrypt data with a private key. Some of the class names suggest this might be possible in SJCL, but I was wondering if anyone could help with an example of how it's done. I'm not concerned at this stage with private key storage, just the in-memory generation and use of a public/private key pair.

If it isn't possible, I'd be interested in recommendations for an alternative library that will cover both AES and public key cryptography - but I'm aware this is something I could research myself! So mainly I'm curious to know if the library I have started using can cover all my needs or whether I need to look into an alternative.


Solution

  • According to Symmetric Cryptography in Javascript, there's no mention of public key cryptography. So it does not appear to be supported.

    There are probably some fractured solutions available, but I don't know any off the top of my head. Github seems to have some choices: javascript public key crypto site:github.com.

    The WebCrypto Working Group is working on the problem right now. It will have provisioning, key generation, key storage and some public key operations, like seal and sign. The first revision will not have a rich offering of Diffie-Hellman or primitive like BigIntger. See, for example, Question on BigInteger operations.