Pārlūkot izejas kodu

Constify all the functions in ltc_math_descriptor appropriately

This includes amending the documentation in doc/crypt.tex
This also includes removing unnecessary casts in src/math/*.c
Richard Levitte 1 gadu atpakaļ
vecāks
revīzija
88315ff8df

+ 64 - 58
doc/crypt.tex

@@ -9537,7 +9537,7 @@ it hasn't proven hard to write \textit{glue} to use math libraries so far.  The
 /** math descriptor */
 typedef struct {
    /** Name of the math provider */
-   char *name;
+   const char *name;
 
    /** Bits per digit, amount of bits must fit in an unsigned long */
    int  bits_per_digit;
@@ -9555,7 +9555,7 @@ typedef struct {
      @param  src    The number to copy from
      @return CRYPT_OK on success
    */
-   int (*init_copy)(void **dst, void *src);
+   int (*init_copy)(void **dst, const void *src);
 
    /** deinit
       @param   a    The number to free
@@ -9570,14 +9570,14 @@ typedef struct {
       @param   dst   The destination
       @return CRYPT_OK on success
    */
-   int (*neg)(void *src, void *dst);
+   int (*neg)(const void *src, void *dst);
 
    /** copy
       @param   src   The number to copy from
       @param   dst   The number to write to
       @return CRYPT_OK on success
    */
-   int (*copy)(void *src, void *dst);
+   int (*copy)(const void *src, void *dst);
 
 /* ---- trivial low level functions ---- */
 
@@ -9593,20 +9593,20 @@ typedef struct {
                 only fetches up to bits_per_digit from the number
       @return   The lower bits_per_digit of the integer (unsigned)
    */
-   unsigned long (*get_int)(void *a);
+   unsigned long (*get_int)(const void *a);
 
    /** get digit n
      @param a  The number to read from
      @param n  The number of the digit to fetch
      @return  The bits_per_digit  sized n'th digit of a
    */
-   ltc_mp_digit (*get_digit)(void *a, int n);
+   ltc_mp_digit (*get_digit)(const void *a, int n);
 
    /** Get the number of digits that represent the number
      @param a   The number to count
      @return The number of digits used to represent the number
    */
-   int (*get_digit_count)(void *a);
+   int (*get_digit_count)(const void *a);
 
    /** compare two integers
      @param a   The left side integer
@@ -9615,7 +9615,7 @@ typedef struct {
              LTC_MP_GT if a > b and
              LTC_MP_EQ otherwise.  (signed comparison)
    */
-   int (*compare)(void *a, void *b);
+   int (*compare)(const void *a, const void *b);
 
    /** compare against int
      @param a   The left side integer
@@ -9624,19 +9624,19 @@ typedef struct {
              LTC_MP_GT if a > b and
              LTC_MP_EQ otherwise.  (signed comparison)
    */
-   int (*compare_d)(void *a, unsigned long n);
+   int (*compare_d)(const void *a, unsigned long n);
 
    /** Count the number of bits used to represent the integer
      @param a   The integer to count
      @return The number of bits required to represent the integer
    */
-   int (*count_bits)(void * a);
+   int (*count_bits)(const void * a);
 
    /** Count the number of LSB bits which are zero
      @param a   The integer to count
      @return The number of contiguous zero LSB bits
    */
-   int (*count_lsb_bits)(void *a);
+   int (*count_lsb_bits)(const void *a);
 
    /** Compute a power of two
      @param a  The integer to store the power in
@@ -9661,20 +9661,20 @@ typedef struct {
      @param radix The radix the integer is to be represented in (2-64)
      @return CRYPT_OK on success
    */
-   int (*write_radix)(void *a, char *str, int radix);
+   int (*write_radix)(const void *a, char *str, int radix);
 
    /** get size as unsigned char string
      @param a  The integer to get the size (when stored in array of octets)
      @return   The length of the integer in octets
    */
-   unsigned long (*unsigned_size)(void *a);
+   unsigned long (*unsigned_size)(const void *a);
 
    /** store an integer as an array of octets
      @param src   The integer to store
      @param dst   The buffer to store the integer in
      @return CRYPT_OK on success
    */
-   int (*unsigned_write)(void *src, unsigned char *dst);
+   int (*unsigned_write)(const void *src, unsigned char *dst);
 
    /** read an array of octets and store as integer
      @param dst   The integer to load
@@ -9682,9 +9682,9 @@ typedef struct {
      @param len   The number of octets
      @return CRYPT_OK on success
    */
-   int (*unsigned_read)(         void *dst,
-                        unsigned char *src,
-                        unsigned long  len);
+   int (*unsigned_read)(               void *dst,
+                        const unsigned char *src,
+                              unsigned long  len);
 
 /* ---- basic math ---- */
 
@@ -9694,7 +9694,7 @@ typedef struct {
      @param c   The destination of "a + b"
      @return CRYPT_OK on success
    */
-   int (*add)(void *a, void *b, void *c);
+   int (*add)(const void *a, const void *b, void *c);
 
    /** add two integers
      @param a   The first source integer
@@ -9703,7 +9703,7 @@ typedef struct {
      @param c   The destination of "a + b"
      @return CRYPT_OK on success
    */
-   int (*addi)(void *a, unsigned long b, void *c);
+   int (*addi)(const void *a, unsigned long b, void *c);
 
    /** subtract two integers
      @param a   The first source integer
@@ -9711,7 +9711,7 @@ typedef struct {
      @param c   The destination of "a - b"
      @return CRYPT_OK on success
    */
-   int (*sub)(void *a, void *b, void *c);
+   int (*sub)(const void *a, const void *b, void *c);
 
    /** subtract two integers
      @param a   The first source integer
@@ -9720,7 +9720,7 @@ typedef struct {
      @param c   The destination of "a - b"
      @return CRYPT_OK on success
    */
-   int (*subi)(void *a, unsigned long b, void *c);
+   int (*subi)(const void *a, unsigned long b, void *c);
 
    /** multiply two integers
      @param a   The first source integer
@@ -9729,7 +9729,7 @@ typedef struct {
      @param c   The destination of "a * b"
      @return CRYPT_OK on success
    */
-   int (*mul)(void *a, void *b, void *c);
+   int (*mul)(const void *a, const void *b, void *c);
 
    /** multiply two integers
      @param a   The first source integer
@@ -9738,14 +9738,14 @@ typedef struct {
      @param c   The destination of "a * b"
      @return CRYPT_OK on success
    */
-   int (*muli)(void *a, unsigned long b, void *c);
+   int (*muli)(const void *a, unsigned long b, void *c);
 
    /** Square an integer
      @param a    The integer to square
      @param b    The destination
      @return CRYPT_OK on success
    */
-   int (*sqr)(void *a, void *b);
+   int (*sqr)(const void *a, void *b);
 
    /** Divide an integer
      @param a    The dividend
@@ -9754,14 +9754,14 @@ typedef struct {
      @param d    The remainder (can be NULL to signify don't care)
      @return CRYPT_OK on success
    */
-   int (*mpdiv)(void *a, void *b, void *c, void *d);
+   int (*mpdiv)(const void *a, const void *b, void *c, void *d);
 
    /** divide by two
       @param  a   The integer to divide (shift right)
       @param  b   The destination
       @return CRYPT_OK on success
    */
-   int (*div_2)(void *a, void *b);
+   int (*div_2)(const void *a, void *b);
 
    /** Get remainder (small value)
       @param  a    The integer to reduce
@@ -9769,7 +9769,7 @@ typedef struct {
       @param  c    The destination for the residue
       @return CRYPT_OK on success
    */
-   int (*modi)(void *a, unsigned long b, unsigned long *c);
+   int (*modi)(const void *a, unsigned long b, unsigned long *c);
 
    /** gcd
       @param  a     The first integer
@@ -9777,7 +9777,7 @@ typedef struct {
       @param  c     The destination for (a, b)
       @return CRYPT_OK on success
    */
-   int (*gcd)(void *a, void *b, void *c);
+   int (*gcd)(const void *a, const void *b, void *c);
 
    /** lcm
       @param  a     The first integer
@@ -9785,7 +9785,7 @@ typedef struct {
       @param  c     The destination for [a, b]
       @return CRYPT_OK on success
    */
-   int (*lcm)(void *a, void *b, void *c);
+   int (*lcm)(const void *a, const void *b, void *c);
 
    /** Modular multiplication
       @param  a     The first source
@@ -9794,7 +9794,7 @@ typedef struct {
       @param  d     The destination (a*b mod c)
       @return CRYPT_OK on success
    */
-   int (*mulmod)(void *a, void *b, void *c, void *d);
+   int (*mulmod)(const void *a, const void *b, const void *c, void *d);
 
    /** Modular squaring
       @param  a     The first source
@@ -9802,7 +9802,7 @@ typedef struct {
       @param  c     The destination (a*a mod b)
       @return CRYPT_OK on success
    */
-   int (*sqrmod)(void *a, void *b, void *c);
+   int (*sqrmod)(const void *a, const void *b, void *c);
 
    /** Modular inversion
       @param  a     The value to invert
@@ -9810,7 +9810,7 @@ typedef struct {
       @param  c     The destination (1/a mod b)
       @return CRYPT_OK on success
    */
-   int (*invmod)(void *, void *, void *);
+   int (*invmod)(const void *a, const void *b, void *c);
 
 /* ---- reduction ---- */
 
@@ -9819,14 +9819,14 @@ typedef struct {
        @param b  The destination for the reduction digit
        @return CRYPT_OK on success
    */
-   int (*montgomery_setup)(void *a, void **b);
+   int (*montgomery_setup)(const void *a, void **b);
 
    /** get normalization value
        @param a   The destination for the normalization value
        @param b   The modulus
        @return  CRYPT_OK on success
    */
-   int (*montgomery_normalization)(void *a, void *b);
+   int (*montgomery_normalization)(void *a, const void *b);
 
    /** reduce a number
        @param a   The number [and dest] to reduce
@@ -9834,7 +9834,7 @@ typedef struct {
        @param c   The value "b" from montgomery_setup()
        @return CRYPT_OK on success
    */
-   int (*montgomery_reduce)(void *a, void *b, void *c);
+   int (*montgomery_reduce)(void *a, const void *b, void *c);
 
    /** clean up  (frees memory)
        @param a   The value "b" from montgomery_setup()
@@ -9851,7 +9851,7 @@ typedef struct {
        @param d    The destination
        @return CRYPT_OK on success
    */
-   int (*exptmod)(void *a, void *b, void *c, void *d);
+   int (*exptmod)(const void *a, const void *b, const void *c, void *d);
 
    /** Primality testing
        @param a     The integer to test
@@ -9859,7 +9859,7 @@ typedef struct {
        @param c     The destination of the result (FP_YES if prime)
        @return CRYPT_OK on success
    */
-   int (*isprime)(void *a, int b, int *c);
+   int (*isprime)(const void *a, int b, int *c);
 
 /* ----  (optional) ecc point math ---- */
 
@@ -9867,42 +9867,48 @@ typedef struct {
        @param k   The integer to multiply the point by
        @param G   The point to multiply
        @param R   The destination for kG
+       @param a   ECC curve parameter a
        @param modulus  The modulus for the field
        @param map Boolean indicated whether to map back to affine or not
                   (can be ignored if you work in affine only)
        @return CRYPT_OK on success
    */
-   int (*ecc_ptmul)(     void *k,
-                    ecc_point *G,
-                    ecc_point *R,
-                         void *modulus,
+   int (*ecc_ptmul)(     const void *k,
+                    const ecc_point *G,
+                          ecc_point *R,
+                         const void *a,
+                         const void *modulus,
                           int  map);
 
    /** ECC GF(p) point addition
        @param P    The first point
        @param Q    The second point
        @param R    The destination of P + Q
+       @param ma   The curve parameter "a" in montgomery form
        @param modulus  The modulus
        @param mp   The "b" value from montgomery_setup()
        @return CRYPT_OK on success
    */
-   int (*ecc_ptadd)(ecc_point *P,
-                    ecc_point *Q,
-                    ecc_point *R,
-                         void *modulus,
-                         void *mp);
+   int (*ecc_ptadd)(const ecc_point *P,
+                    const ecc_point *Q,
+                          ecc_point *R,
+                         const void *ma,
+                         const void *modulus,
+                               void *mp);
 
    /** ECC GF(p) point double
        @param P    The first point
        @param R    The destination of 2P
+       @param ma   The curve parameter "a" in montgomery form
        @param modulus  The modulus
        @param mp   The "b" value from montgomery_setup()
        @return CRYPT_OK on success
    */
-   int (*ecc_ptdbl)(ecc_point *P,
-                    ecc_point *R,
-                         void *modulus,
-                         void *mp);
+   int (*ecc_ptdbl)(const ecc_point *P,
+                          ecc_point *R,
+                         const void *ma,
+                         const void *modulus,
+                               void *mp);
 
    /** ECC mapping from projective to affine,
        currently uses (x,y,z) => (x/z^2, y/z^3, 1)
@@ -9914,7 +9920,7 @@ typedef struct {
                ecc_point only has three integers (x,y,z) so if
                you use a different mapping you have to make it fit.
    */
-   int (*ecc_map)(ecc_point *P, void *modulus, void *mp);
+   int (*ecc_map)(ecc_point *P, const void *modulus, void *mp);
 
    /** Computes kA*A + kB*B = C using Shamir's Trick
        @param A        First point to multiply
@@ -9925,10 +9931,10 @@ typedef struct {
        @param modulus  Modulus for curve
        @return CRYPT_OK on success
    */
-   int (*ecc_mul2add)(ecc_point *A, void *kA,
-                      ecc_point *B, void *kB,
-                      ecc_point *C,
-                           void *modulus);
+   int (*ecc_mul2add)(const ecc_point *A, void *kA,
+                      const ecc_point *B, void *kB,
+                            ecc_point *C,
+                           const void *modulus);
 
 /* ---- (optional) rsa optimized math (for internal CRT) ---- */
 
@@ -9959,7 +9965,7 @@ typedef struct {
    */
    int (*rsa_me)(const unsigned char *in,   unsigned long inlen,
                        unsigned char *out,  unsigned long *outlen, int which,
-                       rsa_key *key);
+                 const rsa_key *key);
 
 /* ---- basic math continued ---- */
 
@@ -9970,7 +9976,7 @@ typedef struct {
       @param  d     The destination (a + b mod c)
       @return CRYPT_OK on success
    */
-   int (*addmod)(void *a, void *b, void *c, void *d);
+   int (*addmod)(const void *a, const void *b, const void *c, void *d);
 
    /** Modular substraction
       @param  a     The first source
@@ -9979,7 +9985,7 @@ typedef struct {
       @param  d     The destination (a - b mod c)
       @return CRYPT_OK on success
    */
-   int (*submod)(void *a, void *b, void *c, void *d);
+   int (*submod)(const void *a, const void *b, const void *c, void *d);
 
 /* ---- misc stuff ---- */
 

+ 49 - 49
src/headers/tomcrypt_math.h

@@ -48,7 +48,7 @@ typedef struct {
      @param  src    The number to copy from
      @return CRYPT_OK on success
    */
-   int (*init_copy)(void **dst, void *src);
+   int (*init_copy)(void **dst, const void *src);
 
    /** deinit
       @param   a    The number to free
@@ -63,14 +63,14 @@ typedef struct {
       @param   dst   The destination
       @return CRYPT_OK on success
    */
-   int (*neg)(void *src, void *dst);
+   int (*neg)(const void *src, void *dst);
 
    /** copy
       @param   src   The number to copy from
       @param   dst   The number to write to
       @return CRYPT_OK on success
    */
-   int (*copy)(void *src, void *dst);
+   int (*copy)(const void *src, void *dst);
 
 /* ---- trivial low level functions ---- */
 
@@ -86,20 +86,20 @@ typedef struct {
                 only fetches up to bits_per_digit from the number
       @return   The lower bits_per_digit of the integer (unsigned)
    */
-   unsigned long (*get_int)(void *a);
+   unsigned long (*get_int)(const void *a);
 
    /** get digit n
      @param a  The number to read from
      @param n  The number of the digit to fetch
      @return  The bits_per_digit  sized n'th digit of a
    */
-   ltc_mp_digit (*get_digit)(void *a, int n);
+   ltc_mp_digit (*get_digit)(const void *a, int n);
 
    /** Get the number of digits that represent the number
      @param a   The number to count
      @return The number of digits used to represent the number
    */
-   int (*get_digit_count)(void *a);
+   int (*get_digit_count)(const void *a);
 
    /** compare two integers
      @param a   The left side integer
@@ -108,7 +108,7 @@ typedef struct {
              LTC_MP_GT if a > b and
              LTC_MP_EQ otherwise.  (signed comparison)
    */
-   int (*compare)(void *a, void *b);
+   int (*compare)(const void *a, const void *b);
 
    /** compare against int
      @param a   The left side integer
@@ -117,19 +117,19 @@ typedef struct {
              LTC_MP_GT if a > b and
              LTC_MP_EQ otherwise.  (signed comparison)
    */
-   int (*compare_d)(void *a, ltc_mp_digit n);
+   int (*compare_d)(const void *a, ltc_mp_digit n);
 
    /** Count the number of bits used to represent the integer
      @param a   The integer to count
      @return The number of bits required to represent the integer
    */
-   int (*count_bits)(void * a);
+   int (*count_bits)(const void * a);
 
    /** Count the number of LSB bits which are zero
      @param a   The integer to count
      @return The number of contiguous zero LSB bits
    */
-   int (*count_lsb_bits)(void *a);
+   int (*count_lsb_bits)(const void *a);
 
    /** Compute a power of two
      @param a  The integer to store the power in
@@ -154,20 +154,20 @@ typedef struct {
      @param radix The radix the integer is to be represented in (2-64)
      @return CRYPT_OK on success
    */
-   int (*write_radix)(void *a, char *str, int radix);
+   int (*write_radix)(const void *a, char *str, int radix);
 
    /** get size as unsigned char string
      @param a  The integer to get the size (when stored in array of octets)
      @return   The length of the integer in octets
    */
-   unsigned long (*unsigned_size)(void *a);
+   unsigned long (*unsigned_size)(const void *a);
 
    /** store an integer as an array of octets
      @param src   The integer to store
      @param dst   The buffer to store the integer in
      @return CRYPT_OK on success
    */
-   int (*unsigned_write)(void *src, unsigned char *dst);
+   int (*unsigned_write)(const void *src, unsigned char *dst);
 
    /** read an array of octets and store as integer
      @param dst   The integer to load
@@ -175,9 +175,9 @@ typedef struct {
      @param len   The number of octets
      @return CRYPT_OK on success
    */
-   int (*unsigned_read)(         void *dst,
-                        unsigned char *src,
-                        unsigned long  len);
+   int (*unsigned_read)(               void *dst,
+                        const unsigned char *src,
+                              unsigned long  len);
 
 /* ---- basic math ---- */
 
@@ -187,7 +187,7 @@ typedef struct {
      @param c   The destination of "a + b"
      @return CRYPT_OK on success
    */
-   int (*add)(void *a, void *b, void *c);
+   int (*add)(const void *a, const void *b, void *c);
 
    /** add two integers
      @param a   The first source integer
@@ -196,7 +196,7 @@ typedef struct {
      @param c   The destination of "a + b"
      @return CRYPT_OK on success
    */
-   int (*addi)(void *a, ltc_mp_digit b, void *c);
+   int (*addi)(const void *a, ltc_mp_digit b, void *c);
 
    /** subtract two integers
      @param a   The first source integer
@@ -204,7 +204,7 @@ typedef struct {
      @param c   The destination of "a - b"
      @return CRYPT_OK on success
    */
-   int (*sub)(void *a, void *b, void *c);
+   int (*sub)(const void *a, const void *b, void *c);
 
    /** subtract two integers
      @param a   The first source integer
@@ -213,7 +213,7 @@ typedef struct {
      @param c   The destination of "a - b"
      @return CRYPT_OK on success
    */
-   int (*subi)(void *a, ltc_mp_digit b, void *c);
+   int (*subi)(const void *a, ltc_mp_digit b, void *c);
 
    /** multiply two integers
      @param a   The first source integer
@@ -222,7 +222,7 @@ typedef struct {
      @param c   The destination of "a * b"
      @return CRYPT_OK on success
    */
-   int (*mul)(void *a, void *b, void *c);
+   int (*mul)(const void *a, const void *b, void *c);
 
    /** multiply two integers
      @param a   The first source integer
@@ -231,14 +231,14 @@ typedef struct {
      @param c   The destination of "a * b"
      @return CRYPT_OK on success
    */
-   int (*muli)(void *a, ltc_mp_digit b, void *c);
+   int (*muli)(const void *a, ltc_mp_digit b, void *c);
 
    /** Square an integer
      @param a    The integer to square
      @param b    The destination
      @return CRYPT_OK on success
    */
-   int (*sqr)(void *a, void *b);
+   int (*sqr)(const void *a, void *b);
 
    /** Square root (mod prime)
      @param a    The integer to compute square root mod prime from
@@ -246,7 +246,7 @@ typedef struct {
      @param c    The destination
      @return CRYPT_OK on success
    */
-   int (*sqrtmod_prime)(void *a, void *b, void *c);
+   int (*sqrtmod_prime)(const void *a, const void *b, void *c);
 
    /** Divide an integer
      @param a    The dividend
@@ -255,14 +255,14 @@ typedef struct {
      @param d    The remainder (can be NULL to signify don't care)
      @return CRYPT_OK on success
    */
-   int (*mpdiv)(void *a, void *b, void *c, void *d);
+   int (*mpdiv)(const void *a, const void *b, void *c, void *d);
 
    /** divide by two
       @param  a   The integer to divide (shift right)
       @param  b   The destination
       @return CRYPT_OK on success
    */
-   int (*div_2)(void *a, void *b);
+   int (*div_2)(const void *a, void *b);
 
    /** Get remainder (small value)
       @param  a    The integer to reduce
@@ -270,7 +270,7 @@ typedef struct {
       @param  c    The destination for the residue
       @return CRYPT_OK on success
    */
-   int (*modi)(void *a, ltc_mp_digit b, ltc_mp_digit *c);
+   int (*modi)(const void *a, ltc_mp_digit b, ltc_mp_digit *c);
 
    /** gcd
       @param  a     The first integer
@@ -278,7 +278,7 @@ typedef struct {
       @param  c     The destination for (a, b)
       @return CRYPT_OK on success
    */
-   int (*gcd)(void *a, void *b, void *c);
+   int (*gcd)(const void *a, const void *b, void *c);
 
    /** lcm
       @param  a     The first integer
@@ -286,7 +286,7 @@ typedef struct {
       @param  c     The destination for [a, b]
       @return CRYPT_OK on success
    */
-   int (*lcm)(void *a, void *b, void *c);
+   int (*lcm)(const void *a, const void *b, void *c);
 
    /** Modular multiplication
       @param  a     The first source
@@ -295,7 +295,7 @@ typedef struct {
       @param  d     The destination (a*b mod c)
       @return CRYPT_OK on success
    */
-   int (*mulmod)(void *a, void *b, void *c, void *d);
+   int (*mulmod)(const void *a, const void *b, const void *c, void *d);
 
    /** Modular squaring
       @param  a     The first source
@@ -303,7 +303,7 @@ typedef struct {
       @param  c     The destination (a*a mod b)
       @return CRYPT_OK on success
    */
-   int (*sqrmod)(void *a, void *b, void *c);
+   int (*sqrmod)(const void *a, const void *b, void *c);
 
    /** Modular inversion
       @param  a     The value to invert
@@ -311,7 +311,7 @@ typedef struct {
       @param  c     The destination (1/a mod b)
       @return CRYPT_OK on success
    */
-   int (*invmod)(void *, void *, void *);
+   int (*invmod)(const void *a, const void *b, void *c);
 
 /* ---- reduction ---- */
 
@@ -320,14 +320,14 @@ typedef struct {
        @param b  The destination for the reduction digit
        @return CRYPT_OK on success
    */
-   int (*montgomery_setup)(void *a, void **b);
+   int (*montgomery_setup)(const void *a, void **b);
 
    /** get normalization value
        @param a   The destination for the normalization value
        @param b   The modulus
        @return  CRYPT_OK on success
    */
-   int (*montgomery_normalization)(void *a, void *b);
+   int (*montgomery_normalization)(void *a, const void *b);
 
    /** reduce a number
        @param a   The number [and dest] to reduce
@@ -335,7 +335,7 @@ typedef struct {
        @param c   The value "b" from montgomery_setup()
        @return CRYPT_OK on success
    */
-   int (*montgomery_reduce)(void *a, void *b, void *c);
+   int (*montgomery_reduce)(void *a, const void *b, void *c);
 
    /** clean up  (frees memory)
        @param a   The value "b" from montgomery_setup()
@@ -352,7 +352,7 @@ typedef struct {
        @param d    The destination
        @return CRYPT_OK on success
    */
-   int (*exptmod)(void *a, void *b, void *c, void *d);
+   int (*exptmod)(const void *a, const void *b, const void *c, void *d);
 
    /** Primality testing
        @param a     The integer to test
@@ -360,7 +360,7 @@ typedef struct {
        @param c     The destination of the result (FP_YES if prime)
        @return CRYPT_OK on success
    */
-   int (*isprime)(void *a, int b, int *c);
+   int (*isprime)(const void *a, int b, int *c);
 
 /* ----  (optional) ecc point math ---- */
 
@@ -374,11 +374,11 @@ typedef struct {
                   (can be ignored if you work in affine only)
        @return CRYPT_OK on success
    */
-   int (*ecc_ptmul)(     void *k,
+   int (*ecc_ptmul)(     const void *k,
                     const ecc_point *G,
                           ecc_point *R,
-                               void *a,
-                               void *modulus,
+                         const void *a,
+                         const void *modulus,
                                 int  map);
 
    /** ECC GF(p) point addition
@@ -393,8 +393,8 @@ typedef struct {
    int (*ecc_ptadd)(const ecc_point *P,
                     const ecc_point *Q,
                           ecc_point *R,
-                               void *ma,
-                               void *modulus,
+                         const void *ma,
+                         const void *modulus,
                                void *mp);
 
    /** ECC GF(p) point double
@@ -407,8 +407,8 @@ typedef struct {
    */
    int (*ecc_ptdbl)(const ecc_point *P,
                           ecc_point *R,
-                               void *ma,
-                               void *modulus,
+                         const void *ma,
+                         const void *modulus,
                                void *mp);
 
    /** ECC mapping from projective to affine,
@@ -421,7 +421,7 @@ typedef struct {
                ecc_point only has three integers (x,y,z) so if
                you use a different mapping you have to make it fit.
    */
-   int (*ecc_map)(ecc_point *P, void *modulus, void *mp);
+   int (*ecc_map)(ecc_point *P, const void *modulus, void *mp);
 
    /** Computes kA*A + kB*B = C using Shamir's Trick
        @param A        First point to multiply
@@ -436,8 +436,8 @@ typedef struct {
    int (*ecc_mul2add)(const ecc_point *A, void *kA,
                       const ecc_point *B, void *kB,
                             ecc_point *C,
-                                 void *ma,
-                                 void *modulus);
+                           const void *ma,
+                           const void *modulus);
 
 /* ---- (optional) rsa optimized math (for internal CRT) ---- */
 
@@ -479,7 +479,7 @@ typedef struct {
       @param  d     The destination (a + b mod c)
       @return CRYPT_OK on success
    */
-   int (*addmod)(void *a, void *b, void *c, void *d);
+   int (*addmod)(const void *a, const void *b, const void *c, void *d);
 
    /** Modular substraction
       @param  a     The first source
@@ -488,7 +488,7 @@ typedef struct {
       @param  d     The destination (a - b mod c)
       @return CRYPT_OK on success
    */
-   int (*submod)(void *a, void *b, void *c, void *d);
+   int (*submod)(const void *a, const void *b, const void *c, void *d);
 
 /* ---- misc stuff ---- */
 

+ 12 - 9
src/headers/tomcrypt_private.h

@@ -422,7 +422,7 @@ void       ltc_ecc_del_point(ecc_point *p);
 int        ltc_ecc_set_point_xyz(ltc_mp_digit x, ltc_mp_digit y, ltc_mp_digit z, ecc_point *p);
 int        ltc_ecc_copy_point(const ecc_point *src, ecc_point *dst);
 int        ltc_ecc_is_point(const ltc_ecc_dp *dp, void *x, void *y);
-int        ltc_ecc_is_point_at_infinity(const ecc_point *P, void *modulus, int *retval);
+int        ltc_ecc_is_point_at_infinity(const ecc_point *P, const void *modulus, int *retval);
 int        ltc_ecc_import_point(const unsigned char *in, unsigned long inlen, void *prime, void *a, void *b, void *x, void *y);
 int        ltc_ecc_export_point(unsigned char *out, unsigned long *outlen, void *x, void *y, unsigned long size, int compressed);
 int        ltc_ecc_verify_key(const ecc_key *key);
@@ -430,10 +430,12 @@ int        ltc_ecc_verify_key(const ecc_key *key);
 /* point ops (mp == montgomery digit) */
 #if !defined(LTC_MECC_ACCEL) || defined(LTM_DESC) || defined(GMP_DESC)
 /* R = 2P */
-int ltc_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R, void *ma, void *modulus, void *mp);
+int ltc_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R,
+                                 const void *ma, const void *modulus, void *mp);
 
 /* R = P + Q */
-int ltc_ecc_projective_add_point(const ecc_point *P, const ecc_point *Q, ecc_point *R, void *ma, void *modulus, void *mp);
+int ltc_ecc_projective_add_point(const ecc_point *P, const ecc_point *Q, ecc_point *R,
+                                 const void *ma, const void *modulus, void *mp);
 #endif
 
 #if defined(LTC_MECC_FP)
@@ -451,30 +453,31 @@ void ltc_ecc_fp_tablelock(int lock);
 #endif
 
 /* R = kG */
-int ltc_ecc_mulmod(void *k, const ecc_point *G, ecc_point *R, void *a, void *modulus, int map);
+int ltc_ecc_mulmod(const void *k, const ecc_point *G, ecc_point *R,
+                   const void *a, const void *modulus, int map);
 
 #ifdef LTC_ECC_SHAMIR
 /* kA*A + kB*B = C */
 int ltc_ecc_mul2add(const ecc_point *A, void *kA,
                     const ecc_point *B, void *kB,
                           ecc_point *C,
-                               void *ma,
-                               void *modulus);
+                         const void *ma,
+                         const void *modulus);
 
 #ifdef LTC_MECC_FP
 /* Shamir's trick with optimized point multiplication using fixed point cache */
 int ltc_ecc_fp_mul2add(const ecc_point *A, void *kA,
                        const ecc_point *B, void *kB,
                              ecc_point *C,
-                                  void *ma,
-                                  void *modulus);
+                            const void *ma,
+                            const void *modulus);
 #endif
 
 #endif
 
 
 /* map P to affine from projective */
-int ltc_ecc_map(ecc_point *P, void *modulus, void *mp);
+int ltc_ecc_map(ecc_point *P, const void *modulus, void *mp);
 #endif /* LTC_MECC */
 
 #ifdef LTC_MDSA

+ 45 - 45
src/math/gmp_desc.c

@@ -17,7 +17,7 @@ static int init(void **a)
    if (*a == NULL) {
       return CRYPT_MEM;
    }
-   mpz_init(((__mpz_struct *)*a));
+   mpz_init(*a);
    return CRYPT_OK;
 }
 
@@ -28,7 +28,7 @@ static void deinit(void *a)
    XFREE(a);
 }
 
-static int neg(void *a, void *b)
+static int neg(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -36,7 +36,7 @@ static int neg(void *a, void *b)
    return CRYPT_OK;
 }
 
-static int copy(void *a, void *b)
+static int copy(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -44,7 +44,7 @@ static int copy(void *a, void *b)
    return CRYPT_OK;
 }
 
-static int init_copy(void **a, void *b)
+static int init_copy(void **a, const void *b)
 {
    if (init(a) != CRYPT_OK) {
       return CRYPT_MEM;
@@ -56,29 +56,29 @@ static int init_copy(void **a, void *b)
 static int set_int(void *a, ltc_mp_digit b)
 {
    LTC_ARGCHK(a != NULL);
-   mpz_set_ui(((__mpz_struct *)a), b);
+   mpz_set_ui(a, b);
    return CRYPT_OK;
 }
 
-static unsigned long get_int(void *a)
+static unsigned long get_int(const void *a)
 {
    LTC_ARGCHK(a != NULL);
    return mpz_get_ui(a);
 }
 
-static ltc_mp_digit get_digit(void *a, int n)
+static ltc_mp_digit get_digit(const void *a, int n)
 {
    LTC_ARGCHK(a != NULL);
    return mpz_getlimbn(a, n);
 }
 
-static int get_digit_count(void *a)
+static int get_digit_count(const void *a)
 {
    LTC_ARGCHK(a != NULL);
    return mpz_size(a);
 }
 
-static int compare(void *a, void *b)
+static int compare(const void *a, const void *b)
 {
    int ret;
    LTC_ARGCHK(a != NULL);
@@ -93,11 +93,11 @@ static int compare(void *a, void *b)
    }
 }
 
-static int compare_d(void *a, ltc_mp_digit b)
+static int compare_d(const void *a, ltc_mp_digit b)
 {
    int ret;
    LTC_ARGCHK(a != NULL);
-   ret = mpz_cmp_ui(((__mpz_struct *)a), b);
+   ret = mpz_cmp_ui((__mpz_struct *)a, b);
    if (ret < 0) {
       return LTC_MP_LT;
    } else if (ret > 0) {
@@ -107,13 +107,13 @@ static int compare_d(void *a, ltc_mp_digit b)
    }
 }
 
-static int count_bits(void *a)
+static int count_bits(const void *a)
 {
    LTC_ARGCHK(a != NULL);
    return mpz_sizeinbase(a, 2);
 }
 
-static int count_lsb_bits(void *a)
+static int count_lsb_bits(const void *a)
 {
    LTC_ARGCHK(a != NULL);
    return mpz_scan1(a, 0);
@@ -176,7 +176,7 @@ static int read_radix(void *a, const char *b, int radix)
 }
 
 /* write one */
-static int write_radix(void *a, char *b, int radix)
+static int write_radix(const void *a, char *b, int radix)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -190,26 +190,26 @@ static int write_radix(void *a, char *b, int radix)
 }
 
 /* get size as unsigned char string */
-static unsigned long unsigned_size(void *a)
+static unsigned long unsigned_size(const void *a)
 {
    unsigned long t;
    LTC_ARGCHK(a != NULL);
    t = mpz_sizeinbase(a, 2);
-   if (mpz_cmp_ui(((__mpz_struct *)a), 0) == 0) return 0;
+   if (mpz_cmp_ui((__mpz_struct *)a, 0) == 0) return 0;
    return (t>>3) + ((t&7)?1:0);
 }
 
 /* store */
-static int unsigned_write(void *a, unsigned char *b)
+static int unsigned_write(const void *a, unsigned char *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
-   mpz_export(b, NULL, 1, 1, 1, 0, ((__mpz_struct*)a));
+   mpz_export(b, NULL, 1, 1, 1, 0, a);
    return CRYPT_OK;
 }
 
 /* read */
-static int unsigned_read(void *a, unsigned char *b, unsigned long len)
+static int unsigned_read(void *a, const unsigned char *b, unsigned long len)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -218,7 +218,7 @@ static int unsigned_read(void *a, unsigned char *b, unsigned long len)
 }
 
 /* add */
-static int add(void *a, void *b, void *c)
+static int add(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -227,7 +227,7 @@ static int add(void *a, void *b, void *c)
    return CRYPT_OK;
 }
 
-static int addi(void *a, ltc_mp_digit b, void *c)
+static int addi(const void *a, ltc_mp_digit b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -236,7 +236,7 @@ static int addi(void *a, ltc_mp_digit b, void *c)
 }
 
 /* sub */
-static int sub(void *a, void *b, void *c)
+static int sub(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -245,7 +245,7 @@ static int sub(void *a, void *b, void *c)
    return CRYPT_OK;
 }
 
-static int subi(void *a, ltc_mp_digit b, void *c)
+static int subi(const void *a, ltc_mp_digit b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -254,7 +254,7 @@ static int subi(void *a, ltc_mp_digit b, void *c)
 }
 
 /* mul */
-static int mul(void *a, void *b, void *c)
+static int mul(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -263,7 +263,7 @@ static int mul(void *a, void *b, void *c)
    return CRYPT_OK;
 }
 
-static int muli(void *a, ltc_mp_digit b, void *c)
+static int muli(const void *a, ltc_mp_digit b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -272,7 +272,7 @@ static int muli(void *a, ltc_mp_digit b, void *c)
 }
 
 /* sqr */
-static int sqr(void *a, void *b)
+static int sqr(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -281,7 +281,7 @@ static int sqr(void *a, void *b)
 }
 
 /* sqrtmod_prime */
-static int sqrtmod_prime(void *n, void *prime, void *ret)
+static int sqrtmod_prime(const void *n, const void *prime, void *ret)
 {
    int res, legendre, i;
    mpz_t t1, C, Q, S, Z, M, T, R, two;
@@ -291,11 +291,11 @@ static int sqrtmod_prime(void *n, void *prime, void *ret)
    LTC_ARGCHK(ret   != NULL);
 
    /* first handle the simple cases */
-   if (mpz_cmp_ui(((__mpz_struct *)n), 0) == 0) {
+   if (mpz_cmp_ui((__mpz_struct *)n, 0) == 0) {
       mpz_set_ui(ret, 0);
       return CRYPT_OK;
    }
-   if (mpz_cmp_ui(((__mpz_struct *)prime), 2) == 0)     return CRYPT_ERROR; /* prime must be odd */
+   if (mpz_cmp_ui((__mpz_struct *)prime, 2) == 0)       return CRYPT_ERROR; /* prime must be odd */
    legendre = mpz_legendre(n, prime);
    if (legendre == -1)                                  return CRYPT_ERROR; /* quadratic non-residue mod prime */
 
@@ -358,7 +358,7 @@ static int sqrtmod_prime(void *n, void *prime, void *ret)
       mpz_set(t1, T);
       i = 0;
       while (1) {
-         if (mpz_cmp_ui(((__mpz_struct *)t1), 1) == 0) break;
+         if (mpz_cmp_ui(t1, 1) == 0) break;
          mpz_powm(t1, t1, two, prime);
          i++;
       }
@@ -394,7 +394,7 @@ cleanup:
 }
 
 /* div */
-static int divide(void *a, void *b, void *c, void *d)
+static int divide(const void *a, const void *b, void *c, void *d)
 {
    mpz_t tmp;
    LTC_ARGCHK(a != NULL);
@@ -413,7 +413,7 @@ static int divide(void *a, void *b, void *c, void *d)
    return CRYPT_OK;
 }
 
-static int div_2(void *a, void *b)
+static int div_2(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -422,7 +422,7 @@ static int div_2(void *a, void *b)
 }
 
 /* modi */
-static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
+static int modi(const void *a, ltc_mp_digit b, ltc_mp_digit *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -432,7 +432,7 @@ static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
 }
 
 /* gcd */
-static int gcd(void *a, void *b, void *c)
+static int gcd(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -442,7 +442,7 @@ static int gcd(void *a, void *b, void *c)
 }
 
 /* lcm */
-static int lcm(void *a, void *b, void *c)
+static int lcm(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -451,7 +451,7 @@ static int lcm(void *a, void *b, void *c)
    return CRYPT_OK;
 }
 
-static int addmod(void *a, void *b, void *c, void *d)
+static int addmod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -462,7 +462,7 @@ static int addmod(void *a, void *b, void *c, void *d)
    return CRYPT_OK;
 }
 
-static int submod(void *a, void *b, void *c, void *d)
+static int submod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -473,7 +473,7 @@ static int submod(void *a, void *b, void *c, void *d)
    return CRYPT_OK;
 }
 
-static int mulmod(void *a, void *b, void *c, void *d)
+static int mulmod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -484,7 +484,7 @@ static int mulmod(void *a, void *b, void *c, void *d)
    return CRYPT_OK;
 }
 
-static int sqrmod(void *a, void *b, void *c)
+static int sqrmod(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -495,7 +495,7 @@ static int sqrmod(void *a, void *b, void *c)
 }
 
 /* invmod */
-static int invmod(void *a, void *b, void *c)
+static int invmod(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -505,7 +505,7 @@ static int invmod(void *a, void *b, void *c)
 }
 
 /* setup */
-static int montgomery_setup(void *a, void **b)
+static int montgomery_setup(const void *a, void **b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -514,7 +514,7 @@ static int montgomery_setup(void *a, void **b)
 }
 
 /* get normalization value */
-static int montgomery_normalization(void *a, void *b)
+static int montgomery_normalization(void *a, const void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -523,7 +523,7 @@ static int montgomery_normalization(void *a, void *b)
 }
 
 /* reduce */
-static int montgomery_reduce(void *a, void *b, void *c)
+static int montgomery_reduce(void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -538,7 +538,7 @@ static void montgomery_deinit(void *a)
   LTC_UNUSED_PARAM(a);
 }
 
-static int exptmod(void *a, void *b, void *c, void *d)
+static int exptmod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -548,7 +548,7 @@ static int exptmod(void *a, void *b, void *c, void *d)
    return CRYPT_OK;
 }
 
-static int isprime(void *a, int b, int *c)
+static int isprime(const void *a, int b, int *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);

+ 40 - 40
src/math/ltm_desc.c

@@ -75,21 +75,21 @@ static void deinit(void *a)
    XFREE(a);
 }
 
-static int neg(void *a, void *b)
+static int neg(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
    return mpi_to_ltc_error(mp_neg(a, b));
 }
 
-static int copy(void *a, void *b)
+static int copy(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
    return mpi_to_ltc_error(mp_copy(a, b));
 }
 
-static int init_copy(void **a, void *b)
+static int init_copy(void **a, const void *b)
 {
    int err;
    LTC_ARGCHK(a  != NULL);
@@ -110,7 +110,7 @@ static int set_int(void *a, ltc_mp_digit b)
 #endif
 }
 
-static unsigned long get_int(void *a)
+static unsigned long get_int(const void *a)
 {
    LTC_ARGCHK(a != NULL);
 #ifdef BN_MP_GET_INT_C
@@ -120,23 +120,23 @@ static unsigned long get_int(void *a)
 #endif
 }
 
-static ltc_mp_digit get_digit(void *a, int n)
+static ltc_mp_digit get_digit(const void *a, int n)
 {
-   mp_int *A;
+   const mp_int *A;
    LTC_ARGCHK(a != NULL);
    A = a;
    return (n >= A->used || n < 0) ? 0 : A->dp[n];
 }
 
-static int get_digit_count(void *a)
+static int get_digit_count(const void *a)
 {
-   mp_int *A;
+   const mp_int *A;
    LTC_ARGCHK(a != NULL);
    A = a;
    return A->used;
 }
 
-static int compare(void *a, void *b)
+static int compare(const void *a, const void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -148,7 +148,7 @@ static int compare(void *a, void *b)
    }
 }
 
-static int compare_d(void *a, ltc_mp_digit b)
+static int compare_d(const void *a, ltc_mp_digit b)
 {
    LTC_ARGCHK(a != NULL);
    switch (mp_cmp_d(a, b)) {
@@ -159,13 +159,13 @@ static int compare_d(void *a, ltc_mp_digit b)
    }
 }
 
-static int count_bits(void *a)
+static int count_bits(const void *a)
 {
    LTC_ARGCHK(a != NULL);
    return mp_count_bits(a);
 }
 
-static int count_lsb_bits(void *a)
+static int count_lsb_bits(const void *a)
 {
    LTC_ARGCHK(a != NULL);
    return mp_cnt_lsb(a);
@@ -189,7 +189,7 @@ static int read_radix(void *a, const char *b, int radix)
 }
 
 /* write one */
-static int write_radix(void *a, char *b, int radix)
+static int write_radix(const void *a, char *b, int radix)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -201,7 +201,7 @@ static int write_radix(void *a, char *b, int radix)
 }
 
 /* get size as unsigned char string */
-static unsigned long unsigned_size(void *a)
+static unsigned long unsigned_size(const void *a)
 {
    LTC_ARGCHK(a != NULL);
 #ifdef BN_MP_UNSIGNED_BIN_SIZE_C
@@ -212,7 +212,7 @@ static unsigned long unsigned_size(void *a)
 }
 
 /* store */
-static int unsigned_write(void *a, unsigned char *b)
+static int unsigned_write(const void *a, unsigned char *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -224,7 +224,7 @@ static int unsigned_write(void *a, unsigned char *b)
 }
 
 /* read */
-static int unsigned_read(void *a, unsigned char *b, unsigned long len)
+static int unsigned_read(void *a, const unsigned char *b, unsigned long len)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -236,7 +236,7 @@ static int unsigned_read(void *a, unsigned char *b, unsigned long len)
 }
 
 /* add */
-static int add(void *a, void *b, void *c)
+static int add(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -244,7 +244,7 @@ static int add(void *a, void *b, void *c)
    return mpi_to_ltc_error(mp_add(a, b, c));
 }
 
-static int addi(void *a, ltc_mp_digit b, void *c)
+static int addi(const void *a, ltc_mp_digit b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -252,7 +252,7 @@ static int addi(void *a, ltc_mp_digit b, void *c)
 }
 
 /* sub */
-static int sub(void *a, void *b, void *c)
+static int sub(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -260,7 +260,7 @@ static int sub(void *a, void *b, void *c)
    return mpi_to_ltc_error(mp_sub(a, b, c));
 }
 
-static int subi(void *a, ltc_mp_digit b, void *c)
+static int subi(const void *a, ltc_mp_digit b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -268,7 +268,7 @@ static int subi(void *a, ltc_mp_digit b, void *c)
 }
 
 /* mul */
-static int mul(void *a, void *b, void *c)
+static int mul(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -276,7 +276,7 @@ static int mul(void *a, void *b, void *c)
    return mpi_to_ltc_error(mp_mul(a, b, c));
 }
 
-static int muli(void *a, ltc_mp_digit b, void *c)
+static int muli(const void *a, ltc_mp_digit b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -284,7 +284,7 @@ static int muli(void *a, ltc_mp_digit b, void *c)
 }
 
 /* sqr */
-static int sqr(void *a, void *b)
+static int sqr(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -292,7 +292,7 @@ static int sqr(void *a, void *b)
 }
 
 /* sqrtmod_prime */
-static int sqrtmod_prime(void *a, void *b, void *c)
+static int sqrtmod_prime(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -301,14 +301,14 @@ static int sqrtmod_prime(void *a, void *b, void *c)
 }
 
 /* div */
-static int divide(void *a, void *b, void *c, void *d)
+static int divide(const void *a, const void *b, void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
    return mpi_to_ltc_error(mp_div(a, b, c, d));
 }
 
-static int div_2(void *a, void *b)
+static int div_2(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -316,7 +316,7 @@ static int div_2(void *a, void *b)
 }
 
 /* modi */
-static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
+static int modi(const void *a, ltc_mp_digit b, ltc_mp_digit *c)
 {
    mp_digit tmp;
    int      err;
@@ -332,7 +332,7 @@ static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
 }
 
 /* gcd */
-static int gcd(void *a, void *b, void *c)
+static int gcd(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -341,7 +341,7 @@ static int gcd(void *a, void *b, void *c)
 }
 
 /* lcm */
-static int lcm(void *a, void *b, void *c)
+static int lcm(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -349,7 +349,7 @@ static int lcm(void *a, void *b, void *c)
    return mpi_to_ltc_error(mp_lcm(a, b, c));
 }
 
-static int addmod(void *a, void *b, void *c, void *d)
+static int addmod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -358,7 +358,7 @@ static int addmod(void *a, void *b, void *c, void *d)
    return mpi_to_ltc_error(mp_addmod(a,b,c,d));
 }
 
