From patchwork Tue Dec 19 05:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 122341 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3711565qgn; Mon, 18 Dec 2017 21:23:39 -0800 (PST) X-Google-Smtp-Source: ACJfBouPGd/NvVq3q5+0hABoqLXo/tCQ/iJU2GktE0A6drRLfcN+CAQYs+pxLvn2k85evNBtb+GF X-Received: by 10.55.169.139 with SMTP id s133mr319808qke.355.1513661019109; Mon, 18 Dec 2017 21:23:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513661019; cv=none; d=google.com; s=arc-20160816; b=tBAjzs/1wX9POxJXIkz7TYpGGG2qKRpfe77ZCeLPo9jatvg0Myo1u6qJrZTxkYGr/G 0PXcX11fSslqmVUOIbZTXT+nwb76LcPYFu6Btc+5m6f4WTSoFjAdniqzk6Ovc0UKPkGx 3fnV3PU3otLoZN3g0MiJP45V6pTM22cqEOspdBrx3aNo2Yb5DZ29HFBovuaJNhaDZqI5 jTbb2qpeMtXW39qHlJgVBlDeTrg1eF3RvJ8syW9ketkTNM6Wrz6GuhbI2+mEg7wN5m1r aiOWNQ25FSavG3IPC/JkUFr4gOvbPN5r/Gs8yHBJGt7MWyuQHRPNlRkSlAMXqDpoNTh6 LzKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=w644GTObO8BeLcS2ZQwT7x6Dx5MoqDAn4it0uFDVgpk=; b=pde6mbGjakD3PBkYD89eAePeA3sL0dK+kN6B+Z4tMCH/10E5n5OvwCEcl5ymVEaz40 w97LIwJgRPRJVcIXnFkSL1lFgV7xBLmDtV/KSwP8TucLvdU7yRPbNskBl2ig6TjmvZi/ wRzRmGg1yHfg5H2r8FA7hSi1rR8lQmMB98WV2P2PdTHyNz7U4FMi9y4neU3wc3vO1qXK j3oFyU+bc6I72xWToYL6F3c7d3ENwQ3XQvVLUCoJXYCo+2pZ7BCo5qvlD6itolsi0msB eO20AidOm9moBc+DY2ViezvV3wPHHBaxH0mxZTwN5CEeeYXF1UpSaOaywvwGmXWTZhN4 I8Ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id q66si14845213qkd.163.2017.12.18.21.23.38; Mon, 18 Dec 2017 21:23:39 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id BF37B6175F; Tue, 19 Dec 2017 05:23:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 023986150F; Tue, 19 Dec 2017 05:08:16 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 7493A608E8; Tue, 19 Dec 2017 05:04:22 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id ADFFF608FD for ; Tue, 19 Dec 2017 05:00:11 +0000 (UTC) Received: from mxback9o.mail.yandex.net (mxback9o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::23]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 08C3B56030A8 for ; Tue, 19 Dec 2017 08:00:10 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback9o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id uWiBOelwSo-093icMl8; Tue, 19 Dec 2017 08:00:10 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id o8gpanvgaB-09YCSbSV; Tue, 19 Dec 2017 08:00:09 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 19 Dec 2017 08:00:08 +0300 Message-Id: <1513659608-32569-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513659608-32569-1-git-send-email-odpbot@yandex.ru> References: <1513659608-32569-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 348 Subject: [lng-odp] [PATCH API-NEXT v1 1/1] validation: crypto: run the test twice to catch no-reinit errors X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Add another iteration of crypto opertion to be run when testing to catch different 'not reinitialized' or 'not cleared' errors. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 348 (lumag:crypto-reinit) ** https://github.com/Linaro/odp/pull/348 ** Patch: https://github.com/Linaro/odp/pull/348.patch ** Base sha: 0588040068a50d0d15a641d091fce23214b15594 ** Merge commit sha: 220c0704d2e354ec6bf9d6b44a8a4bc3dc7db889 **/ test/validation/api/crypto/odp_crypto_test_inp.c | 117 +++++++++++++---------- 1 file changed, 65 insertions(+), 52 deletions(-) diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index cba472ded..17be0077f 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -276,6 +276,13 @@ static int alg_packet_op_enq(odp_packet_t pkt, return 0; } +typedef enum crypto_test { + NORMAL_TEST = 0, /**< Plain execution */ + REPEAT_TEST, /**< Rerun without reinitializing the session */ + WRONG_DIGEST_TEST, /**< Check against wrong digest */ + MAX_TEST, /**< Final mark */ +} crypto_test; + /* Basic algorithm run function for async inplace mode. * Creates a session from input parameters and runs one operation * on input_vec. Checks the output of the crypto operation against @@ -296,7 +303,7 @@ static void alg_test(odp_crypto_op_t op, int rc; odp_crypto_ses_create_err_t status; odp_bool_t ok = false; - odp_bool_t should_fail = false; + int iteration; odp_crypto_session_param_t ses_params; odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA]; odp_crypto_auth_capability_t auth_capa[MAX_ALG_CAPA]; @@ -451,66 +458,72 @@ static void alg_test(odp_crypto_op_t op, odp_packet_t pkt = odp_packet_alloc(suite_context.pool, ref->length + ref->digest_length); CU_ASSERT(pkt != ODP_PACKET_INVALID); -restart: - if (op == ODP_CRYPTO_OP_ENCODE) { - odp_packet_copy_from_mem(pkt, 0, ref->length, ref->plaintext); - } else { - odp_packet_copy_from_mem(pkt, 0, ref->length, ref->ciphertext); - odp_packet_copy_from_mem(pkt, ref->length, - ref->digest_length, - ref->digest); - if (should_fail) { - uint8_t byte = ~ref->digest[0]; + for (iteration = NORMAL_TEST; iteration < MAX_TEST; iteration++) { + /* checking against wrong digest is meaningless for NULL digest + * or when generating digest */ + if (iteration == WRONG_DIGEST_TEST && + (auth_alg == ODP_AUTH_ALG_NULL || + op == ODP_CRYPTO_OP_ENCODE)) + continue; + + if (op == ODP_CRYPTO_OP_ENCODE) { + odp_packet_copy_from_mem(pkt, 0, ref->length, + ref->plaintext); + } else { + odp_packet_copy_from_mem(pkt, 0, ref->length, + ref->ciphertext); odp_packet_copy_from_mem(pkt, ref->length, - 1, &byte); + ref->digest_length, + ref->digest); + if (iteration == WRONG_DIGEST_TEST) { + uint8_t byte = ~ref->digest[0]; + + odp_packet_copy_from_mem(pkt, ref->length, + 1, &byte); + } } - } - if (!suite_context.packet) - rc = alg_op(pkt, &ok, session, - ovr_iv ? ref->iv : NULL, - &cipher_range, &auth_range, - ref->aad, ref->length); - else if (ODP_CRYPTO_ASYNC == suite_context.op_mode) - rc = alg_packet_op_enq(pkt, &ok, session, - ovr_iv ? ref->iv : NULL, - &cipher_range, &auth_range, - ref->aad, ref->length); - else - rc = alg_packet_op(pkt, &ok, session, - ovr_iv ? ref->iv : NULL, - &cipher_range, &auth_range, - ref->aad, ref->length); - if (rc < 0) { - goto cleanup; - } + if (!suite_context.packet) + rc = alg_op(pkt, &ok, session, + ovr_iv ? ref->iv : NULL, + &cipher_range, &auth_range, + ref->aad, ref->length); + else if (ODP_CRYPTO_ASYNC == suite_context.op_mode) + rc = alg_packet_op_enq(pkt, &ok, session, + ovr_iv ? ref->iv : NULL, + &cipher_range, &auth_range, + ref->aad, ref->length); + else + rc = alg_packet_op(pkt, &ok, session, + ovr_iv ? ref->iv : NULL, + &cipher_range, &auth_range, + ref->aad, ref->length); + if (rc < 0) { + break; + } - if (should_fail) { - CU_ASSERT(!ok); - goto cleanup; - } + if (iteration == WRONG_DIGEST_TEST) { + CU_ASSERT(!ok); + continue; + } - CU_ASSERT(ok); - - if (op == ODP_CRYPTO_OP_ENCODE) { - CU_ASSERT(!packet_cmp_mem(pkt, 0, - ref->ciphertext, - ref->length)); - CU_ASSERT(!packet_cmp_mem(pkt, ref->length, - ref->digest, - ref->digest_length)); - } else { - CU_ASSERT(!packet_cmp_mem(pkt, 0, - ref->plaintext, - ref->length)); - if (ref->digest_length != 0) { - should_fail = true; - goto restart; + CU_ASSERT(ok); + + if (op == ODP_CRYPTO_OP_ENCODE) { + CU_ASSERT(!packet_cmp_mem(pkt, 0, + ref->ciphertext, + ref->length)); + CU_ASSERT(!packet_cmp_mem(pkt, ref->length, + ref->digest, + ref->digest_length)); + } else { + CU_ASSERT(!packet_cmp_mem(pkt, 0, + ref->plaintext, + ref->length)); } } -cleanup: rc = odp_crypto_session_destroy(session); CU_ASSERT(!rc);