-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getRandomBN error when using OpenMP, if using RDSEED #57
Comments
Hi @zfscgy |
Here is a simplest example: #include <omp.h>
#include <ipcl/ipcl.hpp>
int main()
{
ipcl::KeyPair keyPair = ipcl::generateKeypair(2048);
std::vector<BigNumber> bignums;
for (size_t i = 0; i < 100; i++)
{
bignums.push_back(BigNumber(uint32_t(i)));
}
for (size_t t = 0; t < 100; t++)
{
std::cout << "Start to encrypt 100 BigNumbers ==== time " << t << std::endl;
#pragma omp parallel for
for (size_t i = 0; i < 100; i++)
{
keyPair.pub_key.encrypt(ipcl::PlainText(bignums[i]));
}
std::cout << "Encrypted 100 BigNumbers" << std::endl;
}
} And the // static const RNGenType kRNGenType = use_rdseed ? RNGenType::RDSEED
// : use_rdrand ? RNGenType::RDRAND
// : RNGenType::PSEUDO;
// #else // compile time detection of cpu feature
// #ifdef IPCL_RNG_INSTR_RDSEED
// static const RNGenType kRNGenType = RNGenType::RDSEED;
// #elif defined(IPCL_RNG_INSTR_RDRAND)
// static const RNGenType kRNGenType = RNGenType::RDRAND;
// #else
// static const RNGenType kRNGenType = RNGenType::PSEUDO;
// #endif
#endif // IPCL_RUNTIME_DETECT_CPU_FEATURES
static const RNGenType kRNGenType = RNGenType::RDSEED; // Change different random algorithms Using
|
I use OpenMP for parallel encrypting multiple plaintexts. However, after running for some time, the program crashes with
"getRandomBN: generate random big number error." This error is very weird since:
std::cout
codes in the function ippGenRandomBN for debugging. I don't know why the error could be related tostd::cout
.Finally, I was able to locate the error in the
ippsTRNGenRDSEED
function of the ipp-crypto lib. After I change theutils.hpp
to forceRNGenType kRNGenType = RNGenType::PSEUDO
, the error seems to be resolved.The text was updated successfully, but these errors were encountered: