[Botan-devel] Very strange behavior when loading a private key

Jack Lloyd lloyd at randombit.net
Mon Dec 29 21:12:16 EST 2008


On Sun, Dec 28, 2008 at 07:32:47PM -0500, Z. S. O. wrote:
> Could anyone check if the following three lines of code contain any obvious
> errors?
> DataSource_Stream privKeyFile("PrivateKey.txt");
> AutoSeeded_RNG rng;
> PKCS8_PrivateKey *privateKey = PKCS8::load_key(privKeyFile, rng);
> 
> For some incomprehensible reason, loading the private key causes the rest of
> my program to fail. When I comment out these lines, the program works
> absolutely fine.

I do not see anything obviously wrong. Things that might have caused
failures:

- The file "PrivateKey.txt" did not exist or could not be opened
- Seeding the RNG failed for some reason
- The contents of PrivateKey.txt were malformed in some way
- The contents were valid PKCS#8 but the key material was otherwise invalid
  (for instance, one of the primes in an RSA key were not actually prime)

In all cases an exception should have been thrown. With some C++
runtimes an uncaught exception can seem to be an abend, as normally an
uncaught exception causes the runtime to call std::terminate which in
turn, by default, calls abort()

-Jack



More information about the botan-devel mailing list