#include <iostream>

#include "osrng.h"
#include "eccrypto.h"
#include "ec2n.h"
#include "oids.h"
#include "secblock.h"

using namespace CryptoPP;
using namespace std;

int main()
{
  char m[] = "This is the message to be signed";

  AutoSeededRandomPool rng;
  
  ECDSA<EC2N, SHA>::Signer priv(rng, ASN1::sect113r1());
  
  ECDSA<EC2N, SHA>::Verifier pub(priv);

  SecByteBlock sig(priv.SignatureLength());

  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;
}