-static int submod(void *a, void *b, void *c, void *d)
+static int submod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -367,7 +367,7 @@ static int submod(void *a, void *b, void *c, void *d)
    return mpi_to_ltc_error(mp_submod(a,b,c,d));
 }
 
-static int mulmod(void *a, void *b, void *c, void *d)
+static int mulmod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -376,7 +376,7 @@ static int mulmod(void *a, void *b, void *c, void *d)
    return mpi_to_ltc_error(mp_mulmod(a,b,c,d));
 }
 
-static int sqrmod(void *a, void *b, void *c)
+static int sqrmod(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -385,7 +385,7 @@ static int sqrmod(void *a, void *b, void *c)
 }
 
 /* invmod */
-static int invmod(void *a, void *b, void *c)
+static int invmod(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -394,7 +394,7 @@ static int invmod(void *a, void *b, void *c)
 }
 
 /* setup */
-static int montgomery_setup(void *a, void **b)
+static int montgomery_setup(const void *a, void **b)
 {
    int err;
    LTC_ARGCHK(a != NULL);
@@ -403,14 +403,14 @@ static int montgomery_setup(void *a, void **b)
    if (*b == NULL) {
       return CRYPT_MEM;
    }
-   if ((err = mpi_to_ltc_error(mp_montgomery_setup(a, (mp_digit *)*b))) != CRYPT_OK) {
+   if ((err = mpi_to_ltc_error(mp_montgomery_setup(a, *b))) != CRYPT_OK) {
       XFREE(*b);
    }
    return err;
 }
 
 /* get normalization value */
-static int montgomery_normalization(void *a, void *b)
+static int montgomery_normalization(void *a, const void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -418,7 +418,7 @@ static int montgomery_normalization(void *a, void *b)
 }
 
 /* reduce */
-static int montgomery_reduce(void *a, void *b, void *c)
+static int montgomery_reduce(void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -432,7 +432,7 @@ static void montgomery_deinit(void *a)
    XFREE(a);
 }
 
-static int exptmod(void *a, void *b, void *c, void *d)
+static int exptmod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -441,7 +441,7 @@ static int exptmod(void *a, void *b, void *c, void *d)
    return mpi_to_ltc_error(mp_exptmod(a,b,c,d));
 }
 
