From patchwork Thu Jun 1 08:22:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Eremin-Solenikov X-Patchwork-Id: 100835 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp698207qge; Thu, 1 Jun 2017 01:36:38 -0700 (PDT) X-Received: by 10.200.56.88 with SMTP id r24mr330368qtb.174.1496306198250; Thu, 01 Jun 2017 01:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496306198; cv=none; d=google.com; s=arc-20160816; b=thSxyCtVm72Ctxf6GHH6rCXOgw27lsQc24UjSM0s9eK3m13oiK0zdh4C2b7T1IJL89 XFgI5GYhlbf6e8YX6p93R3+d1iuJ12xoGflus2kgidkFLhai5JKRpqGIJscvl7SyYcag 0RqkuDGXGwlJywbQQrQdIKMsfz+GwO2ucy1g9BVhdhBpdqsEv7ICxmpK6j5071Ytwx6b fINke7gLi+GjLCLFZA0ioF/tPQNvHwhhXexgmnqfsQ9A6hVQDGdrMNKZIr1Fi8gGxoye 3NHouhquclgXKZm9T01pWhZYmsUZEGy+UUmzV5hqZ6Jn8ofIQcNlkwKc4PPrsmNkDqAB 4MdQ== 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:references:in-reply-to :message-id:date:to:from:delivered-to:arc-authentication-results; bh=HCqm2KkDdYMe4tbQ3ZLD+3laHoaNgFV3j8xoaEeMlrg=; b=whBem9YyEF+0q5ll8fhaMrlj8CoCssyOS94/VS7vv2hszQIJXlhLpsim4yDQHWeO2q Z4mqhZ+nN/4XBOOxyE8yPeWVfLOG9c8jW9zQJXDl+pzDZrBp1uh5hN0M2nqDHUg9yVBi UlcOzMG/vIuJfHmRqIF5PjTgcnD+PFzRmwa8BzD0lGrhFKdS09eCC50zlu+5WyofjXU7 xlbJXMxrMbd52vCeWuyw9VTaYNFW98BuUW5rxcocGQ1Z3mgNpJ/C2F3HxYVLJV+OXKh4 vILRc1bqWgAtUe2jtQ7YyyTeqSpy1DVRvfmhuTYWEk0QYGuSZbw3wiySZzRe41h9fFNz jSyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y68si18978233qkc.250.2017.06.01.01.36.38; Thu, 01 Jun 2017 01:36:38 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E5224606A4; Thu, 1 Jun 2017 08:36:37 +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=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, 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 C83E360D92; Thu, 1 Jun 2017 08:26:17 +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 7B78C60D44; Thu, 1 Jun 2017 08:25:57 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id 0130460D43 for ; Thu, 1 Jun 2017 08:23:41 +0000 (UTC) Received: by mail-lf0-f43.google.com with SMTP id c184so17270406lfe.2 for ; Thu, 01 Jun 2017 01:23:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=HCqm2KkDdYMe4tbQ3ZLD+3laHoaNgFV3j8xoaEeMlrg=; b=Nyf+Ta+WsX7NxaGi/eSP7FTnxGHF0z8vZsvjEiDB15vBzrXodFqbBSbkSbgpA/i9ss YB2590X+JuAg+vpP2ch17kiFLdFsHaXTnOB0UcLe2xiH78M4NwCAvMByBcAu8eXJyQLD PiEYU2XsMUlvMdGoDbFj3P/xu7twuF+mT45VZQnJZEnj3powaIoPLcNTF2E/CS8zyI9m iXXAOdAF12JcFj1+kc57nV3kJ2TzLAKCmGPOiMIq1x/DOjQBTWePQaSfsxTPEirnPKpN CP0GQufODLhC53t9ywoUNIrr6rEehURcJRDazbWNYJNx+LV2aQL0X6FrV7CyIkzctRUf 2VYg== X-Gm-Message-State: AODbwcAvj2tD9W6P3rf5IR2Rp8I2rY8p/7ANb5/sFCG4mesoURXDE/Tu K43XhkMGmEOIKhuB7s3oGEx5 X-Received: by 10.25.159.142 with SMTP id i136mr108443lfe.151.1496305419541; Thu, 01 Jun 2017 01:23:39 -0700 (PDT) Received: from forlindon.lumag.auriga.ru ([188.162.64.12]) by smtp.gmail.com with ESMTPSA id c78sm4185837lfh.25.2017.06.01.01.23.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:39 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:56 +0300 Message-Id: <20170601082320.4673-17-dmitry.ereminsolenikov@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170601082320.4673-1-dmitry.ereminsolenikov@linaro.org> References: <20170601082320.4673-1-dmitry.ereminsolenikov@linaro.org> Subject: [lng-odp] [PATCH 09/23] test: crypto: add tests for NULL cipher 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" Signed-off-by: Dmitry Eremin-Solenikov --- test/common_plat/validation/api/crypto/crypto.h | 2 + .../validation/api/crypto/odp_crypto_test_inp.c | 71 ++++++++++++++++++++++ .../validation/api/crypto/test_vectors.h | 12 ++++ .../validation/api/crypto/test_vectors_len.h | 3 + 4 files changed, 88 insertions(+) -- 2.11.0 diff --git a/test/common_plat/validation/api/crypto/crypto.h b/test/common_plat/validation/api/crypto/crypto.h index 4d810f62b7ce..2a491c3c9170 100644 --- a/test/common_plat/validation/api/crypto/crypto.h +++ b/test/common_plat/validation/api/crypto/crypto.h @@ -10,6 +10,8 @@ #include "odp_cunit_common.h" /* test functions: */ +void crypto_test_enc_alg_null(void); +void crypto_test_dec_alg_null(void); void crypto_test_enc_alg_3des_cbc(void); void crypto_test_enc_alg_3des_cbc_ovr_iv(void); void crypto_test_dec_alg_3des_cbc(void); diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c index 470c5bc5e70d..e33597ed0b80 100644 --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c @@ -430,6 +430,73 @@ static int check_auth_options(odp_auth_alg_t auth, uint32_t key_len, return 1; } +static int check_alg_null(void) +{ + return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_NULL); +} + +void crypto_test_enc_alg_null(void) +{ + odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, + auth_key = { .data = NULL, .length = 0 }; + odp_crypto_iv_t iv; + unsigned int test_vec_num = (sizeof(null_reference_length) / + sizeof(null_reference_length[0])); + unsigned int i; + + for (i = 0; i < test_vec_num; i++) { + if (!check_cipher_options(ODP_CIPHER_ALG_NULL, + cipher_key.length, iv.length)) + continue; + + alg_test(ODP_CRYPTO_OP_ENCODE, + 0, + ODP_CIPHER_ALG_NULL, + iv, + NULL, + cipher_key, + ODP_AUTH_ALG_NULL, + auth_key, + NULL, NULL, + NULL, 0, + null_reference_plaintext[i], + null_reference_length[i], + null_reference_plaintext[i], + null_reference_length[i], NULL, 0); + } +} + +void crypto_test_dec_alg_null(void) +{ + odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 }, + auth_key = { .data = NULL, .length = 0 }; + odp_crypto_iv_t iv = { .data = NULL, .length = 0 }; + unsigned int test_vec_num = (sizeof(null_reference_length) / + sizeof(null_reference_length[0])); + unsigned int i; + + for (i = 0; i < test_vec_num; i++) { + if (!check_cipher_options(ODP_CIPHER_ALG_NULL, + cipher_key.length, iv.length)) + continue; + + alg_test(ODP_CRYPTO_OP_DECODE, + 0, + ODP_CIPHER_ALG_NULL, + iv, + NULL, + cipher_key, + ODP_AUTH_ALG_NULL, + auth_key, + NULL, NULL, + NULL, 0, + null_reference_plaintext[i], + null_reference_length[i], + null_reference_plaintext[i], + null_reference_length[i], NULL, 0); + } +} + static int check_alg_3des_cbc(void) { return check_alg_support(ODP_CIPHER_ALG_3DES_CBC, ODP_AUTH_ALG_NULL); @@ -1252,6 +1319,10 @@ int crypto_suite_async_init(void) } odp_testinfo_t crypto_suite[] = { + ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_null, + check_alg_null), + ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_null, + check_alg_null), ODP_TEST_INFO_CONDITIONAL(crypto_test_enc_alg_3des_cbc, check_alg_3des_cbc), ODP_TEST_INFO_CONDITIONAL(crypto_test_dec_alg_3des_cbc, diff --git a/test/common_plat/validation/api/crypto/test_vectors.h b/test/common_plat/validation/api/crypto/test_vectors.h index 0d36c249870f..6d568b918aa4 100644 --- a/test/common_plat/validation/api/crypto/test_vectors.h +++ b/test/common_plat/validation/api/crypto/test_vectors.h @@ -8,6 +8,18 @@ #define _ODP_TEST_CRYPTO_VECTORS_H_ #include "test_vectors_len.h" + +/** length in bytes */ +static uint32_t null_reference_length[] = { 8, 16 }; + +static uint8_t +null_reference_plaintext[][NULL_MAX_DATA_LEN] = { + {0x32, 0x6a, 0x49, 0x4c, 0xd3, 0x3f, 0xe7, 0x56}, + + {0x84, 0x40, 0x1f, 0x78, 0xfe, 0x6c, 0x10, 0x87, 0x6d, 0x8e, 0xa2, 0x30, + 0x94, 0xea, 0x53, 0x09} +}; + /* TDES-CBC reference vectors, according to * "http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf" */ diff --git a/test/common_plat/validation/api/crypto/test_vectors_len.h b/test/common_plat/validation/api/crypto/test_vectors_len.h index 80fd927b7f25..c1521dd763fc 100644 --- a/test/common_plat/validation/api/crypto/test_vectors_len.h +++ b/test/common_plat/validation/api/crypto/test_vectors_len.h @@ -6,6 +6,9 @@ #ifndef TEST_VECTORS_LEN_ #define TEST_VECTORS_LEN_ +/* NULL */ +#define NULL_MAX_DATA_LEN 16 + /* TDES-CBC */ #define TDES_CBC_KEY_LEN 24 #define TDES_CBC_IV_LEN 8