Exception with ECDSA Public Key load with crypto521 package

7 views
Skip to first unread message

Srinath Sitaraman

unread,
Feb 27, 2009, 3:29:10 PM2/27/09
to cryptop...@googlegroups.com
Hi,
I have an application that's using cryptopp521 package. I am attaching herwith a portion of sample code that's the subject of concern.

I create an ECDSA<ECP, SHA>::PublicKey object, ECKpub and I use it to load the public key (please see attached binary file) which is 302 bytes long as follows:

ECKpub.Load(StringSource(pkPub, Len, true, NULL)); //Here Len = 302 and pkPub is a pointer to the public key

The Load call throws an unhandled exception. However, when I use the cryptopp552 package, I do not get an exception. Do you have any thoughts on why this is happening?! Using the crypto552 package is not an issue for me, but I am trying to understand what the problem could be, and fix if it I am doing something wrong in my code.

Thanks in advance.

Srinath
Test.cpp
PubKey.bin

Jeffrey Walton

unread,
Mar 2, 2009, 3:26:59 AM3/2/09
to Crypto++ Users
Hi Srinath,

Have you verified the key using dumpasn1 or other tool?

What happens when you use a FileSource rather than a fopen\buffer
\StringSource combination?

Jeff

From *.cpp:
BYTE *ReadFromDisk(TCHAR *FileName, DWORD *dwBufferLen)
{
unsigned char *buff = NULL;
*dwBufferLen = 0;

// Read the file and store data in pbBuffer
FILE *f = fopen(FileName, "rb");
....
}


On Feb 27, 3:29 pm, Srinath Sitaraman <srinath.sitara...@gmail.com>
wrote:
>  Test.cpp
> 1KViewDownload
>
>  PubKey.bin
> < 1KViewDownload

Srinath Sitaraman

unread,
Mar 2, 2009, 11:12:23 AM3/2/09
to Crypto++ Users
Hi Jeff,
Thanks a lot for replying.

The sample code that I sent you uses the ReadFromDisk method so that you have a short/complete working sample code. In reality, the public key is obtained by parsing a X.509 format public key certificate using an ASN.1 parser.

Also, putting this into perspective, the exception happens only with eccrypto.h from cryptopp 5.2.1 package. With cryptopp 5.5.2, there are no issues with loading this public key (with the sample code as well as with the actual sw).

My latest sw uses cryptopp 5.5.2 package, but apparently my client who first reported this problem has sw that uses cryptopp 5.2.1. Asking him to upgrade to the latest sw is not an issue, but before that I want to make sure that I am not doing something fundamentally wrong.

Also, I forgot to mention earlier, I use MSVC6 SP5.

Thanks again.
Srinath

Jeffrey Walton

unread,
Mar 2, 2009, 12:28:52 PM3/2/09
to Srinath Sitaraman, Crypto++ Users
Hi Srinath,

> parsing a X.509 format public key certificate using an ASN.1
> parser.

Out of curiosity, which parser are you using? In the past I tried
Objective Systmes. but it had a terrible time with the ITU's *.asn
files. (It seems the ITU has problems with their own files).

> eccrypto.h from cryptopp 5.2.1 package ... MSVC6 SP5
ECC and MSVC6 gave me problems in the past. Most notably, the
"Internal Compiler Error". Outside of re-arranging functions
(really!!!), I don't know what it might be.

Jeff

> > [SNIP]

Reply all
Reply to author
Forward
0 new messages