-static int isprime(void *a, int b, int *c)
+static int isprime(const void *a, int b, int *c)
 {
    int err;
 #if defined(PRIVATE_MP_WARRAY) || defined(BN_MP_PRIME_IS_PRIME_C)

+ 50 - 46
src/math/tfm_desc.c

@@ -51,15 +51,18 @@ static void deinit(void *a)
    XFREE(a);
 }
 
-static int neg(void *a, void *b)
+static int neg(const void *a, void *b)
 {
+   /* fp_neg() is a macro that accesses the internals of the b */
+   fp_int *tmpb = b;
+
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
-   fp_neg(((fp_int*)a), ((fp_int*)b));
+   fp_neg(a, tmpb);
    return CRYPT_OK;
 }
 
-static int copy(void *a, void *b)
+static int copy(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -67,7 +70,7 @@ static int copy(void *a, void *b)
    return CRYPT_OK;
 }
 
-static int init_copy(void **a, void *b)
+static int init_copy(void **a, const void *b)
 {
    if (init(a) != CRYPT_OK) {
       return CRYPT_MEM;
@@ -83,31 +86,31 @@ static int set_int(void *a, ltc_mp_digit b)
    return CRYPT_OK;
 }
 
-static unsigned long get_int(void *a)
+static unsigned long get_int(const void *a)
 {
-   fp_int *A;
+   const fp_int *A;
    LTC_ARGCHK(a != NULL);
    A = a;
    return A->used > 0 ? A->dp[0] : 0;
 }
 
-static ltc_mp_digit get_digit(void *a, int n)
+static ltc_mp_digit get_digit(const void *a, int n)
 {
-   fp_int *A;
+   const fp_int *A;
    LTC_ARGCHK(a != NULL);
    A = a;
    return (n >= A->used || n < 0) ? 0 : A->dp[n];
 }
 
-static int get_digit_count(void *a)
+static int get_digit_count(const void *a)
 {
-   fp_int *A;
+   const fp_int *A;
    LTC_ARGCHK(a != NULL);
    A = a;
    return A->used;
 }
 
-static int compare(void *a, void *b)
+static int compare(const void *a, const void *b)
 {
    int ret;
    LTC_ARGCHK(a != NULL);
@@ -121,7 +124,7 @@ static int compare(void *a, void *b)
    return 0;
 }
 
-static int compare_d(void *a, ltc_mp_digit b)
+static int compare_d(const void *a, ltc_mp_digit b)
 {
    int ret;
    LTC_ARGCHK(a != NULL);
@@ -134,13 +137,13 @@ static int compare_d(void *a, ltc_mp_digit b)
    return 0;
 }
 
-static int count_bits(void *a)
+static int count_bits(const void *a)
 {
    LTC_ARGCHK(a != NULL);
    return fp_count_bits(a);
 }
 
-static int count_lsb_bits(void *a)
+static int count_lsb_bits(const void *a)
 {
    LTC_ARGCHK(a != NULL);
    return fp_cnt_lsb(a);
@@ -160,11 +163,11 @@ static int read_radix(void *a, const char *b, int radix)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
-   return tfm_to_ltc_error(fp_read_radix(a, (char *)b, radix));
+   return tfm_to_ltc_error(fp_read_radix(a, b, radix));
 }
 
 /* write one */
-static int write_radix(void *a, char *b, int radix)
+static int write_radix(const void *a, char *b, int radix)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -172,14 +175,14 @@ static int write_radix(void *a, char *b, int radix)
 }
 
 /* get size as unsigned char string */
