Fix yaca_sign_initialize_hmac/cmac memory leak. 31/85531/4
authorDariusz Michaluk <d.michaluk@samsung.com>
Thu, 25 Aug 2016 12:05:56 +0000 (14:05 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Mon, 29 Aug 2016 14:32:59 +0000 (16:32 +0200)
Fix sign example indentation.

Change-Id: I65664d815ebff5eb5861d24a649ea94c9910915f

examples/sign.c
src/sign.c

index df7ff58943215325ac0b2b33261185155079d0fd..db6f39a15067aba0f20480944a5779bc47d29996 100644 (file)
@@ -50,22 +50,22 @@ void simple_sign_verify_asym(yaca_key_type_e type, const char *algo)
 
        /* SIGN */
        if (yaca_simple_calculate_signature(YACA_DIGEST_SHA512,
-                     prv,
-                     lorem4096,
-                     LOREM4096_SIZE,
-                     &signature,
-                     &signature_len) != YACA_ERROR_NONE)
+                                           prv,
+                                           lorem4096,
+                                           LOREM4096_SIZE,
+                                           &signature,
+                                           &signature_len) != YACA_ERROR_NONE)
                goto exit;
 
        dump_hex(signature, signature_len, "[Simple API] %s Signature of lorem4096:", algo);
 
        /* VERIFY */
        if (yaca_simple_verify_signature(YACA_DIGEST_SHA512,
-                       pub,
-                       lorem4096,
-                       LOREM4096_SIZE,
-                       signature,
-                       signature_len) != YACA_ERROR_NONE)
+                                        pub,
+                                        lorem4096,
+                                        LOREM4096_SIZE,
+                                        signature,
+                                        signature_len) != YACA_ERROR_NONE)
                printf("[Simple API] %s verification failed\n", algo);
        else
                printf("[Simple API] %s verification successful\n", algo);
@@ -90,22 +90,22 @@ void simple_sign_verify_hmac(void)
 
        /* SIGN */
        if (yaca_simple_calculate_hmac(YACA_DIGEST_SHA512,
-                     key,
-                     lorem4096,
-                     LOREM4096_SIZE,
-                     &signature1,
-                     &signature_len) != YACA_ERROR_NONE)
+                                      key,
+                                      lorem4096,
+                                      LOREM4096_SIZE,
+                                      &signature1,
+                                      &signature_len) != YACA_ERROR_NONE)
                goto exit;
 
        dump_hex(signature1, signature_len, "[Simple API] HMAC Signature of lorem4096:");
 
        /* VERIFY */
        if (yaca_simple_calculate_hmac(YACA_DIGEST_SHA512,
-                     key,
-                     lorem4096,
-                     LOREM4096_SIZE,
-                     &signature2,
-                     &signature_len) != YACA_ERROR_NONE)
+                                      key,
+                                      lorem4096,
+                                      LOREM4096_SIZE,
+                                      &signature2,
+                                      &signature_len) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_memcmp(signature1, signature2, signature_len) != YACA_ERROR_NONE)
@@ -133,11 +133,11 @@ void simple_sign_verify_cmac(void)
 
        /* SIGN */
        if (yaca_simple_calculate_cmac(YACA_ENCRYPT_AES,
-                     key,
-                     lorem4096,
-                     LOREM4096_SIZE,
-                     &signature1,
-                     &signature_len) != YACA_ERROR_NONE)
+                                      key,
+                                      lorem4096,
+                                      LOREM4096_SIZE,
+                                      &signature1,
+                                      &signature_len) != YACA_ERROR_NONE)
                goto exit;
 
        dump_hex(signature1, signature_len, "[Simple API] CMAC Signature of lorem4096:");
@@ -145,11 +145,11 @@ void simple_sign_verify_cmac(void)
 
        /* VERIFY */
        if (yaca_simple_calculate_cmac(YACA_ENCRYPT_AES,
-                     key,
-                     lorem4096,
-                     LOREM4096_SIZE,
-                     &signature2,
-                     &signature_len) != YACA_ERROR_NONE)
+                                      key,
+                                      lorem4096,
+                                      LOREM4096_SIZE,
+                                      &signature2,
+                                      &signature_len) != YACA_ERROR_NONE)
                goto exit;
 
        if (yaca_memcmp(signature1, signature2, signature_len) != YACA_ERROR_NONE)
index aaa5863290f40967ebff894499b0c64a41ec782e..79d77596c8637fd57166bc1d562a1d04b16bbfea 100644 (file)
@@ -343,8 +343,6 @@ API int yaca_sign_initialize_hmac(yaca_context_h *ctx,
                goto exit;
        }
 
-       pkey = NULL;
-
        *ctx = (yaca_context_h)nc;
        nc = NULL;
        ret = YACA_ERROR_NONE;
@@ -427,8 +425,6 @@ API int yaca_sign_initialize_cmac(yaca_context_h *ctx,
                goto exit;
        }
 
-       pkey = NULL;
-
        *ctx = (yaca_context_h)nc;
        nc = NULL;
        ret = YACA_ERROR_NONE;