[ITC/UTC][yaca][Non-ACR] Adjust tests after yaca_context_get_property() implementatio... 73/210573/2
authorDariusz Michaluk <d.michaluk@samsung.com>
Mon, 22 Jul 2019 11:56:27 +0000 (13:56 +0200)
committermanoj <manoj.g2@samsung.com>
Tue, 23 Jul 2019 05:28:01 +0000 (10:58 +0530)
Change-Id: I55c2fa71e3344ef3ca797a83ef412cac7289c4cf

src/itc/yaca/ITs-yaca-encrypt.c
src/utc/yaca/utc-yaca-crypto.c
src/utc/yaca/utc-yaca-encrypt.c

index 9135923e7963d7b7b6fef5920d218d12313b36a1..3248631e6ad5aafc8170ce9f046ccd254ad98bee 100755 (executable)
@@ -317,7 +317,7 @@ int ITc_yaca_encrypt_update_finalize_p(void)
 int ITc_yaca_decrypt_update_finalize_p(void)
 {
        START_TEST;
-       
+
        yaca_encrypt_algorithm_e eEncryptAlgorithm = YACA_ENCRYPT_AES;
        yaca_block_cipher_mode_e eBlockCipherMode = YACA_BCM_GCM;
        yaca_key_type_e key_type = YACA_KEY_TYPE_SYMMETRIC;
@@ -348,55 +348,52 @@ int ITc_yaca_decrypt_update_finalize_p(void)
        // Key generation
        nRet = yaca_key_generate(key_type, hKeyBitLen, &hKey);
        PRINT_RESULT(YACA_ERROR_NONE, nRet, "yaca_key_generate", YacaGetError(nRet));
-       CHECK_HANDLE(hKey, "yaca_key_generate");        
+       CHECK_HANDLE(hKey, "yaca_key_generate");
 
        // IV generation
        nRet = yaca_key_generate(YACA_KEY_TYPE_IV, iv_bit_len, &iv);
        PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_key_generate", YacaGetError(nRet), yaca_key_destroy(hKey));
        CHECK_HANDLE(iv, "yaca_key_generate");
-       
+
        nRet = yaca_zalloc(aad_len, (void**)&aad);
        PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_zalloc", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_key_destroy(iv));
 
        nRet = yaca_randomize_bytes(aad, aad_len);
        PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_randomize_bytes", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_key_destroy(iv));
-       
-       nRet = yaca_zalloc(tag_len, (void**)&tag);
-       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_zalloc", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_key_destroy(iv));
 
        // Encryption
        nRet = yaca_encrypt_initialize(&hContext, eEncryptAlgorithm, eBlockCipherMode, hKey, iv);
-       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_encrypt_initialize", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_free(tag);yaca_key_destroy(iv));
+       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_encrypt_initialize", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_key_destroy(iv));
 
        nRet = yaca_context_set_property(hContext, YACA_PROPERTY_GCM_AAD, aad, aad_len);
-       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_context_set_property", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(tag);yaca_free(aad);yaca_context_destroy(hContext);yaca_key_destroy(iv));
+       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_context_set_property", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_context_destroy(hContext);yaca_key_destroy(iv));
 
        nRet = yaca_context_get_output_length(hContext, LOREM4096_SIZE, &output_len);
-       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_context_get_output_length", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(tag);yaca_free(aad);yaca_context_destroy(hContext);yaca_key_destroy(iv));
+       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_context_get_output_length", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_context_destroy(hContext);yaca_key_destroy(iv));
 
        nRet = yaca_context_get_output_length(hContext, 0, &block_len);
-       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_context_get_output_length", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(tag);yaca_free(aad);yaca_context_destroy(hContext);yaca_key_destroy(iv));
+       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_context_get_output_length", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_context_destroy(hContext);yaca_key_destroy(iv));
 
        enc_len = output_len + block_len;
        nRet = yaca_malloc(enc_len, (void**)&enc);
-       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_malloc", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(tag);yaca_free(aad);yaca_context_destroy(hContext);yaca_key_destroy(iv));
+       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_malloc", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_context_destroy(hContext);yaca_key_destroy(iv));
 
        written_len = enc_len;
        nRet = yaca_encrypt_update(hContext, lorem4096, LOREM4096_SIZE, enc, &written_len);
-       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_encrypt_update", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(tag);yaca_free(aad);yaca_free(enc);yaca_context_destroy(hContext);yaca_key_destroy(iv));
-       
+       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_encrypt_update", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_free(enc);yaca_context_destroy(hContext);yaca_key_destroy(iv));
+
        rem = enc_len - written_len;
        nRet = yaca_encrypt_finalize(hContext, enc + written_len, &rem);
-       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_encrypt_finalize", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(tag);yaca_free(aad);yaca_free(enc);yaca_context_destroy(hContext);yaca_key_destroy(iv));
+       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_encrypt_finalize", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_free(enc);yaca_context_destroy(hContext);yaca_key_destroy(iv));
 
        enc_len = rem + written_len;
 
        // Set the tag length and get the tag after final encryption
        nRet = yaca_context_set_property(hContext, YACA_PROPERTY_GCM_TAG_LEN, (void*)&tag_len, sizeof(tag_len));
-       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_context_set_property", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(tag);yaca_free(aad);yaca_free(enc);yaca_context_destroy(hContext);yaca_key_destroy(iv));
+       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_context_set_property", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_free(enc);yaca_context_destroy(hContext);yaca_key_destroy(iv));
 
-       nRet = yaca_context_get_property(hContext, YACA_PROPERTY_GCM_TAG, (void**)tag, &tag_len);
-       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_context_get_property", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(tag);yaca_free(aad);yaca_free(enc);yaca_context_destroy(hContext);yaca_key_destroy(iv));
+       nRet = yaca_context_get_property(hContext, YACA_PROPERTY_GCM_TAG, (void**)&tag, &tag_len);
+       PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_context_get_property", YacaGetError(nRet), yaca_key_destroy(hKey);yaca_free(aad);yaca_free(enc);yaca_context_destroy(hContext);yaca_key_destroy(iv));
 
        yaca_context_destroy(hContext);
        hContext = YACA_CONTEXT_NULL;
@@ -432,7 +429,7 @@ int ITc_yaca_decrypt_update_finalize_p(void)
 //Target API
        nRet = yaca_decrypt_finalize(hContext, dec + written_len, &rem);
        PRINT_RESULT_CLEANUP(YACA_ERROR_NONE, nRet, "yaca_decrypt_finalize", YacaGetError(nRet), yaca_context_destroy(hContext);yaca_key_destroy(iv);yaca_free(tag);yaca_free(aad);yaca_free(enc);yaca_free(dec);yaca_key_destroy(hKey));
-       
+
        dec_len = rem + written_len;
 
        yaca_free(enc);
@@ -442,8 +439,8 @@ int ITc_yaca_decrypt_update_finalize_p(void)
        yaca_context_destroy(hContext);
        yaca_key_destroy(iv);
        yaca_key_destroy(hKey);
-       
+
        return 0;
 }
 /** @} */
