6 int main(int argc
, char *argv
[])
9 BI_CTX
*ctx
= bi_initialize();
10 char cmp1
[1024], cmp2
[1024];
12 const char *plaintext
= /* 128 byte number */
13 "01aaaaaaaaaabbbbbbbbbbbbbbbccccccccccccccdddddddddddddeeeeeeeeee"
14 "01aaaaaaaaaabbbbbbbbbbbbbbbccccccccccccccdddddddddddddeeeeeeeeee";
15 d
= bi_import(ctx
, (uint8_t *)plaintext
, strlen(plaintext
));
16 memset(cmp1
, 0, sizeof(cmp1
));
20 bi_set_mod(ctx
, bi_clone(ctx
, d
), 0);
21 m1
= bi_square(ctx
, bi_copy(d
));
22 m2
= bi_residue(ctx
, m1
);
25 //bi_export(ctx, bi_copy(d), cmp1, sizeof(cmp1));
26 bi_export(ctx
, m2
, cmp2
, sizeof(cmp2
));
28 if (memcmp(cmp1
, cmp2
, sizeof(cmp1
)) != 0)
30 printf("Error!\n"); TTY_FLUSH();
34 d
= bi_add(ctx
, d
, int_to_bi(ctx
, 1));
39 printf("all good\n"); TTY_FLUSH();