[Botan-devel] "Access violation" error when creating Pipe object
with a PK_Encryptor_Filter
reen du
reendu at gmail.com
Fri Jan 25 04:25:15 EST 2008
Hi Gurus,
I am running into an "Access violation" error when trying to initiate a Pipe
object with a PK_Encryptor_Filter. I am on Windows 2000 with MS VS.Net 2003
compiler. The compiled program just throws "Exception: Access violation - no
RTTI data" after following statement:
Pipe pipe(new Botan::PK_Encryptor_Filter(get_pk_encryptor(*rsakey,
> "EME1(SHA-1)")));
I have checked that the "new
Botan::PK_Encryptor_Filter(get_pk_encryptor(*rsakey, "EME1(SHA-1)"))" did
returned a valid pointer, and the rsa key is also valid. If I replaced the
PK_Encryptor_Filter with other types of filters, say, Base64_Encoder, the
code just worked fine.
Below attached my complete code. Any pointers are highly appreciated.
Thanks a lot!
-Reen
======
> #include <iostream>
> #include <fstream>
> #include <string>
> #include <memory>
>
> #include <botan/botan.h>
> #include <botan/look_pk.h>
> #include <botan/rsa.h>
> #include <botan/secqueue.h>
> using namespace Botan;
>
> std::string b64_encode(const SecureVector<byte>&);
>
> int main(int argc, char* argv[])
> {
> if(argc != 3)
> {
> std::cout << "Usage: " << argv[0] << " keyfile messagefile" <<
> std::endl;
> return 1;
> }
>
> std::ifstream message(argv[2], std::ios::in | std::ios::binary);
> if(!message)
> {
> std::cout << "Couldn't read the message file." << std::endl;
> return 1;
> }
>
> std::string output_name(argv[2]);
> output_name += ".enc";
> std::ofstream ciphertext(output_name.c_str(), std::ios::out |
> std::ios::binary);
> if(!ciphertext)
> {
> std::cout << "Couldn't write the ciphertext to " << output_name
> << std::endl;
> return 1;
> }
>
> try {
>
> LibraryInitializer init;
>
> std::auto_ptr<X509_PublicKey> key(X509::load_key(argv[1]));
> RSA_PublicKey* rsakey = dynamic_cast<RSA_PublicKey*>(key.get());
> if(!rsakey)
> {
> std::cout << "The loaded key is not a RSA key!\n";
> return 1;
> }
>
> Pipe pipe(new Botan::PK_Encryptor_Filter(get_pk_encryptor(*rsakey,
> "EME1(SHA-1)")));
>
> return 0;
> }
> catch(std::exception& e)
> {
> std::cout << "Exception: " << e.what() << std::endl;
> }
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.randombit.net/pipermail/botan-devel/attachments/20080125/7e34955d/attachment.htm
More information about the botan-devel
mailing list