0

I have to get ECDSA signature in variable using Crypto++.
I tried to get it after launching SignMessage but signature is empty.
How could i get it?

Blacktempel
  • 3,935
  • 3
  • 29
  • 53
user3175204
  • 23
  • 1
  • 7

1 Answers1

1

Have you had a look at the Crypto++ wiki? There's a lot of stuff on Elliptic Curve Digital Signature Algorithm.

Its not really clear what you are doing or where things went wrong, so here's a copy and paste from the wiki:

Signing:

ECDSA<ECP, SHA1>::PrivateKey privateKey;
privateKey.Load(...);

AutoSeededRandomPool prng;
string message = "Yoda said, Do or do not. There is no try.";
string signature;

StringSource ss1( message, true /*pump all*/,
    new SignerFilter( prng,
        ECDSA<ECP,SHA1>::Signer( privateKey ),
        new StringSink( signature )
    ) // SignerFilter
); // StringSource

Verification:

ECDSA<ECP, SHA1>::PublicKey publicKey;
publicKey.Load(...);

// Result of the verification process
bool result = false;

// Exactly what was signed in the previous step
string message = ...;
// Output from the signing operation in the previous step
string signature = ...;

StringSource ss2( signature+message, true /*pump all*/,
    new SignatureVerificationFilter(
        ECDSA<ECP,SHA1>::Verifier(publicKey),
        new ArraySink( (byte*)&result, sizeof(result) )
    ) // SignatureVerificationFilter
);

// Verification failure?
if( !result ) {...}

If you would like the verifcation to throw on a failure, then try:

static const int VERIFICATION_FLAGS = SIGNATURE_AT_BEGIN | THROW_EXCEPTION;
StringSource ss3( signature+message, true /*pump all*/,
    new SignatureVerificationFilter(
        ECDSA<ECP,SHA1>::Verifier(publicKey),
        NULL, /* No need for attached filter */
        VERIFICATION_FLAGS
    ) // SignatureVerificationFilter
);
jww
  • 97,681
  • 90
  • 411
  • 885