Re: ECDSA - i can help with code
Thanks for your feedbacks!
I'll look into it.
not include ECDSA into recent PuTTY 0.64 release. I'm sure there's a reason for that.
#include "ec.h"
...
size_t rsize;
uint8_t rnd[70], priv_key[70], pub_key_x[70], pub_key_y[70], sign_r[70], sign_s[70];
ec_curve_t curve;
/* SHA-1("abc") = "a9993e364706816aba3e25717850c26c9cd0d89d" */ uint8_t hash_abc[20] = {0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d};
/* Get curve params by name. */
if (0 != ec_curve_from_str(ec_curve_str_get_by_name((uint8_t*)"secp192r1", 9), &curve))
return (-1);
/* Generating keys. */
memset(rnd, 173, sizeof(rnd));/* XXX rand!!! */
if (0 != ec_key_gen(rnd, sizeof(rnd), &curve, priv_key, pub_key_x, pub_key_y, &rsize))
return (-1); /* Error! */
/* Sign */
memset(rnd, 73, sizeof(rnd));/* XXX rand!!! */
if (0 != ec_sign((uint8_t*)hash_abc, 20, priv_key, rsize, rnd, sizeof(rnd), &curve, sign_r, sign_s, &rsize))
return (-1); /* Error! */
/* Verify */
if (0 != ec_verify(&curve, pub_key_x, pub_key_y, rsize, (uint8_t*)hash_abc, 20, sign_r, sign_s, rsize))
return (-1); /* Error! */