-static unsigned long unsigned_size(void *a)
+static unsigned long unsigned_size(const void *a)
 {
    LTC_ARGCHK(a != NULL);
    return fp_unsigned_bin_size(a);
 }
 
 /* store */
-static int unsigned_write(void *a, unsigned char *b)
+static int unsigned_write(const void *a, unsigned char *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -188,7 +191,7 @@ static int unsigned_write(void *a, unsigned char *b)
 }
 
 /* read */
-static int unsigned_read(void *a, unsigned char *b, unsigned long len)
+static int unsigned_read(void *a, const unsigned char *b, unsigned long len)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -197,7 +200,7 @@ static int unsigned_read(void *a, unsigned char *b, unsigned long len)
 }
 
 /* add */
-static int add(void *a, void *b, void *c)
+static int add(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -206,7 +209,7 @@ static int add(void *a, void *b, void *c)
    return CRYPT_OK;
 }
 
-static int addi(void *a, ltc_mp_digit b, void *c)
+static int addi(const void *a, ltc_mp_digit b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -215,7 +218,7 @@ static int addi(void *a, ltc_mp_digit b, void *c)
 }
 
 /* sub */
-static int sub(void *a, void *b, void *c)
+static int sub(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -224,7 +227,7 @@ static int sub(void *a, void *b, void *c)
    return CRYPT_OK;
 }
 
