Просмотр исходного кода

Merge pull request #381 from felixdoerre/const_hash

add const to the hashes' compress functions
Steffen Jaeckel 7 лет назад
Родитель
Сommit
2e8371ce0b

+ 2 - 2
src/hashes/md4.c

@@ -71,7 +71,7 @@ const struct ltc_hash_descriptor md4_desc =
   }
 
 #ifdef LTC_CLEAN_STACK
-static int _md4_compress(hash_state *md, unsigned char *buf)
+static int _md4_compress(hash_state *md, const unsigned char *buf)
 #else
 static int  md4_compress(hash_state *md, const unsigned char *buf)
 #endif
@@ -155,7 +155,7 @@ static int  md4_compress(hash_state *md, const unsigned char *buf)
 }
 
 #ifdef LTC_CLEAN_STACK
-static int md4_compress(hash_state *md, unsigned char *buf)
+static int md4_compress(hash_state *md, const unsigned char *buf)
 {
    int err;
    err = _md4_compress(md, buf);

+ 2 - 2
src/hashes/md5.c

@@ -96,7 +96,7 @@ static const ulong32 Korder[64] = {
 #endif
 
 #ifdef LTC_CLEAN_STACK
-static int _md5_compress(hash_state *md, unsigned char *buf)
+static int _md5_compress(hash_state *md, const unsigned char *buf)
 #else
 static int  md5_compress(hash_state *md, const unsigned char *buf)
 #endif
@@ -214,7 +214,7 @@ static int  md5_compress(hash_state *md, const unsigned char *buf)
 }
 
 #ifdef LTC_CLEAN_STACK
-static int md5_compress(hash_state *md, unsigned char *buf)
+static int md5_compress(hash_state *md, const unsigned char *buf)
 {
    int err;
    err = _md5_compress(md, buf);

+ 2 - 2
src/hashes/rmd128.c

@@ -79,7 +79,7 @@ const struct ltc_hash_descriptor rmd128_desc =
       (a) = ROLc((a), (s));
 
 #ifdef LTC_CLEAN_STACK
-static int _rmd128_compress(hash_state *md, unsigned char *buf)
+static int _rmd128_compress(hash_state *md, const unsigned char *buf)
 #else
 static int  rmd128_compress(hash_state *md, const unsigned char *buf)
 #endif
@@ -253,7 +253,7 @@ static int  rmd128_compress(hash_state *md, const unsigned char *buf)
 }
 
 #ifdef LTC_CLEAN_STACK
-static int rmd128_compress(hash_state *md, unsigned char *buf)
+static int rmd128_compress(hash_state *md, const unsigned char *buf)
 {
    int err;
    err = _rmd128_compress(md, buf);

+ 2 - 2
src/hashes/rmd160.c

@@ -99,7 +99,7 @@ const struct ltc_hash_descriptor rmd160_desc =
 
 
 #ifdef LTC_CLEAN_STACK
-static int _rmd160_compress(hash_state *md, unsigned char *buf)
+static int _rmd160_compress(hash_state *md, const unsigned char *buf)
 #else
 static int  rmd160_compress(hash_state *md, const unsigned char *buf)
 #endif
@@ -311,7 +311,7 @@ static int  rmd160_compress(hash_state *md, const unsigned char *buf)
 }
 
 #ifdef LTC_CLEAN_STACK
-static int rmd160_compress(hash_state *md, unsigned char *buf)
+static int rmd160_compress(hash_state *md, const unsigned char *buf)
 {
    int err;
    err = _rmd160_compress(md, buf);

+ 2 - 2
src/hashes/rmd256.c

@@ -73,7 +73,7 @@ const struct ltc_hash_descriptor rmd256_desc =
       (a) = ROLc((a), (s));
 
 #ifdef LTC_CLEAN_STACK
-static int _rmd256_compress(hash_state *md, unsigned char *buf)
+static int _rmd256_compress(hash_state *md, const unsigned char *buf)
 #else
 static int  rmd256_compress(hash_state *md, const unsigned char *buf)
 #endif
@@ -262,7 +262,7 @@ static int  rmd256_compress(hash_state *md, const unsigned char *buf)
 }
 
 #ifdef LTC_CLEAN_STACK
-static int rmd256_compress(hash_state *md, unsigned char *buf)
+static int rmd256_compress(hash_state *md, const unsigned char *buf)
 {
    int err;
    err = _rmd256_compress(md, buf);

+ 2 - 2
src/hashes/rmd320.c

@@ -94,7 +94,7 @@ const struct ltc_hash_descriptor rmd320_desc =
 
 
 #ifdef LTC_CLEAN_STACK
-static int _rmd320_compress(hash_state *md, unsigned char *buf)
+static int _rmd320_compress(hash_state *md, const unsigned char *buf)
 #else
 static int  rmd320_compress(hash_state *md, const unsigned char *buf)
 #endif
@@ -325,7 +325,7 @@ static int  rmd320_compress(hash_state *md, const unsigned char *buf)
 }
 
 #ifdef LTC_CLEAN_STACK
-static int rmd320_compress(hash_state *md, unsigned char *buf)
+static int rmd320_compress(hash_state *md, const unsigned char *buf)
 {
    int err;
    err = _rmd320_compress(md, buf);

+ 2 - 2
src/hashes/sha1.c

@@ -40,7 +40,7 @@ const struct ltc_hash_descriptor sha1_desc =
 #define F3(x,y,z)  (x ^ y ^ z)
 
 #ifdef LTC_CLEAN_STACK
-static int _sha1_compress(hash_state *md, unsigned char *buf)
+static int _sha1_compress(hash_state *md, const unsigned char *buf)
 #else
 static int  sha1_compress(hash_state *md, const unsigned char *buf)
 #endif
@@ -146,7 +146,7 @@ static int  sha1_compress(hash_state *md, const unsigned char *buf)
 }
 
 #ifdef LTC_CLEAN_STACK
-static int sha1_compress(hash_state *md, unsigned char *buf)
+static int sha1_compress(hash_state *md, const unsigned char *buf)
 {
    int err;
    err = _sha1_compress(md, buf);

+ 2 - 2
src/hashes/sha2/sha256.c

@@ -64,7 +64,7 @@ static const ulong32 K[64] = {
 
 /* compress 512-bits */
 #ifdef LTC_CLEAN_STACK
-static int _sha256_compress(hash_state * md, unsigned char *buf)
+static int _sha256_compress(hash_state * md, const unsigned char *buf)
 #else
 static int  sha256_compress(hash_state * md, const unsigned char *buf)
 #endif
@@ -187,7 +187,7 @@ static int  sha256_compress(hash_state * md, const unsigned char *buf)
 }
 
 #ifdef LTC_CLEAN_STACK
-static int sha256_compress(hash_state * md, unsigned char *buf)
+static int sha256_compress(hash_state * md, const unsigned char *buf)
 {
     int err;
     err = _sha256_compress(md, buf);

+ 2 - 2
src/hashes/sha2/sha512.c

@@ -89,7 +89,7 @@ CONST64(0x5fcb6fab3ad6faec), CONST64(0x6c44198c4a475817)
 
 /* compress 1024-bits */
 #ifdef LTC_CLEAN_STACK
-static int _sha512_compress(hash_state * md, unsigned char *buf)
+static int _sha512_compress(hash_state * md, const unsigned char *buf)
 #else
 static int  sha512_compress(hash_state * md, const unsigned char *buf)
 #endif
@@ -156,7 +156,7 @@ static int  sha512_compress(hash_state * md, const unsigned char *buf)
 
 /* compress 1024-bits */
 #ifdef LTC_CLEAN_STACK
-static int sha512_compress(hash_state * md, unsigned char *buf)
+static int sha512_compress(hash_state * md, const unsigned char *buf)
 {
     int err;
     err = _sha512_compress(md, buf);

+ 1 - 1
src/hashes/tiger.c

@@ -639,7 +639,7 @@ static int  tiger_compress(hash_state *md, const unsigned char *buf)
 }
 
 #ifdef LTC_CLEAN_STACK
-static int tiger_compress(hash_state *md, unsigned char *buf)
+static int tiger_compress(hash_state *md, const unsigned char *buf)
 {
    int err;
    err = _tiger_compress(md, buf);

+ 1 - 1
src/hashes/whirl/whirl.c

@@ -109,7 +109,7 @@ static int whirlpool_compress(hash_state *md, const unsigned char *buf)
 
 
 #ifdef LTC_CLEAN_STACK
-static int whirlpool_compress(hash_state *md, unsigned char *buf)
+static int whirlpool_compress(hash_state *md, const unsigned char *buf)
 {
    int err;
    err = _whirlpool_compress(md, buf);

+ 1 - 1
src/headers/tomcrypt_hash.h

@@ -523,7 +523,7 @@ int func_name (hash_state * md, const unsigned char *in, unsigned long inlen)
     }                                                                                       \
     while (inlen > 0) {                                                                     \
         if (md-> state_var .curlen == 0 && inlen >= block_size) {                           \
-           if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) {               \
+           if ((err = compress_name (md, in)) != CRYPT_OK) {                                \
               return err;                                                                   \
            }                                                                                \
            md-> state_var .length += block_size * 8;                                        \