From patchwork Thu Nov 27 09:20:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Badicioiu X-Patchwork-Id: 41607 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 30C552486D for ; Thu, 27 Nov 2014 09:24:32 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e53sf2917245eek.11 for ; Thu, 27 Nov 2014 01:24:31 -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=uoeRDoHmXczUjGC44CCghML5T2DnQ0LElcrxotPcz9I=; b=U/2BEwBtKMB0zo9avcgJoscRB6vNrAGh+kQkk8FdnWRP448aEe+Qy5MH2RBnDBHtq9 k4N/0UiRui1pN8LxPhWgSziy4kjMAtKNbeJTBSUkIhqe59luPOmyGP3iMyfsNJjIQai9 m+GF+P/fzINiqshzMUqKi5bGBQ+Kv6RY3jaauO5N9TcCKXUsHer4E94qpqjSJL26hgh5 jp6V//HSrbmcpuc+GO42YQmjU4iS3b217AU2rKqjneHqgixUxRUIKLA6hbe9dN5fkQnB ff7SeoLCrlHB4V8TfRnHbBCmeldrgnrfzBezUCV28sSFUfJ9uRj1tNJ60xcncOY0mxND fwAw== X-Gm-Message-State: ALoCoQl9O6xR87z1UNQ/zkwKpVajIoW0INVkDz77jhFhkJjdDhAWIgpaYIOJ0JAkenzlWRseEngb X-Received: by 10.152.29.226 with SMTP id n2mr129708lah.9.1417080271395; Thu, 27 Nov 2014 01:24:31 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.169 with SMTP id c9ls22827laa.104.gmail; Thu, 27 Nov 2014 01:24:31 -0800 (PST) X-Received: by 10.152.19.133 with SMTP id f5mr36229731lae.87.1417080271056; Thu, 27 Nov 2014 01:24:31 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id ll1si747980lac.41.2014.11.27.01.24.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Nov 2014 01:24:31 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id s18so3948386lam.35 for ; Thu, 27 Nov 2014 01:24:31 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr14674261lal.29.1417080270944; Thu, 27 Nov 2014 01:24:30 -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 ew9csp769603lbc; Thu, 27 Nov 2014 01:24:29 -0800 (PST) X-Received: by 10.68.65.2 with SMTP id t2mr61985502pbs.39.1417080269057; Thu, 27 Nov 2014 01:24:29 -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 pu5si10598043pac.195.2014.11.27.01.24.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 27 Nov 2014 01:24:29 -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 1XtvJC-0001yX-CM; Thu, 27 Nov 2014 09:24:18 +0000 Received: from mail-bn1bon0083.outbound.protection.outlook.com ([157.56.111.83] helo=na01-bn1-obe.outbound.protection.outlook.com) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XtvJ6-0001qm-9k for lng-odp@lists.linaro.org; Thu, 27 Nov 2014 09:24:12 +0000 Received: from DM2PR03CA0047.namprd03.prod.outlook.com (10.141.96.46) by BY2PR03MB596.namprd03.prod.outlook.com (10.255.93.36) with Microsoft SMTP Server (TLS) id 15.1.26.15; Thu, 27 Nov 2014 09:24:05 +0000 Received: from BY2FFO11FD055.protection.gbl (2a01:111:f400:7c0c::195) by DM2PR03CA0047.outlook.office365.com (2a01:111:e400:2428::46) with Microsoft SMTP Server (TLS) id 15.1.26.15 via Frontend Transport; Thu, 27 Nov 2014 09:24:04 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD055.mail.protection.outlook.com (10.1.15.192) with Microsoft SMTP Server (TLS) id 15.1.6.13 via Frontend Transport; Thu, 27 Nov 2014 09:24:04 +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 sAR9O2hs015935; Thu, 27 Nov 2014 02:24:03 -0700 From: To: Date: Thu, 27 Nov 2014 11:20:16 +0200 Message-ID: <1417080016-13487-1-git-send-email-alexandru.badicioiu@linaro.org> X-Mailer: git-send-email 1.7.3.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 130615538447921537; (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)(199003)(243025005)(189002)(110136001)(104016003)(97736003)(95666004)(104166001)(36756003)(77156002)(62966003)(50226001)(102836001)(15202345003)(33646002)(81156004)(46102003)(106466001)(4396001)(2351001)(107046002)(229853001)(85326001)(47776003)(20776003)(89996001)(88136002)(64706001)(31966008)(50466002)(92566001)(92726001)(87286001)(93916002)(575784001)(86362001)(86152002)(84676001)(48376002)(50986999)(87936001)(21056001)(99396003)(120916001)(15975445006)(68736004)(44976005)(6806004)(69596002)(19580395003)(19580405001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB596; H:az84smr01.freescale.net; FPR:; SPF:PermError; MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB596; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB596; X-Forefront-PRVS: 040866B734 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:(402001)(401002)(400003); SRVR:BY2PR03MB596; X-Topics: crypto patch Subject: [lng-odp] [PATCH v1] 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.215.48 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 --- 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/odp_crypto.c | 2 + 5 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 test/validation/crypto/odp_crypto_test_rng.c create mode 100644 test/validation/crypto/odp_crypto_test_rng.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..3037877 --- /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.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..5719d1f 100644 --- a/test/validation/crypto/test_vectors.h +++ b/test/validation/crypto/test_vectors.h @@ -4,7 +4,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ - +#define TEST_UNUSED __attribute__((unused)) /* TDES-CBC reference vectors, according to * "http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf" */ @@ -13,7 +13,7 @@ #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] = { +static uint8_t tdes_cbc_reference_key[][TDES_CBC_KEY_LEN] TEST_UNUSED = { {0x62, 0x7f, 0x46, 0x0e, 0x08, 0x10, 0x4a, 0x10, 0x43, 0xcd, 0x26, 0x5d, 0x58, 0x40, 0xea, 0xf1, 0x31, 0x3e, 0xdf, 0x97, 0xdf, 0x2a, 0x8a, 0x8c, }, @@ -22,23 +22,25 @@ static uint8_t tdes_cbc_reference_key[][TDES_CBC_KEY_LEN] = { 0x31, 0xcb, 0xb3, 0x85, 0x5e, 0x7f, 0xd3, 0x6d, 0xc8, 0x70, 0xbf, 0xae} }; -static uint8_t tdes_cbc_reference_iv[][TDES_CBC_IV_LEN] = { +static uint8_t tdes_cbc_reference_iv[][TDES_CBC_IV_LEN] TEST_UNUSED = { {0x8e, 0x29, 0xf7, 0x5e, 0xa7, 0x7e, 0x54, 0x75}, {0x3d, 0x1d, 0xe3, 0xcc, 0x13, 0x2e, 0x3b, 0x65} }; /** length in bytes */ -static uint32_t tdes_cbc_reference_length[] = { 8, 16 }; +static uint32_t tdes_cbc_reference_length[] TEST_UNUSED = { 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] TEST_UNUSED = { {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] TEST_UNUSED = { {0xb2, 0x2b, 0x8d, 0x66, 0xde, 0x97, 0x06, 0x92}, {0x7b, 0x1f, 0x7c, 0x7e, 0x3b, 0x1c, 0x94, 0x8e, 0xbd, 0x04, 0xa7, 0x5f, @@ -52,7 +54,7 @@ static uint8_t tdes_cbc_reference_ciphertext[][TDES_CBC_MAX_DATA_LEN] = { #define HMAC_MD5_DIGEST_LEN 16 #define HMAC_MD5_96_CHECK_LEN 12 -static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = { +static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] TEST_UNUSED = { { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b } , @@ -63,9 +65,10 @@ static uint8_t hmac_md5_reference_key[][HMAC_MD5_KEY_LEN] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa } }; -static uint32_t hmac_md5_reference_length[] = { 8, 28, 50 }; +static uint32_t hmac_md5_reference_length[] TEST_UNUSED = { 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] TEST_UNUSED = { /* "Hi There" */ { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65}, @@ -82,7 +85,7 @@ static uint8_t hmac_md5_reference_plaintext[][HMAC_MD5_MAX_DATA_LEN] = { 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd } }; -static uint8_t hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] = { +static uint8_t hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] TEST_UNUSED = { { 0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c, 0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d }, 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, };