On Wed, Feb 6, 2019 at 9:49 AM <
luca.d...@cnit.it> wrote:
>
> It's correct! Tomorrow I'll take more information, but the encryption was done following the IEEE1609.2 standard and I have only a set of pcap files analyzed by wireshark.
> However tomorrow (Ihope) I'll let you know more information.
OK. But keep this in mind when you are turning the knobs. The test
program below shows r || s is 64-bytes for secp256r1.
$ ./test.exe
Private key: 3041020100301306072A8648CE3D020106082A8648CE3D030107042730250201010420D62F849A0C0B4D4E7C8BCAE0AF88C71040FD194F1D2420E076B393EF0C769CEA
Public key: 3059301306072A8648CE3D020106082A8648CE3D03010703420004B327AB1E9192FAA3AB411E9DF0D2282D8640169FF819977A78BF51E475C010DB462070A75FF5F4ADFFD9CD39211FE9795C838A5872CFFB10D9966936109ADED8
Signature: C8EC7C709F9DC7DDC0BF5AE13262CA5D9DF79A5AE65DB23E763B8D31747A1986D2C5FD636946EC4A41294D87BD78C8F4C7355605524EBA3F52E5B00DCDF788C1
Success on verify: 1
And:
$ echo -n C8EC7C709F9DC7DDC0BF5AE13262CA5D9DF79A5AE65DB23E763B8D31747A1986D2C5FD636946EC4A41294D87BD78C8F4C7355605524EBA3F52E5B00DCDF788C1
| wc -c
128
And:
$ cat test.cxx
#include "cryptlib.h"
#include "eccrypto.h"
#include "hex.h"
#include "ecp.h"
#include "oids.h"
#include "files.h"
#include "filters.h"
#include "osrng.h"
#include <string>
#include <iostream>
#include <iomanip>
int main (int argc, char* argv[])
{
using namespace CryptoPP;
AutoSeededRandomPool prng;
HexEncoder encoder(new FileSink(std::cout));
ECDSA<ECP, SHA256>::PrivateKey privKey;
privKey.Initialize(prng, ASN1::secp256r1());
ECDSA<ECP, SHA256>::PublicKey pubKey;
privKey.MakePublicKey(pubKey);
std::cout << "Private key: ";
privKey.Save(encoder);
std::cout << "\n" << std::endl;
std::cout << "Public key: ";
pubKey.Save(encoder);
std::cout << "\n" << std::endl;
std::string m, message =
"4003805520500000003101001400ba749705a41d251799c60000000000000000"
"000000000000000007d1000001029705a41d99c6405d693a403ad274803fffff"
"fc23b7743e40e11fdffffe3fe9ed073753085fffa0000000004001240000006d"
"251a3fe2";
std::string s, signature;
// Decode to binary
StringSource(message, true, new HexDecoder(new StringSink(m)));
ECDSA<ECP, SHA256>::Signer signer(privKey);
StringSource(m, true, new SignerFilter(prng, signer,
new HexEncoder(new StringSink(signature))));
// Not really needed, but we hex encoded in the signing pipeline
StringSource(signature, true, new HexDecoder(new StringSink(s)));
std::cout << "Signature: ";
StringSource(s, true, new Redirector(encoder));
std::cout << "\n" << std::endl;
bool result;
ECDSA<ECP, SHA256>::Verifier verifier(pubKey);
StringSource ss1( s+m, true, new SignatureVerificationFilter (verifier,
new ArraySink( (byte*)&result, sizeof(result))));
// Verification failure?
if (!result)
std::cout << "Error on verify: " << result << "\n" << std::endl;
else
std::cout << "Success on verify: " << result << "\n" << std::endl;
return 0;
}