Hi,
I'm trying to do a simple ECDSA signature and verification. Now I know that
the
ECDSA<EC2N, SHA>::PrivateKey contains the private key and
ECDSA<EC2N, SHA>::Signer contains the method SignMessage
But I can't figure out how to connect the PrivateKey object to the Signer
object.
I need something like a MakeSignerObject() method like the MakePublicKey
method.
Thanks,
Ramsey Beaini
void testECDSA()
{
ECDSA<EC2N, SHA>::PrivateKey privkey;
ECDSA<EC2N, SHA>::PublicKey pubkey;
AutoSeededRandomPool rng;
const int messageLen = 100 ;
byte message[messageLen];
ECDSA<EC2N, SHA>::Signer S(rng,ASN1::sect193r1()) ;
ECDSA<EC2N, SHA>::Verifier V;
try
{
privkey.Initialize(rng, ASN1::sect233k1());
privkey.MakePublicKey(pubkey);
SecByteBlock sig(S.SignatureLength());
try
{
S.SignMessage(rng, message, messageLen, sig);
try
{
bool result = V.VerifyMessage(message,
messageLen, sig, messageLen);
}
catch ( Exception e )
{
cout << " VerifyMessage failed " <<
e.what() << endl ;
}
}
catch ( Exception e )
{
cout <<" SignMessage failed " << e.what() << endl ;
}
}
catch ( Exception e )
{
cout << e.what() << endl ;
}
}