math: change get_digit() return value
unsigned long is 32bit wide when compiling with the compiler flag "-mx32" but the digit size of the math libraries is still 64 bit which lead to the buggy ecc code. Therefore define a new type ltc_mp_digit with the correct width and use that as return value of get_digit() Has been tested with all three math providers
This commit is contained in:
		
							parent
							
								
									1793072c67
								
							
						
					
					
						commit
						f597f29ece
					
				| @ -122,6 +122,11 @@ typedef ulong32 __attribute__((__may_alias__)) LTC_FAST_TYPE; | ||||
|   #endif | ||||
| #endif | ||||
| 
 | ||||
| #ifdef ENDIAN_64BITWORD | ||||
| typedef ulong64 ltc_mp_digit; | ||||
| #else | ||||
| typedef ulong32 ltc_mp_digit; | ||||
| #endif | ||||
| 
 | ||||
| #ifdef LTC_NO_FAST | ||||
|    #ifdef LTC_FAST | ||||
|  | ||||
| @ -80,7 +80,7 @@ typedef struct { | ||||
|      @param n  The number of the digit to fetch | ||||
|      @return  The bits_per_digit  sized n'th digit of a | ||||
|    */ | ||||
|    unsigned long (*get_digit)(void *a, int n); | ||||
|    ltc_mp_digit (*get_digit)(void *a, int n); | ||||
| 
 | ||||
|    /** Get the number of digits that represent the number
 | ||||
|      @param a   The number to count | ||||
|  | ||||
| @ -74,7 +74,7 @@ static unsigned long get_int(void *a) | ||||
|    return mpz_get_ui(a); | ||||
| } | ||||
| 
 | ||||
| static unsigned long get_digit(void *a, int n) | ||||
| static ltc_mp_digit get_digit(void *a, int n) | ||||
| { | ||||
|    LTC_ARGCHK(a != NULL); | ||||
|    return mpz_getlimbn(a, n); | ||||
|  | ||||
| @ -100,7 +100,7 @@ static unsigned long get_int(void *a) | ||||
|    return mp_get_int(a); | ||||
| } | ||||
| 
 | ||||
| static unsigned long get_digit(void *a, int n) | ||||
| static ltc_mp_digit get_digit(void *a, int n) | ||||
| { | ||||
|    mp_int *A; | ||||
|    LTC_ARGCHK(a != NULL); | ||||
|  | ||||
| @ -99,7 +99,7 @@ static unsigned long get_int(void *a) | ||||
|    return A->used > 0 ? A->dp[0] : 0; | ||||
| } | ||||
| 
 | ||||
| static unsigned long get_digit(void *a, int n) | ||||
| static ltc_mp_digit get_digit(void *a, int n) | ||||
| { | ||||
|    fp_int *A; | ||||
|    LTC_ARGCHK(a != NULL); | ||||
|  | ||||
| @ -41,7 +41,7 @@ int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map) | ||||
|    ecc_point *tG, *M[8]; | ||||
|    int        i, j, err; | ||||
|    void       *mu, *mp; | ||||
|    unsigned long buf; | ||||
|    ltc_mp_digit buf; | ||||
|    int        first, bitbuf, bitcpy, bitcnt, mode, digidx; | ||||
| 
 | ||||
|    LTC_ARGCHK(k       != NULL); | ||||
|  | ||||
| @ -39,7 +39,7 @@ int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map) | ||||
|    ecc_point *tG, *M[3]; | ||||
|    int        i, j, err; | ||||
|    void       *mu, *mp; | ||||
|    unsigned long buf; | ||||
|    ltc_mp_digit buf; | ||||
|    int        bitcnt, mode, digidx; | ||||
| 
 | ||||
|    LTC_ARGCHK(k       != NULL); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user