-/** @} */
\ No newline at end of file
+/** @} */
index 625753dffbd5440e8f2b7c4580353217a2ce6add..a009cd0e7bb20b543d606d633ca1dcf7b7631f96 100755 (executable)
@@ -387,8 +387,6 @@ int utc_yaca_context_get_property_p(void)
 
        assert_eq(yaca_randomize_bytes(aad, aad_len), YACA_ERROR_NONE);
 
-       assert_eq(yaca_zalloc(tag_len, (void**)&tag), YACA_ERROR_NONE);
-
        /* Encryption */
        {
                assert_eq(yaca_encrypt_initialize(&ctx, algo, bcm, key, iv), YACA_ERROR_NONE);
@@ -418,7 +416,7 @@ int utc_yaca_context_get_property_p(void)
                assert_eq(yaca_context_set_property(ctx, YACA_PROPERTY_GCM_TAG_LEN,
                                                  (void*)&tag_len, sizeof(tag_len)), YACA_ERROR_NONE);
 
-               assert_eq(yaca_context_get_property(ctx, YACA_PROPERTY_GCM_TAG, (void**)tag, &tag_len), YACA_ERROR_NONE);
+               assert_eq(yaca_context_get_property(ctx, YACA_PROPERTY_GCM_TAG, (void**)&tag, &tag_len), YACA_ERROR_NONE);
 
                yaca_context_destroy(ctx);
                ctx = YACA_CONTEXT_NULL;
index 4c3a43604ce76266589760531e86a526f21dfca9..f644ed69a40b4a7bb3a431f7fae96210ed2d151b 100755 (executable)
@@ -908,9 +908,6 @@ int utc_yaca_decrypt_finalize_p2(void)
        ret = yaca_randomize_bytes(aad, aad_len);
        assert_eq(ret, YACA_ERROR_NONE);
 
-       ret = yaca_zalloc(tag_len, (void**)&tag);
-       assert_eq(ret, YACA_ERROR_NONE);
-
        // Encryption
        ret = yaca_encrypt_initialize(&ctx, algo, bcm, key, iv);
        assert_eq(ret, YACA_ERROR_NONE);
@@ -942,7 +939,7 @@ int utc_yaca_decrypt_finalize_p2(void)
        ret = yaca_context_set_property(ctx, YACA_PROPERTY_GCM_TAG_LEN, (void*)&tag_len, sizeof(tag_len));
        assert_eq(ret, YACA_ERROR_NONE);
 
-       ret = yaca_context_get_property(ctx, YACA_PROPERTY_GCM_TAG, (void**)tag, &tag_len);
+       ret = yaca_context_get_property(ctx, YACA_PROPERTY_GCM_TAG, (void**)&tag, &tag_len);
        assert_eq(ret, YACA_ERROR_NONE);
 
        yaca_context_destroy(ctx);
@@ -1034,8 +1031,6 @@ int utc_yaca_decrypt_finalize_p3(void)
 
        assert_eq(yaca_randomize_bytes(aad, aad_len), YACA_ERROR_NONE);
 
-       assert_eq(yaca_zalloc(tag_len, (void**)&tag), YACA_ERROR_NONE);
-
        /* Encryption */
        {
                assert_eq(yaca_encrypt_initialize(&ctx, algo, bcm, key, iv), YACA_ERROR_NONE);
@@ -1068,7 +1063,7 @@ int utc_yaca_decrypt_finalize_p3(void)
                enc_len += written_len;
 
                /* Get the tag after final encryption */
-               assert_eq(yaca_context_get_property(ctx, YACA_PROPERTY_CCM_TAG, (void**)tag, &tag_len), YACA_ERROR_NONE);
+               assert_eq(yaca_context_get_property(ctx, YACA_PROPERTY_CCM_TAG, (void**)&tag, &tag_len), YACA_ERROR_NONE);
 
                yaca_context_destroy(ctx);
                ctx = YACA_CONTEXT_NULL;