Skip to content

Instantly share code, notes, and snippets.

@sjaeckel
Forked from anonymous/libtommathtest_jaeckel
Created January 2, 2012 16:21

Revisions

  1. sjaeckel revised this gist Jan 2, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions test.c
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@ void show_mp_int(mp_int *a){

    int main()
    {
    const unsigned char test="ABC";
    const char* test="ABC";
    mp_int a, b, c;
    mp_init(&a);
    show_mp_int_fullinfo(&a);
    @@ -48,7 +48,7 @@ int main()
    show_mp_int_fullinfo(&c);
    if( getch() == 'q' ) exit(0);
    **/
    mp_read_unsigned_bin(&a, test, 1);
    mp_read_unsigned_bin(&a, (unsigned char*)test, 1);
    show_mp_int_fullinfo(&a);
    getch();
    return 0;
  2. sjaeckel revised this gist Jan 2, 2012. No changes.
  3. sjaeckel renamed this gist Jan 2, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @invalid-email-address Anonymous created this gist Jan 2, 2012.
    55 changes: 55 additions & 0 deletions libtommathtest_jaeckel
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    #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;
    }