]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
cppcheck: Variable is reassigned a value before the old one has been used.
authorNikolay Morozov <nmorozoff77@yandex.ru>
Thu, 27 Feb 2020 11:28:07 +0000 (14:28 +0300)
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>
Sat, 29 Feb 2020 18:57:21 +0000 (21:57 +0300)
Plus some minor chnages
- function defenition doen't match function declaration
- Consecutive break statement is unnecessary.
- Type missmatch in format string

gost89.h
gost_ameth.c
gost_ec_keyx.c
gost_grasshopper_cipher.c
gost_keyexpimp.c
gost_lcl.h
test_sign.c

index 9f36905e43903243f42b7a867118fa9470c4e568..569db5b059816eee5fa162fc74b6d0940c867913 100644 (file)
--- a/gost89.h
+++ b/gost89.h
@@ -78,7 +78,7 @@ int gost_mac(gost_ctx * ctx, int mac_len, const unsigned char *data,
  * Compute MAC of given length in bits from data, using non-zero 8-byte IV
  * (non-standard, for use in CryptoPro key transport only
  */
-int gost_mac_iv(gost_ctx * c, int mac_len, const unsigned char *iv,
+int gost_mac_iv(gost_ctx * ctx, int mac_len, const unsigned char *iv,
                 const unsigned char *data, unsigned int data_len,
                 unsigned char *mac);
 /* Perform one step of MAC calculation like gostcrypt */
index 92cfc41984000349ede1ac822f3c04d38878776c..f13b4ed8a544a6ab21b4d7262fc6952d5ea53fce 100644 (file)
@@ -392,8 +392,7 @@ static int priv_decode_gost(EVP_PKEY *pk,
         pk_num = ASN1_INTEGER_to_BN(priv_key, BN_secure_new());
         ASN1_INTEGER_free(priv_key);
     } else if ((V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED) == *p) {
-        MASKED_GOST_KEY *mgk = NULL;
-        mgk = d2i_MASKED_GOST_KEY(NULL, &p, priv_len);
+        MASKED_GOST_KEY *mgk = d2i_MASKED_GOST_KEY(NULL, &p, priv_len);
 
         if (!mgk) {
             GOSTerr(GOST_F_PRIV_DECODE_GOST, EVP_R_DECODE_ERROR);
@@ -460,10 +459,9 @@ static int priv_encode_gost(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk)
     }
 
     if (pk_format != NULL && strcmp(pk_format, PK_WRAP_PARAM) == 0) {
-        ASN1_STRING *octet = NULL;
+        ASN1_STRING *octet = ASN1_STRING_new();
         int priv_len = 0;
         unsigned char *priv_buf = NULL;
-        octet = ASN1_STRING_new();        
         if (!octet || !ASN1_OCTET_STRING_set(octet, buf, key_len)) {
             ASN1_STRING_free(octet);
             ASN1_STRING_free(params);
@@ -723,13 +721,13 @@ static int pub_decode_gost_ec(EVP_PKEY *pk, X509_PUBKEY *pub)
 
 static int pub_encode_gost_ec(X509_PUBKEY *pub, const EVP_PKEY *pk)
 {
-    ASN1_OBJECT *algobj = NULL;
+    ASN1_OBJECT *algobj;
     ASN1_OCTET_STRING *octet = NULL;
-    void *pval = NULL;
+    void *pval;
     unsigned char *buf = NULL, *databuf = NULL;
     int data_len, ret = -1;
     const EC_POINT *pub_key;
-    BIGNUM *X = NULL, *Y = NULL, *order = NULL;
+    BIGNUM *X = NULL, *Y = NULL, *order;
     const EC_KEY *ec = EVP_PKEY_get0((EVP_PKEY *)pk);
     int ptype = V_ASN1_SEQUENCE;
     ASN1_STRING *params;
index 340ca368f71ab197c536c06956b0e83bb94cc70e..de52dec2c2a703ebb4dfa50535e8b5c83cf1e154 100644 (file)
@@ -152,7 +152,6 @@ static int gost_keg(const unsigned char *ukm_source, int pkey_nid,
 
             OPENSSL_cleanse(tmpkey, 32);
             return (keylen) ? keylen : 0;
-            break;
         }
     default:
         return 0;
index 777ca0a860aa84e407593a21d8b935a560d0906a..f6b8a39edb62fc472a043c94c6b4c486e05cbbf4 100644 (file)
@@ -692,9 +692,7 @@ int gost_grasshopper_set_asn1_parameters(EVP_CIPHER_CTX *ctx, ASN1_TYPE *params)
 {
     int len = 0;
     unsigned char *buf = NULL;
-    ASN1_OCTET_STRING *os = NULL;
-
-    os = ASN1_OCTET_STRING_new();
+    ASN1_OCTET_STRING *os = ASN1_OCTET_STRING_new();
 
     if (!os || !ASN1_OCTET_STRING_set(os, buf, len)) {
         ASN1_OCTET_STRING_free(os);
index 5564387a973bc1779e816122e43514f7417467e1..e0961ff5f0bba2cc421f4716dc11af3f8b0b2486 100644 (file)
@@ -176,7 +176,7 @@ int gost_kdftree2012_256(unsigned char *keyout, size_t keyout_len,
     int iters, i = 0;
     unsigned char zero = 0;
     unsigned char *ptr = keyout;
-    HMAC_CTX *ctx = NULL;
+    HMAC_CTX *ctx;
     unsigned char *len_ptr = NULL;
     uint32_t len_repr = htonl(keyout_len * 8);
     size_t len_repr_len = 4;
index 4eba3545a38998cd5408c74886b649e0f602b6c4..08120b574b20b4380d1e1d66a22b2487fdb3e1a1 100644 (file)
@@ -241,7 +241,7 @@ const EVP_CIPHER *cipher_magma_cbc();
 const EVP_CIPHER *cipher_magma_ctr();
 void cipher_gost_destroy();
 
-void inc_counter(unsigned char *buffer, size_t buf_len);
+void inc_counter(unsigned char *counter, size_t counter_bytes);
 
 # define EVP_MD_CTRL_KEY_LEN (EVP_MD_CTRL_ALG_CTRL+3)
 # define EVP_MD_CTRL_SET_KEY (EVP_MD_CTRL_ALG_CTRL+4)
@@ -278,8 +278,8 @@ int gost_kdftree2012_256(unsigned char *keyout, size_t keyout_len,
                          const unsigned char *seed, size_t seed_len,
                          const size_t representation);
 
-int gost_tlstree(int cipher_nid, const unsigned char* inkey,
-                unsigned char *outkey, const unsigned char *tlsseq);
+int gost_tlstree(int cipher_nid, const unsigned char *in, unsigned char *out,
+                 const unsigned char *tlsseq);
 /* KExp/KImp */
 int gost_kexp15(const unsigned char *shared_key, const int shared_len,
                 int cipher_nid, const unsigned char *cipher_key,
index 1d0058164f14bfda18fa93f0f44f0aebc7f00c45..f0f9d4421cfebf3babddb51212cfff1941741a7c 100644 (file)
@@ -157,7 +157,7 @@ static int test_sign(struct test_sign *t)
     const EC_GROUP *group = EC_KEY_get0_group(ec);
     int curve_name = EC_GROUP_get_curve_name(group);
     err = curve_name == t->nid;
-    printf("\tcurve_name (%d):\t", t->nid);
+    printf("\tcurve_name (%u):\t", t->nid);
     print_test_tf(err, curve_name, "match", "mismatch");
     ret |= !err;