use ltc_mp_digit instead of unsigned long

This commit is contained in:
Steffen Jaeckel 2017-06-12 13:07:12 +02:00
parent d6e2a585d0
commit 258de3cecc
4 changed files with 24 additions and 24 deletions

View File

@ -67,7 +67,7 @@ typedef struct {
@param n Source upto bits_per_digit (actually meant for very small constants) @param n Source upto bits_per_digit (actually meant for very small constants)
@return CRYPT_OK on success @return CRYPT_OK on success
*/ */
int (*set_int)(void *a, unsigned long n); int (*set_int)(void *a, ltc_mp_digit n);
/** get small constant /** get small constant
@param a Small number to read, @param a Small number to read,
@ -105,7 +105,7 @@ typedef struct {
LTC_MP_GT if a > b and LTC_MP_GT if a > b and
LTC_MP_EQ otherwise. (signed comparison) LTC_MP_EQ otherwise. (signed comparison)
*/ */
int (*compare_d)(void *a, unsigned long n); int (*compare_d)(void *a, ltc_mp_digit n);
/** Count the number of bits used to represent the integer /** Count the number of bits used to represent the integer
@param a The integer to count @param a The integer to count
@ -184,7 +184,7 @@ typedef struct {
@param c The destination of "a + b" @param c The destination of "a + b"
@return CRYPT_OK on success @return CRYPT_OK on success
*/ */
int (*addi)(void *a, unsigned long b, void *c); int (*addi)(void *a, ltc_mp_digit b, void *c);
/** subtract two integers /** subtract two integers
@param a The first source integer @param a The first source integer
@ -201,7 +201,7 @@ typedef struct {
@param c The destination of "a - b" @param c The destination of "a - b"
@return CRYPT_OK on success @return CRYPT_OK on success
*/ */
int (*subi)(void *a, unsigned long b, void *c); int (*subi)(void *a, ltc_mp_digit b, void *c);
/** multiply two integers /** multiply two integers
@param a The first source integer @param a The first source integer
@ -219,7 +219,7 @@ typedef struct {
@param c The destination of "a * b" @param c The destination of "a * b"
@return CRYPT_OK on success @return CRYPT_OK on success
*/ */
int (*muli)(void *a, unsigned long b, void *c); int (*muli)(void *a, ltc_mp_digit b, void *c);
/** Square an integer /** Square an integer
@param a The integer to square @param a The integer to square
@ -250,7 +250,7 @@ typedef struct {
@param c The destination for the residue @param c The destination for the residue
@return CRYPT_OK on success @return CRYPT_OK on success
*/ */
int (*modi)(void *a, unsigned long b, unsigned long *c); int (*modi)(void *a, ltc_mp_digit b, ltc_mp_digit *c);
/** gcd /** gcd
@param a The first integer @param a The first integer

View File

@ -61,7 +61,7 @@ static int init_copy(void **a, void *b)
} }
/* ---- trivial ---- */ /* ---- trivial ---- */
static int set_int(void *a, unsigned long b) static int set_int(void *a, ltc_mp_digit b)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
mpz_set_ui(((__mpz_struct *)a), b); mpz_set_ui(((__mpz_struct *)a), b);
@ -101,7 +101,7 @@ static int compare(void *a, void *b)
} }
} }
static int compare_d(void *a, unsigned long b) static int compare_d(void *a, ltc_mp_digit b)
{ {
int ret; int ret;
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
@ -235,7 +235,7 @@ static int add(void *a, void *b, void *c)
return CRYPT_OK; return CRYPT_OK;
} }
static int addi(void *a, unsigned long b, void *c) static int addi(void *a, ltc_mp_digit b, void *c)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
LTC_ARGCHK(c != NULL); LTC_ARGCHK(c != NULL);
@ -253,7 +253,7 @@ static int sub(void *a, void *b, void *c)
return CRYPT_OK; return CRYPT_OK;
} }
static int subi(void *a, unsigned long b, void *c) static int subi(void *a, ltc_mp_digit b, void *c)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
LTC_ARGCHK(c != NULL); LTC_ARGCHK(c != NULL);
@ -271,7 +271,7 @@ static int mul(void *a, void *b, void *c)
return CRYPT_OK; return CRYPT_OK;
} }
static int muli(void *a, unsigned long b, void *c) static int muli(void *a, ltc_mp_digit b, void *c)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
LTC_ARGCHK(c != NULL); LTC_ARGCHK(c != NULL);
@ -317,7 +317,7 @@ static int div_2(void *a, void *b)
} }
/* modi */ /* modi */
static int modi(void *a, unsigned long b, unsigned long *c) static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
LTC_ARGCHK(c != NULL); LTC_ARGCHK(c != NULL);