-static int subi(void *a, ltc_mp_digit b, void *c)
+static int subi(const void *a, ltc_mp_digit b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -233,7 +236,7 @@ static int subi(void *a, ltc_mp_digit b, void *c)
 }
 
 /* mul */
-static int mul(void *a, void *b, void *c)
+static int mul(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -242,7 +245,7 @@ static int mul(void *a, void *b, void *c)
    return CRYPT_OK;
 }
 
-static int muli(void *a, ltc_mp_digit b, void *c)
+static int muli(const void *a, ltc_mp_digit b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -251,7 +254,7 @@ static int muli(void *a, ltc_mp_digit b, void *c)
 }
 
 /* sqr */
-static int sqr(void *a, void *b)
+static int sqr(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -262,14 +265,14 @@ static int sqr(void *a, void *b)
 /* sqrtmod_prime - NOT SUPPORTED */
 
 /* div */
-static int divide(void *a, void *b, void *c, void *d)
+static int divide(const void *a, const void *b, void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
    return tfm_to_ltc_error(fp_div(a, b, c, d));
 }
 
-static int div_2(void *a, void *b)
+static int div_2(const void *a, void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -278,7 +281,7 @@ static int div_2(void *a, void *b)
 }
 
 /* modi */
-static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
+static int modi(const void *a, ltc_mp_digit b, ltc_mp_digit *c)
 {
    fp_digit tmp;
    int      err;
@@ -294,7 +297,7 @@ static int modi(void *a, ltc_mp_digit b, ltc_mp_digit *c)
 }
 
 /* gcd */
-static int gcd(void *a, void *b, void *c)
+static int gcd(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -304,7 +307,7 @@ static int gcd(void *a, void *b, void *c)
 }
 
 /* lcm */
-static int lcm(void *a, void *b, void *c)
+static int lcm(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -313,7 +316,7 @@ static int lcm(void *a, void *b, void *c)
    return CRYPT_OK;
 }
 
-static int addmod(void *a, void *b, void *c, void *d)
+static int addmod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -322,7 +325,7 @@ static int addmod(void *a, void *b, void *c, void *d)
    return tfm_to_ltc_error(fp_addmod(a,b,c,d));
 }
 
