]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Some PVS Studio nits
authorDmitry Belyavskiy <beldmit@gmail.com>
Sat, 29 Dec 2018 12:01:32 +0000 (15:01 +0300)
committerDmitry Belyavskiy <beldmit@gmail.com>
Sat, 29 Dec 2018 12:01:32 +0000 (15:01 +0300)
benchmark/sign.c
gost_ec_keyx.c
gost_keyexpimp.c
test_tlstree.c

index 417d8dd76b261f7274cc388a488c6e3651fe32ae..2d1d7866480a16e0418ef31d70285d95260e03fc 100644 (file)
@@ -131,6 +131,10 @@ int main(int argc, char **argv)
            fflush(stdout);
            siglen = EVP_PKEY_size(pkey);
            sigbuf = malloc(siglen * cycles);
+       if (!sigbuf) {
+           fprintf(stderr, "No tests were run, malloc failure.\n");
+           exit(1);
+       }
 
            for (pass = 0; pass < 2; pass++) {
                struct timespec ts;
index a95df330f2546b757566b20e02666ab99ee6267b..6efa3e870b06d54d22dd8e8c3c26255f9966a615 100644 (file)
@@ -251,8 +251,7 @@ static int pkey_GOST_ECcp_encrypt(EVP_PKEY_CTX *pctx, unsigned char *out,
     EVP_PKEY *sec_key = EVP_PKEY_CTX_get0_peerkey(pctx);
     if (data->shared_ukm) {
         memcpy(ukm, data->shared_ukm, 8);
-    } else if (out) {
-
+    } else {
         if (RAND_bytes(ukm, 8) <= 0) {
             GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_RNG_ERROR);
             return 0;
index caa6171d1fbb36dccf2bfb3efca90535e97e7bad..1f058a19d9ac209cd7f9146f5ce8fe44ae8a33ab 100644 (file)
@@ -84,7 +84,7 @@ int gost_kexp15(const unsigned char *shared_key, const int shared_len,
 
 /*
  * Function expects that shared_key is a preallocated buffer
- * with length defined as expkeylen - mac_len defined by mac_nid
+ * with length defined as expkeylen + mac_len defined by mac_nid
  * */
 int gost_kimp15(const unsigned char *expkey, const size_t expkeylen,
                 int cipher_nid, const unsigned char *cipher_key,
index 08caf906b7d1cd215e80d5345537e1970543f4cb..df2574298d38f0828b241c0090556d892238ccf8 100644 (file)
@@ -132,7 +132,7 @@ int main(void)
        EVP_Cipher(enc, data0_processed+sizeof(data0), mac0, 16);
 
        hexdump(stderr, "ENC0 result", data0_processed, 31);
-       if (memcmp(enc0_etl, data0_processed, 16) != 0) {
+       if (memcmp(enc0_etl, data0_processed, sizeof(data0_processed)) != 0) {
                fprintf(stderr, "ENC0 mismatch");
                exit(1);
        }