对于 Diffie-Hellman 素数和生成器,我应该使用什么密钥长度?

发布于 2024-08-18 06:26:48 字数 438 浏览 4 评论 0原文

在下面来自 Crypto++ wiki 的代码中,128 是我真正应该使用的数字吗?

CryptoPP::AutoSeededRandomPool arngA;
CryptoPP::RandomNumberGenerator& rngA = *dynamic_cast<CryptoPP::RandomNumberGenerator *>(&arngA); 
CryptoPP::DH dhA(rngA, 128);
CryptoPP::Integer iPrime = dhA.GetGroupParameters().GetModulus();
CryptoPP::Integer iGenerator = dhA.GetGroupParameters().GetSubgroupGenerator();

In the code below, from the Crypto++ wiki, is 128 the number I really should be using?

CryptoPP::AutoSeededRandomPool arngA;
CryptoPP::RandomNumberGenerator& rngA = *dynamic_cast<CryptoPP::RandomNumberGenerator *>(&arngA); 
CryptoPP::DH dhA(rngA, 128);
CryptoPP::Integer iPrime = dhA.GetGroupParameters().GetModulus();
CryptoPP::Integer iGenerator = dhA.GetGroupParameters().GetSubgroupGenerator();

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

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

发布评论

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

评论(1

゛时过境迁 2024-08-25 06:26:48

Z/(pZ) 上的整数分解和离散对数大致同样困难。因此,Diffie-Hellman 模数的大小应与您为 RSA 模数选择的大小大致相同。如果您熟悉 1024 位 RSA 密钥,那么您也可以熟悉 1024 位 Diffie-Hellman 密钥。

很难判断 crypto++ 中的密钥大小是以位还是字节来衡量的。
正如 Sebastian 指出的那样,dhA(rngA, 128) 确实可能生成 128 位 Diffie-Hellman 密钥,但这太小了。通过代码来看,确实是这样的。

生成器 iGenerator 的大小不会影响 Diffie-Hellman 的安全性。 (即 iGenerator = 2 就可以了)

Integer factorization and discrete logarithm over Z/(pZ) are roughly equally difficult. Therefore the size of the modulus for Diffie-Hellman should be about the same size as you would choose for an RSA modulus. If you are comfortable with a 1024-bit RSA key then you can also be comfortable with a 1024-bit Diffie-Hellman key.

It is not easy to tell if key sizes in crypto++ are measured in bits or bytes.
As Sebastian points out dhA(rngA, 128) may indeed generate a 128 bit Diffie-Hellman key, which would be too small. Going through the code it looks like this is indeed the case.

The size of the generator iGenerator does not affect the security of Diffie-Hellman. (I.e. iGenerator = 2 could be perfectly fine)

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