View File

@ -88,7 +88,7 @@ static int init_copy(void **a, void *b)
} }
/* ---- trivial ---- */ /* ---- trivial ---- */
static int set_int(void *a, unsigned long b) static int set_int(void *a, ltc_mp_digit b)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
return mpi_to_ltc_error(mp_set_int(a, b)); return mpi_to_ltc_error(mp_set_int(a, b));
@ -130,7 +130,7 @@ static int compare(void *a, void *b)
} }
} }
static int compare_d(void *a, unsigned long b) static int compare_d(void *a, ltc_mp_digit b)
{ {
int ret; int ret;
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
@ -212,7 +212,7 @@ static int add(void *a, void *b, void *c)
return mpi_to_ltc_error(mp_add(a, b, c)); return mpi_to_ltc_error(mp_add(a, b, c));
} }
static int addi(void *a, unsigned long b, void *c) static int addi(void *a, ltc_mp_digit b, void *c)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
LTC_ARGCHK(c != NULL); LTC_ARGCHK(c != NULL);
@ -228,7 +228,7 @@ static int sub(void *a, void *b, void *c)
return mpi_to_ltc_error(mp_sub(a, b, c)); return mpi_to_ltc_error(mp_sub(a, b, c));
} }
static int subi(void *a, unsigned long b, void *c) static int subi(void *a, ltc_mp_digit b, void *c)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
LTC_ARGCHK(c != NULL); LTC_ARGCHK(c != NULL);
@ -244,7 +244,7 @@ static int mul(void *a, void *b, void *c)
return mpi_to_ltc_error(mp_mul(a, b, c)); return mpi_to_ltc_error(mp_mul(a, b, c));
} }
static int muli(void *a, unsigned long b, void *c) static int muli(void *a, ltc_mp_digit b, void *c)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
LTC_ARGCHK(c != NULL); LTC_ARGCHK(c != NULL);
@ -275,7 +275,7 @@ static int div_2(void *a, void *b)
} }
/* modi */ /* modi */
static int modi(void *a, unsigned long b, unsigned long *c) static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
{ {
mp_digit tmp; mp_digit tmp;
int err; int err;

View File

@ -84,7 +84,7 @@ static int init_copy(void **a, void *b)
} }
/* ---- trivial ---- */ /* ---- trivial ---- */
static int set_int(void *a, unsigned long b) static int set_int(void *a, ltc_mp_digit b)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
fp_set(a, b); fp_set(a, b);
@ -129,7 +129,7 @@ static int compare(void *a, void *b)
return 0; return 0;
} }
static int compare_d(void *a, unsigned long b) static int compare_d(void *a, ltc_mp_digit b)
{ {
int ret; int ret;
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
@ -214,7 +214,7 @@ static int add(void *a, void *b, void *c)
return CRYPT_OK; return CRYPT_OK;
} }
static int addi(void *a, unsigned long b, void *c) static int addi(void *a, ltc_mp_digit b, void *c)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
LTC_ARGCHK(c != NULL); LTC_ARGCHK(c != NULL);
@ -232,7 +232,7 @@ static int sub(void *a, void *b, void *c)
return CRYPT_OK; return CRYPT_OK;
} }
static int subi(void *a, unsigned long b, void *c) static int subi(void *a, ltc_mp_digit b, void *c)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
LTC_ARGCHK(c != NULL); LTC_ARGCHK(c != NULL);
@ -250,7 +250,7 @@ static int mul(void *a, void *b, void *c)
return CRYPT_OK; return CRYPT_OK;
} }
static int muli(void *a, unsigned long b, void *c) static int muli(void *a, ltc_mp_digit b, void *c)
{ {
LTC_ARGCHK(a != NULL); LTC_ARGCHK(a != NULL);
LTC_ARGCHK(c != NULL); LTC_ARGCHK(c != NULL);
@ -284,7 +284,7 @@ static int div_2(void *a, void *b)
} }
/* modi */ /* modi */
static int modi(void *a, unsigned long b, unsigned long *c) static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
{ {
fp_digit tmp; fp_digit tmp;
int err; int err;