Skip to content

Instantly share code, notes, and snippets.

Created January 2, 2012 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/1551264 to your computer and use it in GitHub Desktop.
Save anonymous/1551264 to your computer and use it in GitHub Desktop.
libtommathtest_jaeckel
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
#include"tommath.h"
/*
int mp_int_loader(mp_int *a){
}
*/
void show_mp_int_fullinfo(mp_int *a){
int i;
printf("\na.used = %d\n", a->used);
printf("a.alloc = %d\n", a->alloc);
printf("a.sign = %d\n", a->sign);
i = a->used - 1;
for(;i>=0;i--)
printf("dp[%d] = %d\n", i, a->dp[i] );
}
void show_mp_int(mp_int *a){
int i;
for(i = (a->used) - 1; i>=0; i--){
printf("dp[%d] = %d\n", i, a->dp[i] );
}
}
int main()
{
const unsigned char test="ABC";
mp_int a, b, c;
mp_init(&a);
show_mp_int_fullinfo(&a);
mp_init(&b);
show_mp_int_fullinfo(&b);
mp_init(&c);
show_mp_int_fullinfo(&c);
/**
mp_set_int(&a, 1073741824); // 268435456 // 10425
show_mp_int_fullinfo(&a);
if( getch() == 'q' ) exit(0);
mp_set(&b, 268435455); // 268435458 (prev val + 2) // 22483
show_mp_int_fullinfo(&b);
if( getch() == 'q' ) exit(0);
mp_add(&a, &b, &c);
show_mp_int_fullinfo(&c);
if( getch() == 'q' ) exit(0);
**/
mp_read_unsigned_bin(&a, test, 1);
show_mp_int_fullinfo(&a);
getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment