diff --git a/src/encauth/ccm/ccm_add_aad.c b/src/encauth/ccm/ccm_add_aad.c index 3dcf3ff..43a3d53 100644 --- a/src/encauth/ccm/ccm_add_aad.c +++ b/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; diff --git a/src/hashes/whirl/whirl.c b/src/hashes/whirl/whirl.c index af5625a..525d75b 100644 --- a/src/hashes/whirl/whirl.c +++ b/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) diff --git a/src/headers/tomcrypt_macros.h b/src/headers/tomcrypt_macros.h index 2bb60cf..39cf118 100644 --- a/src/headers/tomcrypt_macros.h +++ b/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), \ diff --git a/src/math/ltm_desc.c b/src/math/ltm_desc.c index 5ff8ff8..22937e8 100644 --- a/src/math/ltm_desc.c +++ b/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) diff --git a/src/modes/xts/xts_decrypt.c b/src/modes/xts/xts_decrypt.c index 1840b17..d1be2c1 100644 --- a/src/modes/xts/xts_decrypt.c +++ b/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; diff --git a/src/modes/xts/xts_encrypt.c b/src/modes/xts/xts_encrypt.c index 1f6dea3..77c7e8c 100644 --- a/src/modes/xts/xts_encrypt.c +++ b/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; diff --git a/src/pk/ecc/ecc_import.c b/src/pk/ecc/ecc_import.c index 9ee97a1..124b1b1 100644 --- a/src/pk/ecc/ecc_import.c +++ b/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;