From 87142382dacbdb8f846c51b8f4b6d1deec33f648 Mon Sep 17 00:00:00 2001 From: Karel Miko Date: Sat, 29 Apr 2017 19:58:24 +0200 Subject: [PATCH] lint fixes discussed in #199 --- src/encauth/gcm/gcm_memory.c | 3 +-- src/encauth/ocb3/ocb3_add_aad.c | 2 +- src/headers/tomcrypt_cipher.h | 2 +- src/pk/dsa/dsa_decrypt_key.c | 3 ++- src/pk/dsa/dsa_verify_hash.c | 2 +- src/pk/pkcs1/pkcs_1_oaep_decode.c | 1 - src/pk/rsa/rsa_import_x509.c | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/encauth/gcm/gcm_memory.c b/src/encauth/gcm/gcm_memory.c index f858992..05d471b 100644 --- a/src/encauth/gcm/gcm_memory.c +++ b/src/encauth/gcm/gcm_memory.c @@ -52,8 +52,7 @@ int gcm_memory( int cipher, } if (cipher_descriptor[cipher].accel_gcm_memory != NULL) { - return - cipher_descriptor[cipher].accel_gcm_memory + return cipher_descriptor[cipher].accel_gcm_memory (key, keylen, IV, IVlen, adata, adatalen, diff --git a/src/encauth/ocb3/ocb3_add_aad.c b/src/encauth/ocb3/ocb3_add_aad.c index 4608670..88f4d08 100644 --- a/src/encauth/ocb3/ocb3_add_aad.c +++ b/src/encauth/ocb3/ocb3_add_aad.c @@ -54,7 +54,7 @@ int ocb3_add_aad(ocb3_state *ocb, const unsigned char *aad, unsigned long aadlen datalen = aadlen; } - if (datalen <= 0) return CRYPT_OK; + if (datalen == 0) return CRYPT_OK; full_blocks = datalen/ocb->block_len; full_blocks_len = full_blocks * ocb->block_len; diff --git a/src/headers/tomcrypt_cipher.h b/src/headers/tomcrypt_cipher.h index fc5b652..58f02db 100644 --- a/src/headers/tomcrypt_cipher.h +++ b/src/headers/tomcrypt_cipher.h @@ -962,7 +962,7 @@ int chacha_test(void); #ifdef LTC_RC4_STREAM typedef struct { - int x, y; + unsigned int x, y; unsigned char buf[256]; } rc4_state; diff --git a/src/pk/dsa/dsa_decrypt_key.c b/src/pk/dsa/dsa_decrypt_key.c index f971e6e..25a9db0 100644 --- a/src/pk/dsa/dsa_decrypt_key.c +++ b/src/pk/dsa/dsa_decrypt_key.c @@ -92,7 +92,8 @@ int dsa_decrypt_key(const unsigned char *in, unsigned long inlen, goto LBL_ERR; } - y = MIN(mp_unsigned_bin_size(key->p) + 1, MAXBLOCKSIZE); + y = mp_unsigned_bin_size(key->p) + 1; + y = MIN(y, MAXBLOCKSIZE); if ((err = hash_memory(hash, expt, x, expt, &y)) != CRYPT_OK) { goto LBL_ERR; } diff --git a/src/pk/dsa/dsa_verify_hash.c b/src/pk/dsa/dsa_verify_hash.c index d247391..7df472c 100644 --- a/src/pk/dsa/dsa_verify_hash.c +++ b/src/pk/dsa/dsa_verify_hash.c @@ -102,7 +102,7 @@ int dsa_verify_hash(const unsigned char *sig, unsigned long siglen, void *r, *s; if ((err = mp_init_multi(&r, &s, NULL)) != CRYPT_OK) { - return CRYPT_MEM; + return err; } /* decode the sequence */ diff --git a/src/pk/pkcs1/pkcs_1_oaep_decode.c b/src/pk/pkcs1/pkcs_1_oaep_decode.c index 5877498..469e3e1 100644 --- a/src/pk/pkcs1/pkcs_1_oaep_decode.c +++ b/src/pk/pkcs1/pkcs_1_oaep_decode.c @@ -160,7 +160,6 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen, /* copy message */ *outlen = modulus_len - hLen - 1 - x; XMEMCPY(out, DB + x, modulus_len - hLen - 1 - x); - x += modulus_len - hLen - 1; /* valid packet */ *res = 1; diff --git a/src/pk/rsa/rsa_import_x509.c b/src/pk/rsa/rsa_import_x509.c index cf4a19f..45da7c7 100644 --- a/src/pk/rsa/rsa_import_x509.c +++ b/src/pk/rsa/rsa_import_x509.c @@ -27,7 +27,7 @@ int rsa_import_x509(const unsigned char *in, unsigned long inlen, rsa_key *key) { int err; - unsigned char *tmpbuf=NULL; + unsigned char *tmpbuf; unsigned long tmpbuf_len, tmp_inlen; ltc_asn1_list *decoded_list = NULL, *l;