-static int submod(void *a, void *b, void *c, void *d)
+static int submod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -331,7 +334,7 @@ static int submod(void *a, void *b, void *c, void *d)
    return tfm_to_ltc_error(fp_submod(a,b,c,d));
 }
 
-static int mulmod(void *a, void *b, void *c, void *d)
+static int mulmod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -340,7 +343,7 @@ static int mulmod(void *a, void *b, void *c, void *d)
    return tfm_to_ltc_error(fp_mulmod(a,b,c,d));
 }
 
-static int sqrmod(void *a, void *b, void *c)
+static int sqrmod(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -349,7 +352,7 @@ static int sqrmod(void *a, void *b, void *c)
 }
 
 /* invmod */
-static int invmod(void *a, void *b, void *c)
+static int invmod(const void *a, const void *b, void *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -358,7 +361,7 @@ static int invmod(void *a, void *b, void *c)
 }
 
 /* setup */
-static int montgomery_setup(void *a, void **b)
+static int montgomery_setup(const void *a, void **b)
 {
    int err;
    LTC_ARGCHK(a != NULL);
@@ -367,14 +370,14 @@ static int montgomery_setup(void *a, void **b)
    if (*b == NULL) {
       return CRYPT_MEM;
    }
-   if ((err = tfm_to_ltc_error(fp_montgomery_setup(a, (fp_digit *)*b))) != CRYPT_OK) {
+   if ((err = tfm_to_ltc_error(fp_montgomery_setup(a, *b))) != CRYPT_OK) {
       XFREE(*b);
    }
    return err;
 }
 
 /* get normalization value */
-static int montgomery_normalization(void *a, void *b)
+static int montgomery_normalization(void *a, const void *b)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
@@ -383,12 +386,13 @@ static int montgomery_normalization(void *a, void *b)
 }
 
 /* reduce */
