用于 RSA PKCS#1(密钥生成)的 C++ 中的加密安全 RNG

Cryptographically secure RNG in C++ for RSA PKCS#1 (key generation)

我正在尝试在 C++ 中重新实现 RSA 密钥生成(作为 hobby/learning 游乐场),到目前为止我最大的问题似乎是 生成 x 范围内的随机数,y 这也是加密安全的(例如素数 p 和 q)。

我想使用带有安全随机种子的 mt19937 或 std::rand(例如 /dev/urandom 或 OpenSSL RAND_bytes 等)在这种情况下不会被视为 'cryptographically secure'(RSA )?

ISAAC 看起来很有前途,但我对如何使用它一无所知,因为我根本找不到任何文档。

值得注意的是,这也是我的第一个 C++ 项目(我之前做过一些 C、Rust 等...所以 C++ 至少感觉有点熟悉,请注意,我不是一个完全的新手)。

I suppose using mt19937 or std::rand with a secure random seed (e.g. /dev/urandom or OpenSSL RAND_bytes etc) would not be considered 'cryptographically secure' in this case (RSA)?

不,这些基本上没有任何目的的加密安全。

ISAAC looked promising but I have zero clue on how to use it since I wasn't able to find any documentation at all.

好吧,我想是时候了。但我只是使用 C++ 库,如 Crypto++ 或 Botan 或类似的东西,然后只实现 RSA 密钥对生成位,借用他们的安全随机生成器之一。幸运的是,他们还有一个 bignum 库,因此您也不必实现它。