Hi,
I m new to crypto++ library.
When I execute the following sample code, it caused core dump.
Here is the source:
#include <iostream>
#include <cryptopp/osrng.h>
#include <cryptopp/eccrypto.h>
#include <cryptopp/ec2n.h>
#include <cryptopp/oids.h>
#include <cryptopp/secblock.h>
using namespace CryptoPP;
using namespace std;
int main()
{
char m[] = "This is the message to be signed";
cout << m << endl;
AutoSeededRandomPool rng;
cout << "rng" << endl;
ECDSA<EC2N, SHA>::Signer priv(rng, ASN1::sect113r1());
cout << "ECDSA 0" << endl;
ECDSA<EC2N, SHA>::Verifier pub(priv);
cout << "ECDSA" << endl;
SecByteBlock sig(priv.SignatureLength());
cout << "SecByteBlock" << endl;
cout << "Reported signature size: " << priv.SignatureLength() << endl;
priv.SignMessage(rng, (const byte *)m, strlen(m), sig);
cout << "Signature size: " << sig.size() << endl;
if (pub.VerifyMessage((const byte *)m, strlen(m), sig.begin(), sig.size()))
cout << "OK" << endl;
else
cout << "Bad signature!!" << endl;
return 0;
}
Here is the Makefile to compile the source:
CC = g++
PTHREAD_LIBS = -lpthread
CXXFLAGS = -O -pipe -W -Wall -Wpointer-arith -D_THREAD_SAFE
INCS = -I/usr/local/include/
LIBS = /usr/local/lib/libcryptopp.a
LIBS += $(PTHREAD_LIBS)
OBJS = cryptest-simple2.o
PROGS = cryptest-simple2
all: ${PROGS}
cryptest-simple2: ${OBJS} ${LIBS}
${CC} ${CXXFLAGS} -o $@ ${OBJS} ${LIBS} ${INCS}
cryptest-simple2.o: cryptest-simple2.cpp
$(CC) $(INCS) -c $< -o $@
clean:
rm -f ${PROGS} *.o *.core
How can I correct the error?
Thanks
Sam.