From patchwork Thu Jun 1 09:03:35 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: 100856 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp710381qge; Thu, 1 Jun 2017 02:17:37 -0700 (PDT) X-Received: by 10.200.48.98 with SMTP id g31mr508149qte.119.1496308657036; Thu, 01 Jun 2017 02:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496308657; cv=none; d=google.com; s=arc-20160816; b=lQf4S7tzwV/cPwwXbiy+il39uVjOxA3nC/Wt81DBW5Z9LY+Fhm6hykyYGbEwPIzPwD R36rr/F8ZeK9hm46Y32ZBfwBy3cqfpZzN3li+S8mSXgS7zIUvSfqR7A3BpQLueu4xCsm DkkFAruJCSUHHgNKgUp1gzE7uRni2mr26fzLOxT3cdpwxalWwAtgr+A+y05ZcYHFqWbx cpe6IRFeO4HvDmQR4HVaYf2cfpRybd5/ZXYiuzFwvQYsRWEZe/Jub01DfqB3gyxCtnAw ZHJOgvH7CwTxoIvxewj5tuDNS8GTKjum+Su8QiilH3Pu6LmcileFaTl8N034B7ZcAxDN 6EiQ== 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=F8KHtBKGLWIRxbxt4bH67oQymqEaDw4ssmuBU7oTGRs=; b=oviphHn64/5Pp3yfBxhCwc3GsT+CES/yXS5R4q+bRVpbZXUrQCnysl+TmXYa6xKjFP 19eVsZtIxjD152KX0vVq0Aj3ZqtbFRj0NnwEZ/0gXAvaOnfX30ek74ue2mfHjfoAqw8X Cfjj+hhntnZd6J+DovkMInRWajwqjWznFv/lLlJQ6s0qWmvavh05Xj/m/dhanqoNndPz jy0LHlLnASuNLdGl+6y++lI29fAatsqHHWIOwv8JsZaiM/mgmCUPDT7aqkbGFhUIFpPd DBchFgNO4BeQr3o+1LirD5ZTpZkrO5A4DA2ITSGNBJwIMJCWAM7Y5tD4faEMONto2ARV /jwA== 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 d80si3664783qkg.281.2017.06.01.02.17.36; Thu, 01 Jun 2017 02:17:37 -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 B4622608DD; Thu, 1 Jun 2017 09:17:36 +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 BA43C60DD0; Thu, 1 Jun 2017 09:06:39 +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 EC7F360D8E; Thu, 1 Jun 2017 09:06:27 +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 DD8DF60D42 for ; Thu, 1 Jun 2017 09:04:04 +0000 (UTC) Received: by mail-lf0-f43.google.com with SMTP id a136so8036993lfa.0 for ; Thu, 01 Jun 2017 02:04:04 -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=F8KHtBKGLWIRxbxt4bH67oQymqEaDw4ssmuBU7oTGRs=; b=bJblx7flUUFhcfmmk+Ymg4d+U7bDtLAJwNAiMJhBkO3ruOpXJXg0FqYGmvCSmFeDFQ aqDGoV6ARE/VT8bPLKkibdLvf5iRFCPrbUu/6nWyC7vJWKWQjNKLb/OutaGMPKqW7UXv IlG5wVxqe4wdP0VBxeWvKmaNYO2jg/cL7WlwXZmUW9fftl2jqOV2Gh+WgNGwdUFpUP4r H7NvCelXzPJEbfsomw+n8tBNYtrAM/vfwOL5VusaS3tmh4YQsEIzredx/O6/MefU9DdZ saro2GWcH9JwZkM+BSbHlM2zfJoIGs1XRQMrJNu/I/1SoSi7egOezxFfpT9EPCsNw9yZ SS2Q== X-Gm-Message-State: AODbwcARrOiq46lxk/dyZYj4j0KEvdA6cHWA72IYT5HoJUatwvpaLMH+ 2Ma1B65/u8XK3xVGx4xs3vCY X-Received: by 10.25.23.198 with SMTP id 67mr196784lfx.162.1496307843469; Thu, 01 Jun 2017 02:04:03 -0700 (PDT) Received: from forlindon.lumag.auriga.ru ([188.162.64.12]) by smtp.gmail.com with ESMTPSA id 129sm4232819ljf.36.2017.06.01.02.04.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 02:04:02 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 12:03:35 +0300 Message-Id: <20170601090339.9313-20-dmitry.ereminsolenikov@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170601090339.9313-1-dmitry.ereminsolenikov@linaro.org> References: <20170601090339.9313-1-dmitry.ereminsolenikov@linaro.org> Subject: [lng-odp] [PATCH API-NEXT v5 19/23] validation: 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..4d8f7b54a51b 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 = { .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_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