2014-04-11 05:05:59 +04:00
|
|
|
/* gen164/5/ed_sign.c
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
2014-09-04 07:10:43 +04:00
|
|
|
|
2014-04-11 05:05:59 +04:00
|
|
|
|
|
|
|
#include <ed25519.h>
|
|
|
|
|
|
|
|
/* functions
|
|
|
|
*/
|
2014-09-06 00:13:24 +04:00
|
|
|
static u3_noun
|
2015-08-28 17:14:14 +03:00
|
|
|
_cqee_sign(u3_noun a,
|
|
|
|
u3_noun b)
|
2014-04-11 05:05:59 +04:00
|
|
|
{
|
|
|
|
c3_y sig_y[64];
|
2014-04-17 07:15:49 +04:00
|
|
|
c3_y sed_y[32];
|
2014-04-19 02:34:16 +04:00
|
|
|
c3_y pub_y[64];
|
|
|
|
c3_y sec_y[64];
|
2014-04-11 05:05:59 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
c3_w mesm_w = u3r_met(3, a);
|
|
|
|
c3_w mess_w = u3r_met(3, b);
|
2014-04-11 05:05:59 +04:00
|
|
|
|
|
|
|
c3_y* mes_y = 0;
|
|
|
|
|
2014-04-19 02:34:16 +04:00
|
|
|
memset(sig_y, 0, 64);
|
|
|
|
memset(sed_y, 0, 32);
|
|
|
|
memset(pub_y, 0, 64);
|
|
|
|
memset(sec_y, 0, 64);
|
2014-04-12 04:02:10 +04:00
|
|
|
|
2014-04-19 02:34:16 +04:00
|
|
|
mes_y = malloc(mesm_w);
|
2014-04-12 04:02:10 +04:00
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
u3r_bytes(0, mesm_w, mes_y, a);
|
|
|
|
u3r_bytes(0, mess_w, sed_y, b);
|
2014-04-11 05:05:59 +04:00
|
|
|
|
2014-04-17 07:15:49 +04:00
|
|
|
ed25519_create_keypair(pub_y, sec_y, sed_y);
|
2014-04-11 05:05:59 +04:00
|
|
|
ed25519_sign(sig_y, mes_y, mesm_w, pub_y, sec_y);
|
|
|
|
free(mes_y);
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3i_bytes(64, sig_y);
|
2014-04-11 05:05:59 +04:00
|
|
|
}
|
2014-09-04 01:33:18 +04:00
|
|
|
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun
|
2014-11-06 22:13:57 +03:00
|
|
|
u3wee_sign(u3_noun cor)
|
2014-04-12 04:02:10 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun a, b;
|
2014-11-06 03:20:01 +03:00
|
|
|
if ( c3n == u3r_mean(cor,
|
2015-08-28 17:14:14 +03:00
|
|
|
u3x_sam_2, &a, u3x_sam_3, &b, 0) ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3m_bail(c3__fail);
|
2014-04-12 04:02:10 +04:00
|
|
|
} else {
|
2014-09-04 01:33:18 +04:00
|
|
|
return _cqee_sign(a, b);
|
2014-04-12 04:02:10 +04:00
|
|
|
}
|
|
|
|
}
|