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

Omon Edeki (Nowell, Inc) omon.edeki at nowellgroup.com
Tue Dec 30 11:44:00 EST 2008

I need some help writing out encrypted data to a file. I am using AES and I
started out using the standard ofstream << to write to a file; however, when
I read in the data, not everything is picked up. What is the best way to
write out encrypted data? Is it possible to use hex?


-----Original Message-----
From: botan-devel-bounces at randombit.net
[mailto:botan-devel-bounces at randombit.net] On Behalf Of Jack Lloyd
Sent: Monday, December 29, 2008 8:12 PM
To: botan-devel at randombit.net
Subject: Re: [Botan-devel] Very strange behavior when loading a private key

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
> 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
> 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

- 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()

botan-devel mailing list
botan-devel at randombit.net

More information about the botan-devel mailing list