-static int montgomery_reduce(void *a, void *b, void *c)
+static int montgomery_reduce(void *a, const void *b, void *c)
 {
+   fp_digit *tmpc = c;
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
    LTC_ARGCHK(c != NULL);
-   fp_montgomery_reduce(a, b, *((fp_digit *)c));
+   fp_montgomery_reduce(a, b, *tmpc);
    return CRYPT_OK;
 }
 
@@ -398,16 +402,16 @@ static void montgomery_deinit(void *a)
    XFREE(a);
 }
 
-static int exptmod(void *a, void *b, void *c, void *d)
+static int exptmod(const void *a, const void *b, const void *c, void *d)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(b != NULL);
    LTC_ARGCHK(c != NULL);
    LTC_ARGCHK(d != NULL);
-   return tfm_to_ltc_error(fp_exptmod(a,b,c,d));
+   return tfm_to_ltc_error(fp_exptmod(a,(void *)b,c,d));
 }
 
-static int isprime(void *a, int b, int *c)
+static int isprime(const void *a, int b, int *c)
 {
    LTC_ARGCHK(a != NULL);
    LTC_ARGCHK(c != NULL);
@@ -420,7 +424,7 @@ static int isprime(void *a, int b, int *c)
 
 #if defined(LTC_MECC) && defined(LTC_MECC_ACCEL)
 
-static int tfm_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R, void *ma, void *modulus, void *Mp)
+static int tfm_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R, const void *ma, const void *modulus, void *Mp)
 {
    fp_int t1, t2;
    fp_digit mp;
@@ -575,7 +579,7 @@ static int tfm_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R, void *
    @param Mp       The "b" value from montgomery_setup()
    @return CRYPT_OK on success
 */
-static int tfm_ecc_projective_add_point(const ecc_point *P, const ecc_point *Q, ecc_point *R, void *ma, void *modulus, void *Mp)
+static int tfm_ecc_projective_add_point(const ecc_point *P, const ecc_point *Q, ecc_point *R, const void *ma, const void *modulus, void *Mp)
 {
    fp_int  t1, t2, x, y, z;
    fp_digit mp;

+ 1 - 1
src/pk/ecc/ltc_ecc_is_point_at_infinity.c

@@ -9,7 +9,7 @@
  * a point at infinity is any point (x,y,0) such that y^2 == x^3, except (0,0,0)
  */
 
-int ltc_ecc_is_point_at_infinity(const ecc_point *P, void *modulus, int *retval)
+int ltc_ecc_is_point_at_infinity(const ecc_point *P, const void *modulus, int *retval)
 {
    int err;
    void  *x3, *y2;

+ 1 - 1
src/pk/ecc/ltc_ecc_map.c

@@ -17,7 +17,7 @@
   @param mp       The "b" value from montgomery_setup()
   @return CRYPT_OK on success
 */
-int ltc_ecc_map(ecc_point *P, void *modulus, void *mp)
+int ltc_ecc_map(ecc_point *P, const void *modulus, void *mp)
 {
    void *t1, *t2;
    int   err;

+ 2 - 2
src/pk/ecc/ltc_ecc_mul2add.c

@@ -25,8 +25,8 @@
 int ltc_ecc_mul2add(const ecc_point *A, void *kA,
                     const ecc_point *B, void *kB,
                           ecc_point *C,
-                               void *ma,
-                               void *modulus)
+                         const void *ma,
+                         const void *modulus)
 {
   ecc_point     *precomp[16];
   unsigned       bitbufA, bitbufB, lenA, lenB, len, nA, nB, nibble;

+ 2 - 1
src/pk/ecc/ltc_ecc_mulmod.c

@@ -19,11 +19,12 @@
    @param k    The scalar to multiply by
    @param G    The base point
    @param R    [out] Destination for kG
+   @param a    ECC curve parameter a
    @param modulus  The modulus of the field the ECC curve is in
    @param map      Boolean whether to map back to affine or not (1==map, 0 == leave in projective)
    @return CRYPT_OK on success
 */
-int ltc_ecc_mulmod(void *k, const ecc_point *G, ecc_point *R, void *a, void *modulus, int map)
+int ltc_ecc_mulmod(const void *k, const ecc_point *G, ecc_point *R, const void *a, const void *modulus, int map)
 {
    ecc_point *tG, *M[8];
    int        i, j, err, inf;

+ 1 - 1
src/pk/ecc/ltc_ecc_mulmod_timing.c

@@ -22,7 +22,7 @@
    @param map      Boolean whether to map back to affine or not (1==map, 0 == leave in projective)
    @return CRYPT_OK on success
 */
-int ltc_ecc_mulmod(void *k, const ecc_point *G, ecc_point *R, void *a, void *modulus, int map)
+int ltc_ecc_mulmod(const void *k, const ecc_point *G, ecc_point *R, const void *a, const void *modulus, int map)
 {
    ecc_point *tG, *M[3];
    int        i, j, err, inf;

+ 2 - 1
src/pk/ecc/ltc_ecc_projective_add_point.c

@@ -20,7 +20,8 @@
    @param mp       The "b" value from montgomery_setup()
    @return CRYPT_OK on success
 */
-int ltc_ecc_projective_add_point(const ecc_point *P, const ecc_point *Q, ecc_point *R, void *ma, void *modulus, void *mp)
+int ltc_ecc_projective_add_point(const ecc_point *P, const ecc_point *Q, ecc_point *R,
+                                 const void *ma, const void *modulus, void *mp)
 {
    void  *t1, *t2, *x, *y, *z;
    int    err, inf;

+ 1 - 1
src/pk/ecc/ltc_ecc_projective_dbl_point.c

@@ -37,7 +37,7 @@
    @param mp       The "b" value from montgomery_setup()
    @return CRYPT_OK on success
 */
-int ltc_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R, void *ma, void *modulus, void *mp)
+int ltc_ecc_projective_dbl_point(const ecc_point *P, ecc_point *R, const void *ma, const void *modulus, void *mp)
 {
    void *t1, *t2;
    int   err, inf;