summaryrefslogtreecommitdiffhomepage
path: root/libs/nixio/axTLS/ssl/test/datatest.c
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2009-02-22 23:19:25 +0000
committerSteven Barth <steven@midlink.org>2009-02-22 23:19:25 +0000
commitd730c1263328c5990ce46cdf6394ce6e36cc3609 (patch)
tree8dc37350e69dcbd0ca82570cfa62a4c710defc93 /libs/nixio/axTLS/ssl/test/datatest.c
parentd2b11117f26285186b711271d24733d35e0444a1 (diff)
Add axTLS sourcecode
Diffstat (limited to 'libs/nixio/axTLS/ssl/test/datatest.c')
-rw-r--r--libs/nixio/axTLS/ssl/test/datatest.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/libs/nixio/axTLS/ssl/test/datatest.c b/libs/nixio/axTLS/ssl/test/datatest.c
new file mode 100644
index 0000000000..2a5e836e5b
--- /dev/null
+++ b/libs/nixio/axTLS/ssl/test/datatest.c
@@ -0,0 +1,43 @@
+
+#include <string.h>
+#include <stdlib.h>
+#include "ssl.h"
+
+int main(int argc, char *argv[])
+{
+ bigint *m1, *m2, *d;
+ BI_CTX *ctx = bi_initialize();
+ char cmp1[1024], cmp2[1024];
+
+ const char *plaintext = /* 128 byte number */
+ "01aaaaaaaaaabbbbbbbbbbbbbbbccccccccccccccdddddddddddddeeeeeeeeee"
+ "01aaaaaaaaaabbbbbbbbbbbbbbbccccccccccccccdddddddddddddeeeeeeeeee";
+ d = bi_import(ctx, (uint8_t *)plaintext, strlen(plaintext));
+ memset(cmp1, 0, sizeof(cmp1));
+
+ while (1)
+ {
+ bi_set_mod(ctx, bi_clone(ctx, d), 0);
+ m1 = bi_square(ctx, bi_copy(d));
+ m2 = bi_residue(ctx, m1);
+ bi_free_mod(ctx, 0);
+
+ //bi_export(ctx, bi_copy(d), cmp1, sizeof(cmp1));
+ bi_export(ctx, m2, cmp2, sizeof(cmp2));
+
+ if (memcmp(cmp1, cmp2, sizeof(cmp1)) != 0)
+ {
+ printf("Error!\n"); TTY_FLUSH();
+ break;
+ }
+
+ d = bi_add(ctx, d, int_to_bi(ctx, 1));
+ }
+
+ bi_free(ctx, d);
+ bi_terminate(ctx);
+ printf("all good\n"); TTY_FLUSH();
+ return 0;
+
+}
+