On Monday, December 1, 2014 10:18:55 AM UTC-5, graeme milligan wrote:
>
> I am new to cryptopp and have been struggling for a while with the 
> creation of  private keys for ECDSA signing.
>  
> I have a private key in the format 
> "E4A6CFB431471CFCAE491FD566D19C87082CF9FA7722D7FA24B2B3F5669DBEFB". This is 
> stored as a string.
>  
> I want to use this to sign a text block using ECDSA.  My code looks a bit 
> like this
>  
> string Sig::genSignature(const string& privKeyIn, const string& messageIn)
> {
>  AutoSeededRandomPool prng;
>  ECDSA<ECP, SHA256>::PrivateKey privateKey;
>  privateKey.AccessGroupParameters().Initialize(ASN1::secp256r1());
>  privateKey.Load(StringSource(privKeyIn, true, NULL).Ref());
>  //privateKey.Save(privateKeyBQ);
>  
>  
> //privateKey.SetPrivateExponent(CryptoPP::Integer("4127861661178866478914975717021461"));
>  ECDSA<ECP, SHA256>::Signer signer(privateKey);
>  // Determine maximum size, allocate a string with that size
>  size_t siglen = signer.MaxSignatureLength();
>  string signature(siglen, 0x00);
>
>
>  byte message[] = "test";
>  unsigned int messageLen = sizeof(message);
>
>
>  // Sign, and trim signature to actual size
>  siglen = signer.SignMessage(prng, (const byte *) messageIn.data(), (
> size_t) messageIn.length(), (byte*)signature.data());
>  signature.resize(siglen);
>  cout << signature.data() << endl;
>  return signature;
> }
> This code generates the following error in Visual studio on the when I try 
> to do privateKey.load(...)
> First-chance exception at 0x7693C42D in DLLTest.exe: Microsoft C++ 
> exception: CryptoPP::BERDecodeErr at memory location 0x0033EEA8.
> Unhandled exception at 0x7693C42D in DLLTest.exe: Microsoft C++ exception: 
> CryptoPP::BERDecodeErr at memory location 0x0033EEA8.
> I amg uessing I am doing somethign a bit stupid... any help would be 
> great???
>
 
This was answered on Stack Overflow at 
http://stackoverflow.com/questions/27232053/creation-of-ecdsa-private-key-given-curve-and-private-exponent
. 

-- 
-- 
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.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to