使用自定义 PRNG 在 perl 中高效生成 RSA 密钥对

发布于 2024-10-18 05:21:01 字数 699 浏览 6 评论 0原文

我希望在 Perl 中高效(快速)生成公钥和私钥对,并且能够为自己输入随机数据。 通过输入随机数据,我的意思当然是,该函数需要 X 个随机位来生成 Y 位的公钥/私钥对,并且我应该能够向该函数提供这些 X 位。

因此,通常情况下,该函数应该如下所示:

($private, $public) = genRSAkeypair($randomdata, 1024);

$private 然后包含:

----BEGIN RSA PRIVATE KEY-----
....
----END ....

$public 包含

----BEGIN RSA PUBLIC and so on...

$randomdata 然后只是来自任何随机生成器的随机位字符串。如果实例1和实例2之间的$randomdata一致,则实例1和实例2应该返回相同的公钥和私钥。

如果你想知道这个有什么用处,那就是我计划制作一个基于密码的 RSA 密钥生成系统,不需要在任何地方存储任何密钥。因此,密钥是通过使用以特定方式链接的 SHA512 创建静态随机数据,直接从密码生成的。

当然,每次在系统中输入相同的密码时,必须返回相同的公钥和私钥,否则系统将毫无用处。

有什么想法吗?

I would want to generate a public and private keypair, effciently (fast) in perl, and be able to input random data for myself.
With inputting random data, I of course mean, that the function requires lets say X random bits to generate a public/private keypair of Y bits, and I should be able to supply these X bits to the function.

So idially, the function should look like:

($private, $public) = genRSAkeypair($randomdata, 1024);

and $private then contains:

----BEGIN RSA PRIVATE KEY-----
....
----END ....

and $public contains

----BEGIN RSA PUBLIC and so on...

$randomdata is then just a string of random bits from any random generator. If $randomdata is consistent between instance1 and instance2, instance1 and instance2 should return the same public and private keys.

If you want to know what the use of this is, is that I plan to make a password-based RSA key generation system, without any need to store any keys anywhere. So the key is generated straight out from the password, by using SHA512 chained in a specific way to create static random data.

Of course, the same public and private key must be returned everytime the same password is entered in the system, else the system would be useless.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

時窥 2024-10-25 05:21:01

我会尝试 Crypt::OpenSSL::RSA,它似乎绑定
直接到libssl

I would try Crypt::OpenSSL::RSA, it seems to bind
directly to libssl

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文