2014-05-29 02:40:21 +04:00
|
|
|
/* gen164/5/ed_veri.c
|
2014-04-13 06:59:02 +04:00
|
|
|
**
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
2014-09-04 07:10:43 +04:00
|
|
|
|
2014-04-13 06:59:02 +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_veri(u3_noun s,
|
|
|
|
u3_noun m,
|
|
|
|
u3_noun pk)
|
2014-04-13 06:59:02 +04:00
|
|
|
{
|
|
|
|
c3_y sig_y[64];
|
2014-04-30 04:26:44 +04:00
|
|
|
c3_y pub_y[32];
|
|
|
|
c3_w ret;
|
2014-04-13 06:59:02 +04:00
|
|
|
c3_y* mes_y;
|
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
c3_w mesm_w = u3r_met(3, m);
|
2014-04-19 02:34:16 +04:00
|
|
|
|
|
|
|
memset(sig_y, 0, 64);
|
2014-04-30 04:26:44 +04:00
|
|
|
memset(pub_y, 0, 32);
|
2014-04-19 02:34:16 +04:00
|
|
|
|
2014-04-13 06:59:02 +04:00
|
|
|
mes_y = c3_malloc(mesm_w);
|
|
|
|
|
2014-11-06 03:20:01 +03:00
|
|
|
u3r_bytes(0, 64, sig_y, s);
|
|
|
|
u3r_bytes(0, 32, pub_y, pk);
|
|
|
|
u3r_bytes(0, mesm_w, mes_y, m);
|
2014-04-13 06:59:02 +04:00
|
|
|
|
2014-11-05 04:18:47 +03:00
|
|
|
ret = ed25519_verify(sig_y, mes_y, mesm_w, pub_y) == 1 ? c3y : c3n;
|
2014-04-13 06:59:02 +04:00
|
|
|
free(mes_y);
|
|
|
|
return ret;
|
|
|
|
}
|
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_veri(u3_noun cor)
|
2014-04-13 06:59:02 +04:00
|
|
|
{
|
2014-09-06 00:13:24 +04:00
|
|
|
u3_noun a, b, c;
|
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_6, &b,
|
|
|
|
u3x_sam_7, &c, 0) ) {
|
2014-11-06 03:20:01 +03:00
|
|
|
return u3m_bail(c3__fail);
|
2014-04-13 06:59:02 +04:00
|
|
|
} else {
|
2014-09-04 01:33:18 +04:00
|
|
|
return _cqee_veri(a, b, c);
|
2014-04-13 06:59:02 +04:00
|
|
|
}
|
|
|
|
}
|