From patchwork Tue Dec 19 12:00:11 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: 122379 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4052166qgn; Tue, 19 Dec 2017 04:02:06 -0800 (PST) X-Google-Smtp-Source: ACJfBou4jPD9TNqWgnIIrFl+z4wcSsm/CobQuO0CMuX2W0yAT8OLeNDx4S/vkXc0oo8iBzTh4heP X-Received: by 10.55.72.6 with SMTP id v6mr4407527qka.333.1513684926089; Tue, 19 Dec 2017 04:02:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513684926; cv=none; d=google.com; s=arc-20160816; b=z/l+GXxp3wiVK0Qs5WTsgpgISn680LoHwc/f9xyPxU2EF/ifEuPn27LpMZW++b0mL+ FKqh4iU80wL6eSOkKb6t8VFl/G81I4aeDuVXu/c0lmc4Av3PVKn88pKGsNa1MsbS1NBo KyNOg0IJsrx2YnVbObUhfe+INj5SKegZ3HF95pX6cPDesg6vS87k4dcEAfysxlbuGXdJ +niOxkP580MIPTLxncmqdPTvM5zXXKaTUOLXaANYdmgrOgXLiVo5vzpIhScz3KXTliOH 4O2fsA92CastfJH1I3sxVTbUaErTh0zPc6Rvq9+KbZ+cEcruzRf3iyV9WwzVRTxy6/2U rGYw== 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=9dib4UemSFzFfNVjJHptq1cDiQDy2h2LkcPC+b/ieXs=; b=wtvTp8tNkumZookTarnEZ+Yjl6r5yZGKTlZhdo917qeqlvrLYI7WXCCezrSidP4ELW qt2RwLO0NR2K3EBwLmnTZ0fP/+8kv3lyq0OVJejGYDYyVmG2bl83NpSsTKOmyhYN4ZGW aHEjL7UuuURK8rwVVMvNVgjEOq2/rWlaeRQ+d9jWGOu+P7WSrmDBrQ9YzL+GRl+cvr1x /0sr0jqZJHTS2plHcAEwNCGo/nVrWP3nHS3GWBayFi6BhEvLuUVrIPeJCIyS6TeQSv9t HyldE3YJDHmY4GWnkSXMxoNaayD1WpZgJOWrLAj0g+DL55zGBrqVaTBVudWisHaWbVWO K7+g== 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 y124si4298794qke.231.2017.12.19.04.02.05; Tue, 19 Dec 2017 04:02:06 -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 555AE608E2; Tue, 19 Dec 2017 12:02:05 +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_H2, 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 8438D608A4; Tue, 19 Dec 2017 12:01:52 +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 B285760911; Tue, 19 Dec 2017 12:01:44 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id 19D0D60953 for ; Tue, 19 Dec 2017 12:00:15 +0000 (UTC) Received: from mxback8g.mail.yandex.net (mxback8g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:169]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 69F5F43ADC for ; Tue, 19 Dec 2017 15:00:13 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback8g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id U12vQg2nNR-0DtmJSe8; Tue, 19 Dec 2017 15:00:13 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id fTWByZI6GW-0C241Mt7; Tue, 19 Dec 2017 15:00:12 +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 15:00:11 +0300 Message-Id: <1513684811-10957-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513684811-10957-1-git-send-email-odpbot@yandex.ru> References: <1513684811-10957-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 348 Subject: [lng-odp] [PATCH API-NEXT v2 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: 12fd3a9224a856271934986a1bad981843915d68 ** Merge commit sha: a843bb8f0c68c17ee7751ed68a88e7b2940d7a39 **/ test/validation/api/crypto/odp_crypto_test_inp.c | 116 +++++++++++++---------- 1 file changed, 64 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..0bcbeba82 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,71 @@ 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);