From patchwork Tue Dec 2 10:02:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Badicioiu X-Patchwork-Id: 41804 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8BA6F20672 for ; Tue, 2 Dec 2014 10:07:23 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf7922845lbj.7 for ; Tue, 02 Dec 2014 02:07:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id :mime-version:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Jywi/BzraMga9MhPychAwgNm7ekiYxXdt917L+IQ+IM=; b=jX0eKwLtCYPaEfurJ5p56NkDHUkc5l6zOWQQ7mb7cxu+uePP1qS/9a+Z4dAEz42GfU Bj66vTWlszWLDshXoznnI4gnDHS7894eyvjvMTDnPnaIlSEj24JEc69vwkZx6hqd9ivm /ePzo4/fJgrW4tn5aRx5Hg64kPgYN9E+R3EgdJjRCTzhzQ6vUA2nvsclBoaGfBTkGeRE J9fH1M36J2nLP5jRhwYo1ZhLevMoo+nDMt6J7awVntAwo/yncWKYT/h4cIQ1Se3k8Ptc sd89sgo2maGzhG6K2HQSoAyro3r48u7XhwMKS4xf5iZd3x31iQhhuruM6G1yh7HgmBRa omEQ== X-Gm-Message-State: ALoCoQnEvHHJ1ylCt5s73MrHW2gzVhP2OWxEoyUjM2fQHQdb4YZ+9VU+4s0E9w/waHup/de90CiF X-Received: by 10.180.24.131 with SMTP id u3mr675788wif.4.1417514842477; Tue, 02 Dec 2014 02:07:22 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.227 with SMTP id u3ls12551laa.109.gmail; Tue, 02 Dec 2014 02:07:22 -0800 (PST) X-Received: by 10.152.30.100 with SMTP id r4mr14921376lah.58.1417514842311; Tue, 02 Dec 2014 02:07:22 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id bc1si19937478lbc.80.2014.12.02.02.07.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Dec 2014 02:07:22 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id b6so710970lbj.22 for ; Tue, 02 Dec 2014 02:07:22 -0800 (PST) X-Received: by 10.152.3.67 with SMTP id a3mr17022593laa.56.1417514842093; Tue, 02 Dec 2014 02:07:22 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp454197lbc; Tue, 2 Dec 2014 02:07:21 -0800 (PST) X-Received: by 10.224.29.84 with SMTP id p20mr18447523qac.13.1417514840179; Tue, 02 Dec 2014 02:07:20 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id q6si23744247qaq.79.2014.12.02.02.07.18 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Dec 2014 02:07:20 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XvkMX-0003Np-4y; Tue, 02 Dec 2014 10:07:17 +0000 Received: from mail-bn1bon0098.outbound.protection.outlook.com ([157.56.111.98] helo=na01-bn1-obe.outbound.protection.outlook.com) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XvkMQ-0003Nh-Se for lng-odp@lists.linaro.org; Tue, 02 Dec 2014 10:07:11 +0000 Received: from CO2PR03CA0053.namprd03.prod.outlook.com (10.141.194.180) by CO2PR03MB1019.namprd03.prod.outlook.com (10.141.186.147) with Microsoft SMTP Server (TLS) id 15.1.11.14; Tue, 2 Dec 2014 10:07:04 +0000 Received: from BL2FFO11FD015.protection.gbl (2a01:111:f400:7c09::177) by CO2PR03CA0053.outlook.office365.com (2a01:111:e400:1414::44) with Microsoft SMTP Server (TLS) id 15.1.16.15 via Frontend Transport; Tue, 2 Dec 2014 10:06:53 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD015.mail.protection.outlook.com (10.173.160.223) with Microsoft SMTP Server (TLS) id 15.1.6.13 via Frontend Transport; Tue, 2 Dec 2014 10:06:51 +0000 Received: from fsr-fed1364-15.ea.freescale.net (fsr-fed1364-15.ea.freescale.net [10.171.81.144]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id sB2A6nwp031301; Tue, 2 Dec 2014 03:06:50 -0700 From: To: Date: Tue, 2 Dec 2014 12:02:48 +0200 Message-ID: <1417514568-1356-1-git-send-email-alexandru.badicioiu@linaro.org> X-Mailer: git-send-email 1.7.3.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 130619884120751974; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(448002)(189002)(199003)(243025005)(99396003)(102836001)(48376002)(95666004)(104016003)(15202345003)(88136002)(89996001)(47776003)(20776003)(64706001)(21056001)(87936001)(50466002)(86152002)(92726001)(92566001)(97736003)(36756003)(107046002)(33646002)(120916001)(229853001)(81156004)(2351001)(110136001)(85326001)(104166001)(106466001)(62966003)(50986999)(46102003)(6806004)(69596002)(575784001)(44976005)(19580405001)(4396001)(31966008)(84676001)(77156002)(50226001)(93916002)(86362001)(19580395003)(15975445006)(87286001)(68736005); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR03MB1019; H:az84smr01.freescale.net; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:CO2PR03MB1019; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:; SRVR:CO2PR03MB1019; X-Forefront-PRVS: 0413C9F1ED Received-SPF: PermError (protection.outlook.com: domain of linaro.org used an invalid SPF mechanism) X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(400003)(401002)(402001); SRVR:CO2PR03MB1019; X-Topics: crypto patch Subject: [lng-odp] [PATCH v2] crypto: cunit test suite for rng X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alexandru.badicioiu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Alexandru Badicioiu Signed-off-by: Alexandru Badicioiu Reviewed-by: Mike Holmes --- test/validation/Makefile.am | 1 + test/validation/crypto/odp_crypto_test_rng.c | 30 ++++++++++++++++++++++++++ test/validation/crypto/odp_crypto_test_rng.h | 17 ++++++++++++++ test/validation/crypto/test_vectors.h | 23 ++++++------------- test/validation/crypto/test_vectors_len.h | 21 ++++++++++++++++++ test/validation/odp_crypto.c | 2 + 6 files changed, 78 insertions(+), 16 deletions(-) create mode 100644 test/validation/crypto/odp_crypto_test_rng.c create mode 100644 test/validation/crypto/odp_crypto_test_rng.h create mode 100644 test/validation/crypto/test_vectors_len.h diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index 0b831d0..52dbd50 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -17,4 +17,5 @@ dist_odp_init_SOURCES = odp_init.c dist_odp_queue_SOURCES = odp_queue.c dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \ crypto/odp_crypto_test_sync_inp.c \ + crypto/odp_crypto_test_rng.c \ odp_crypto.c diff --git a/test/validation/crypto/odp_crypto_test_rng.c b/test/validation/crypto/odp_crypto_test_rng.c new file mode 100644 index 0000000..2898cb1 --- /dev/null +++ b/test/validation/crypto/odp_crypto_test_rng.c @@ -0,0 +1,30 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include +#include "CUnit/Basic.h" +#include "CUnit/TestDB.h" +#include "test_vectors_len.h" + +/* + * This test verifies that HW random number generator is able + * to produce an IV for TDES_CBC cipher algorithm. + * */ +#define RNG_GET_SIZE "RNG_GET_SIZE" +static void rng_get_size(void) +{ + int ret; + size_t len = TDES_CBC_IV_LEN; + uint8_t buf[TDES_CBC_IV_LEN]; + + ret = odp_hw_random_get(buf, &len, false); + CU_ASSERT(!ret); + CU_ASSERT(len == TDES_CBC_IV_LEN); +} + +CU_TestInfo test_rng[] = { + { RNG_GET_SIZE, rng_get_size }, + CU_TEST_INFO_NULL, +}; diff --git a/test/validation/crypto/odp_crypto_test_rng.h b/test/validation/crypto/odp_crypto_test_rng.h new file mode 100644 index 0000000..16909b3 --- /dev/null +++ b/test/validation/crypto/odp_crypto_test_rng.h @@ -0,0 +1,17 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#ifndef ODP_CRYPTO_TEST_RNG_ +#define ODP_CRYPTO_TEST_RNG_ + +#include "CUnit/TestDB.h" + +/* Suite name */ +#define ODP_CRYPTO_RNG "ODP_CRYPTO_RNG" + +/* Suite test array */ +extern CU_TestInfo test_rng[]; + +#endif diff --git a/test/validation/crypto/test_vectors.h b/test/validation/crypto/test_vectors.h index c151952..369fc16 100644 --- a/test/validation/crypto/test_vectors.h +++ b/test/validation/crypto/test_vectors.h @@ -4,15 +4,10 @@ * SPDX-License-Identifier: BSD-3-Clause */ - +#include "test_vectors_len.h" /* TDES-CBC reference vectors, according to * "http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf" */ - -#define TDES_CBC_KEY_LEN 24 /* key length(in bytes) for tdes-cbc */ -#define TDES_CBC_IV_LEN 8 /* IV length(in bytes) for tdes-cbc */ -#define TDES_CBC_MAX_DATA_LEN 16 /* max. plain text length(in bytes) */ - static uint8_t tdes_cbc_reference_key[][TDES_CBC_KEY_LEN] = { {0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10, 0x43, 0xcd, 0x26, 0x5d, 0x58, 0x40, 0xea, 0xf1, 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a, 0x8c, @@ -31,27 +26,22 @@ static uint8_t tdes_cbc_reference_iv[][TDES_CBC_IV_LEN] = { /** length in bytes */ static uint32_t tdes_cbc_reference_length[] = { 8, 16 }; -static uint8_t tdes_cbc_reference_plaintext[][TDES_CBC_MAX_DATA_LEN] = { +static uint8_t +tdes_cbc_reference_plaintext[][TDES_CBC_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} }; -static uint8_t tdes_cbc_reference_ciphertext[][TDES_CBC_MAX_DATA_LEN] = { +static uint8_t +tdes_cbc_reference_ciphertext[][TDES_CBC_MAX_DATA_LEN] = { {0xb2, 0x2b, 0x8d, 0x66, 0xde, 0x97, 0x06, 0x92}, {0x7b, 0x1f, 0x7c, 0x7e, 0x3b, 0x1c, 0x94, 0x8e, 0xbd, 0x04, 0xa7, 0x5f, 0xfb, 0xa7, 0xd2, 0xf5} }; - -/* HMAC-MD5 test vectors - RFC2104 */ -#define HMAC_MD5_KEY_LEN 16 -#define HMAC_MD5_MAX_DATA_LEN 128 -#define HMAC_MD5_DIGEST_LEN 16 -#define HMAC_MD5_96_CHECK_LEN 12 - static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = { { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b } , @@ -65,7 +55,8 @@ static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = { static uint32_t hmac_md5_reference_length[] = { 8, 28, 50 }; -static uint8_t hmac_md5_reference_plaintext[][HMAC_MD5_MAX_DATA_LEN] = { +static uint8_t +hmac_md5_reference_plaintext[][HMAC_MD5_MAX_DATA_LEN] = { /* "Hi There" */ { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, diff --git a/test/validation/crypto/test_vectors_len.h b/test/validation/crypto/test_vectors_len.h new file mode 100644 index 0000000..8c83ba1 --- /dev/null +++ b/test/validation/crypto/test_vectors_len.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#ifndef TEST_VECTORS_LEN_ +#define TEST_VECTORS_LEN_ + +/* TDES-CBC */ +#define TDES_CBC_KEY_LEN 24 +#define TDES_CBC_IV_LEN 8 +#define TDES_CBC_MAX_DATA_LEN 16 + + +/* HMAC-MD5 */ +#define HMAC_MD5_KEY_LEN 16 +#define HMAC_MD5_MAX_DATA_LEN 128 +#define HMAC_MD5_DIGEST_LEN 16 +#define HMAC_MD5_96_CHECK_LEN 12 + +#endif diff --git a/test/validation/odp_crypto.c b/test/validation/odp_crypto.c index 9342aca..81343a9 100644 --- a/test/validation/odp_crypto.c +++ b/test/validation/odp_crypto.c @@ -9,6 +9,7 @@ #include "CUnit/TestDB.h" #include "odp_crypto_test_async_inp.h" #include "odp_crypto_test_sync_inp.h" +#include "odp_crypto_test_rng.h" #define SHM_PKT_POOL_SIZE (512*2048*2) #define SHM_PKT_POOL_BUF_SIZE (1024 * 32) @@ -26,6 +27,7 @@ static int init_suite(void) CU_SuiteInfo suites[] = { {ODP_CRYPTO_SYNC_INP, init_suite, NULL, NULL, NULL, test_array_sync }, {ODP_CRYPTO_ASYNC_INP, init_suite, NULL, NULL, NULL, test_array_async }, + {ODP_CRYPTO_RNG, init_suite, NULL, NULL, NULL, test_rng }, CU_SUITE_INFO_NULL, };