You need to use:

CryptoPP::StringSource decoder( prvkey, true, new
CryptoPP::HexDecoder);
temp1.AccessKey().Load( decoder );

Remember that information flows from left to right in a Crypto++
pipeline, like Unix pipes.

Jeffrey Walton wrote:
THIS WORKS. Any idea why? What is the negative interaction between the
HexDecoder and StringSource in the previous cases?

{ // BER Decode Private Key
   CryptoPP::HexDecoder decoder;
   decoder.Put( (byte*)prvkey.c_str(), prvkey.size() );
   decoder.MessageEnd();

   temp1.AccessKey().Load( decoder );

   std::cout << "Dumping Public Key..." << std::endl;
   DumpPublicKey( temp1 );
}

Jeff

Jeffrey Walton wrote:
> Hi Wei,
>
> Here are the details... b = '3': This is the first byte of the string or file.
>
> // asn.cpp
> void BERGeneralDecoder::Init(byte asnTag)
>     byte b;
>     if (!m_inQueue.Get(b) || b != asnTag)
>        BERDecodeError(); <=== Blow Up, b = '3', asnTag = '0'
>
>     if (!BERLengthDecode(m_inQueue, m_length, m_definiteLength))
>        BERDecodeError();
>
> m_length = 14757... (20 decimal digits)
> m_definiteLength = true
>
> m_length = 14757... (20 decimal digits)
> m_definiteLength = true
>
> Jeff
>
> { // Broke
>    temp2.AccessKey().Load(
>       CryptoPP::HexDecoder(
>          new CryptoPP::StringSource( pubkey, true )
>       )
>    );
> }
>
> { // Broke
>    temp2.AccessKey().Load(
>       CryptoPP::HexDecoder(
>          new CryptoPP::FileSource( "rsa400pb.dat", true )
>       )
>    );
> }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Crypto++ 
Users" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cryptopp-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to