我目前正在玩 coverity,它对 rand() 调用大喊大叫
CID 52583 (#1 of 1): Don't call (DC.WEAK_CRYPTO)
dont_call: rand() should not be used for security related applications, as linear congruential algorithms are too easy to break.
使用 urandom 返回与 rand() 相同范围内的数字的替换是否容易下降?
最佳答案
为了在我的代码中抑制有关 rand()
的 Coverity 警告,它的使用不安全相关,我提供了一个建模.c
覆盖率 modeling file到 Coverity,告诉 Coverity 忽略该函数,例如:
/* libc functions. */
int rand(void) {
/* ignore */
}
long random(void) {
/* ignore */
}
void srand(unsigned int seed) {
/* ignore */
}
对于沿着这些方向抑制的其他示例,我经常查看 Python 的 Coverity文档。
希望这对您有所帮助!
关于c - rand(), srand() 1to1替换使用urandom,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25613072/