Add axTLS sourcecode
[project/luci.git] / libs / nixio / axTLS / ssl / test / datatest.c
1
2 #include <string.h>
3 #include <stdlib.h>
4 #include "ssl.h"
5
6 int main(int argc, char *argv[])
7 {
8 bigint *m1, *m2, *d;
9 BI_CTX *ctx = bi_initialize();
10 char cmp1[1024], cmp2[1024];
11
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));
17
18 while (1)
19 {
20 bi_set_mod(ctx, bi_clone(ctx, d), 0);
21 m1 = bi_square(ctx, bi_copy(d));
22 m2 = bi_residue(ctx, m1);
23 bi_free_mod(ctx, 0);
24
25 //bi_export(ctx, bi_copy(d), cmp1, sizeof(cmp1));
26 bi_export(ctx, m2, cmp2, sizeof(cmp2));
27
28 if (memcmp(cmp1, cmp2, sizeof(cmp1)) != 0)
29 {
30 printf("Error!\n"); TTY_FLUSH();
31 break;
32 }
33
34 d = bi_add(ctx, d, int_to_bi(ctx, 1));
35 }
36
37 bi_free(ctx, d);
38 bi_terminate(ctx);
39 printf("all good\n"); TTY_FLUSH();
40 return 0;
41
42 }
43