소스 검색

Merge pull request #143 from libtom/fix/85-part2

Fix/85 part2
karel-m 8 년 전
부모
커밋
f60e045034
7개의 변경된 파일13개의 추가작업 그리고 13개의 파일을 삭제
  1. 2 2
      src/encauth/ccm/ccm_add_aad.c
  2. 2 2
      src/hashes/whirl/whirl.c
  3. 2 2
      src/headers/tomcrypt_macros.h
  4. 2 2
      src/math/ltm_desc.c
  5. 2 2
      src/modes/xts/xts_decrypt.c
  6. 2 2
      src/modes/xts/xts_encrypt.c
  7. 1 1
      src/pk/ecc/ecc_import.c

+ 2 - 2
src/encauth/ccm/ccm_add_aad.c

@@ -38,7 +38,7 @@ int ccm_add_aad(ccm_state *ccm,
       if (ccm->x == 16) {
          /* full block so let's encrypt it */
          if ((err = cipher_descriptor[ccm->cipher].ecb_encrypt(ccm->PAD, ccm->PAD, &ccm->K)) != CRYPT_OK) {
-            return CRYPT_ERROR;
+            return err;
          }
          ccm->x = 0;
       }
@@ -49,7 +49,7 @@ int ccm_add_aad(ccm_state *ccm,
    if (ccm->aadlen == ccm->current_aadlen) {
       if (ccm->x != 0) {
          if ((err = cipher_descriptor[ccm->cipher].ecb_encrypt(ccm->PAD, ccm->PAD, &ccm->K)) != CRYPT_OK) {
-            return CRYPT_ERROR;
+            return err;
          }
       }
       ccm->x = 0;

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

@@ -45,14 +45,14 @@ const struct ltc_hash_descriptor whirlpool_desc =
 
 /* shortcut macro to perform three functions at once */
 #define theta_pi_gamma(a, i)             \
-    SB0(GB(a, i-0, 7)) ^                 \
+   (SB0(GB(a, i-0, 7)) ^                 \
     SB1(GB(a, i-1, 6)) ^                 \
     SB2(GB(a, i-2, 5)) ^                 \
     SB3(GB(a, i-3, 4)) ^                 \
     SB4(GB(a, i-4, 3)) ^                 \
     SB5(GB(a, i-5, 2)) ^                 \
     SB6(GB(a, i-6, 1)) ^                 \
-    SB7(GB(a, i-7, 0))
+    SB7(GB(a, i-7, 0)))
 
 #ifdef LTC_CLEAN_STACK
 static int _whirlpool_compress(hash_state *md, unsigned char *buf)

+ 2 - 2
src/headers/tomcrypt_macros.h

@@ -267,7 +267,7 @@ static inline ulong32 ROR(ulong32 word, int i)
 #ifndef LTC_NO_ROLC
 
 #define ROLc(word,i) ({ \
-   ulong32 __ROLc_tmp = word; \
+   ulong32 __ROLc_tmp = (word); \
    __asm__ ("roll %2, %0" : \
             "=r" (__ROLc_tmp) : \
             "0" (__ROLc_tmp), \
@@ -275,7 +275,7 @@ static inline ulong32 ROR(ulong32 word, int i)
             __ROLc_tmp; \
    })
 #define RORc(word,i) ({ \
-   ulong32 __RORc_tmp = word; \
+   ulong32 __RORc_tmp = (word); \
    __asm__ ("rorl %2, %0" : \
             "=r" (__RORc_tmp) : \
             "0" (__RORc_tmp), \

+ 2 - 2
src/math/ltm_desc.c

@@ -126,8 +126,8 @@ static int compare(void *a, void *b)
       case MP_LT: return LTC_MP_LT;
       case MP_EQ: return LTC_MP_EQ;
       case MP_GT: return LTC_MP_GT;
+      default:    return 0;
    }
-   return 0;
 }
 
 static int compare_d(void *a, unsigned long b)
@@ -139,8 +139,8 @@ static int compare_d(void *a, unsigned long b)
       case MP_LT: return LTC_MP_LT;
       case MP_EQ: return LTC_MP_EQ;
       case MP_GT: return LTC_MP_GT;
+      default:    return 0;
    }
-   return 0;
 }
 
 static int count_bits(void *a)

+ 2 - 2
src/modes/xts/xts_decrypt.c

@@ -94,8 +94,8 @@ int xts_decrypt(const unsigned char *ct, unsigned long ptlen, unsigned char *pt,
    if (cipher_descriptor[xts->cipher].accel_xts_decrypt && lim > 0) {
 
       /* use accelerated decryption for whole blocks */
-      if ((err = cipher_descriptor[xts->cipher].accel_xts_decrypt(ct, pt, lim, tweak, &xts->key1, &xts->key2) !=
-                 CRYPT_OK)) {
+      if ((err = cipher_descriptor[xts->cipher].accel_xts_decrypt(ct, pt, lim, tweak, &xts->key1, &xts->key2)) !=
+                 CRYPT_OK) {
          return err;
       }
       ct += lim * 16;

+ 2 - 2
src/modes/xts/xts_encrypt.c

@@ -96,8 +96,8 @@ int xts_encrypt(const unsigned char *pt, unsigned long ptlen, unsigned char *ct,
    if (cipher_descriptor[xts->cipher].accel_xts_encrypt && lim > 0) {
 
       /* use accelerated encryption for whole blocks */
-      if ((err = cipher_descriptor[xts->cipher].accel_xts_encrypt(pt, ct, lim, tweak, &xts->key1, &xts->key2) !=
-                 CRYPT_OK)) {
+      if ((err = cipher_descriptor[xts->cipher].accel_xts_encrypt(pt, ct, lim, tweak, &xts->key1, &xts->key2)) !=
+                 CRYPT_OK) {
          return err;
       }
       ct += lim * 16;

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

@@ -107,7 +107,7 @@ int ecc_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, co
    }
 
    /* find out what type of key it is */
-   if ((err = der_decode_sequence_multi(in, inlen, 
+   if ((err = der_decode_sequence_multi(in, inlen,
                                   LTC_ASN1_BIT_STRING, 1UL, &flags,
                                   LTC_ASN1_EOL,        0UL, NULL)) != CRYPT_OK) {
       goto done;