admin管理员组文章数量:1291297
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 remendations 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.
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 remendations 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.
Share Improve this question edited Feb 12, 2014 at 14:47 jww 102k103 gold badges443 silver badges943 bronze badges asked Feb 11, 2014 at 11:41 waifnstraywaifnstray 5475 silver badges6 bronze badges 2- 3 In general just generating a public/private key pair is not that useful. The problem is that you need to establish trust on the public key. This question is very close to being off topic as asking for sample code or library is considered off topic (show what you've tried yourself, your search engine is as good as ours). – Maarten Bodewes Commented Feb 11, 2014 at 12:30
- Relevant article: blogs.msdn./b/ericlippert/archive/2011/09/27/… – ntoskrnl Commented Feb 11, 2014 at 14:22
3 Answers
Reset to default 8In fact it is possible to implement private/public encryption using the ECC module. If you are a pro you can check the api documentation at http://bitwiseshiftleft.github.io/sjcl/doc/.
If you want an example of how its done, you can go through
http://justinthomas.pro/crypto/test.html http://justinthomas.pro/crypto/ repository url
You can see the SJCL ECC implementation in action here (key generation included)
Also this might be helpful https://github./bitwiseshiftleft/sjcl/issues/134
P.S. Elliptic curve cryptography (ECC) is an approach to public-key cryptography based on the algebraic structure of elliptic curves over finite fields. 256-bit ECC public key should provide parable security to a 3072-bit RSA public key http://en.wikipedia/wiki/Elliptic_curve_cryptography
Looks like they recently released this (about a year after your initial post) but it gives a tutorial of how to do asymetric crypto
https://github./bitwiseshiftleft/sjcl/wiki/Asymmetric-Crypto
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..
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.
本文标签: javascriptHow do I implement publicprivate key cryptography in SJCLStack Overflow
版权声明:本文标题:javascript - How do I implement publicprivate key cryptography in SJCL? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741507680a2382419.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论