使用< keygen>获取用于javascript的RSA密钥? [英] Using <keygen> to get an RSA key for use with javascript?

查看:136
本文介绍了使用< keygen>获取用于javascript的RSA密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Web项目需要一个RSA密钥对,虽然有一些库我认为依靠浏览器(为了安全性和速度)为我生成密钥是个好主意。是否可以使用keygen或其他浏览器API来执行此操作?我不知道如何从keygen获取密钥。它们似乎是在提交时生成的,但我不想将它们发送到服务器。

I need an RSA key pair for my web project and while there are some libraries I think it would be a good idea to rely on the browser (for security and speed) to generate the key for me. Is it possible to use keygen or something an other browser API to do so? I don't know how to get the keys from keygen. They seem to be generated on submit, but I don't want to send them to the server.

推荐答案

你可能是什么寻找像Mozilla的 DOMCrypt API提案。它允许您通过生成密钥对window.mozCrypto.pk.generateKeypair() window.mozCrypto 应该是要更改为 window.crypto 以后),您可以获取公钥,并使用私钥加密或解密文本。它仍然不会授予您对私钥的直接访问权限,但是,您只能获得密钥ID。

What you are probably looking for is something like Mozilla's DOMCrypt API proposal. It allows you to generate a key pair via window.mozCrypto.pk.generateKeypair() (window.mozCrypto is supposed to change into window.crypto later), you can get the public key and also encrypt or decrypt text with the private key. It will still not grant you direct access to the private key however, you only get a key ID.

不幸的是,任何浏览器都不支持此API。只有 Firefox扩展程序可用于测试它,所以提案还处于初期阶段。但我认为这是目前最好的。

Unfortunately, this API isn't supported by any browser yet. There is only a Firefox extension that can be used to test it, so that proposal is still in a very early stage. But I think that's the best you can get at this point.

这篇关于使用< keygen>获取用于javascript的RSA密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