Commit 68c8b472 authored by Alexander Camatchy's avatar Alexander Camatchy
Browse files

modif pour tp2

parent dd9d952c
Loading
Loading
Loading
Loading
+19 −0
Changes for src/bignum.c: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
#include <stdlib.h>
#include <stdio.h>
#include <gmp.h>

typedef mpz_t* bignum_t;
@@ -91,6 +92,24 @@ bignum_t bignum_pow(bignum_t x, bignum_t exp){
  return z;
}

bignum_t bignum_gcd(bignum_t a, bignum_t b){
  bignum_t g = bignum_zero();
  mpz_gcd(*g, *a, *b);
  return g;
}

bignum_t bignum_from_MD5(unsigned char* md5sum, size_t len){
  char s[100];
  size_t r = 0;
  bignum_t res = bignum_zero();

  for(size_t i = 0; i < len; i++)
    r = r + sprintf(s+r, "%x", md5sum[i]);

  mpz_set_str(*res, s, 16);
  return res;
}

char* bignum_to_str(bignum_t x){
  return mpz_get_str(NULL, 10, *x);
}
+4 −0
Changes for src/bignum.h: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -24,5 +24,9 @@ bignum_t bignum_mod(bignum_t, bignum_t);
bignum_t bignum_powm(bignum_t, bignum_t, bignum_t);
bignum_t bignum_pow(bignum_t, bignum_t);

bignum_t bignum_gcd(bignum_t, bignum_t);

bignum_t bignum_from_MD5(unsigned char* md5sum, size_t len);

char* bignum_to_str(bignum_t);
#endif

src/bignum.o

0 → 100644
+9.68 KiB

File added.

No diff preview for this file type.

src/bst.o

0 → 100644
+7.13 KiB

File added.

No diff preview for this file type.

src/hash_tbl.o

0 → 100644
+4.52 KiB

File added.

No diff preview for this file type.

Loading