tags:

views:

172

answers:

2

I'm using the c++ crypto library called Botan, and at arbitrary times I am getting the following error at runtime. What does it mean?

terminate called after throwing an instance of 'Botan::PRNG_Unseeded' what(): Botan: PRNG not seeded: X9.31(AES-256)

A: 

Well it looks to me like you forgot to seed the PRNG (pseudo random number generator). Having failed to do so, the Botan library threw the aforementioned exception which seems to have caused the terminate function to be called.

1800 INFORMATION
That part is clear, but why isn't it being seeded automatically? And why is it only showing up unpredictably, instead of all the time?
Note that I am using the AutoSeeded_RNG object exclusively, so this error should not be appearing if it indeed is autoseeded.
No I do not, are you able to use a debugger to attach and replicate the issue? Maybe that will help to narrow down the problem. Sometimes it helps to simplify your code down to the minimal set that can replicate the issue
1800 INFORMATION
The only possible thing I can think of is that perhaps an object is being allocated before the LibraryInitializer object. The documentation says that things can get really screwy if that happens, including "it will be unable to do basic things like allocate memory or get random bits."Right now I am using Botan in an external source/header file that I am importing into my main program. The only global variable called in the source file is the LibraryInitializer object -- everything else is a local variable in a class or function -- so I don't see how this could be the issue.
The initialisation order of global objects in C++ is not well defined - if you had a static class or file variable, then you couldn't say for sure which one would be created first
1800 INFORMATION
I modified my program so that any private data members in classes are pointers, so I know for certain they aren't initialized before the LibraryInitializer object. I even included the "thread_safe=true" parameter since my program uses threads. Unfortunately the error still occurs.
If you are still stuck, maybe a thing to try might be to narrow down your source to a minimal example that still causes the problem and then post it as a new question here
1800 INFORMATION
A: 

The most likely answer is that you are using v 1.8.2 which had problems with its autoseeding routines. Upgrading to 1.8.4 or 1.8.5 has fixed this for everyone who had reported this problem up to now.

Jack Lloyd