I am having trouble initializing a CryptoPP::DSA::PublicKey object by
loading the contents of a Version 1 X.509 certificate (.cer) file
created with keytool, using SHA1withDSA and stored in binary format.
DSA::PublicKey.Load() throws "BER decode error".  I'm using Crypto++
5.4 on Windows 2000 with Visual C++ 6.0.

Is there a specific format that Crypto++ requires?  Does it only
accept a subset of the X.509 fields?

Below is a simple program that demonstrates the problem:

#define CRYPTOPP_DEFAULT_NO_DLL

#include "dll.h"
#include <config.h>
#include <cryptlib.h>
#include <rng.h>
#include <base64.h>
#include <dsa.h>

USING_NAMESPACE(CryptoPP)

int main(int argc, char* argv[])
{
        try
        {
                std::string pubKeyStr;

                FileSource certificate("test.cer", true, new 
StringSink(pubKeyStr));
                StringSource ss(pubKeyStr, true);

                DSA::PublicKey pubKey;
                pubKey.Load(ss);

                std::cout << "Loaded key successfully"
                                  << std::endl << std::flush;
        }
        catch (Exception ex)
        {
                std::cerr << "FAILED to load Public Key: "
                                  << ex.what() << std::endl << std::flush;
        }
        catch (std::exception e)
        {
                std::cerr << "FAILED to load Public Key: "
                                  << e.what() << std::endl << std::flush;
        }
        catch (...)
        {
                std::cerr << "FAILED to load Public Key, exception caught"
                                  << std::endl << std::flush;
        }

        return 0;
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to