From patchwork Mon Nov 24 15:04: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: 41407 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AC26323FFA for ; Mon, 24 Nov 2014 15:08:09 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf98148lab.7 for ; Mon, 24 Nov 2014 07:08:08 -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=+WPlcJpK7V3sFzNxYqUiga+E2Qi4zPhAZOt/UgMNJ5g=; b=cHwhAyLkJAICLIO7cQrbYHNgcNr1357+hYvm1U408rSIq0fXnVnKM5MuP5rIfKP1CX GlxdvxiaN1zdOJ0ms5zvtCKLGj/54hd4Rt6e4cjvfwJ9zeRomyhXoPbL1npfaC7MFSb/ e1ZzBcvH417XAUNqOmBln9FIAozmUl3H5d3QDvAeKlpNQbStIMJ6OVmu+YEuqgM0lNSs g/rFWpxFvc5TRE9TUGjkVmMYtGUUyGfIdygg+ri3bK51aloQao646iIPMsjKvxDGx/6x S5zdrtxQGuLRy/R0wnd1zh5vpsDfKDnRKcRKxA+BqmZSixM0ACVHDAlDfOw4/fIE/h3j +TeQ== X-Gm-Message-State: ALoCoQkJ9MN+/+3f6fJaH0JO0kJFZhp9YfejfkmG06q4prPxrj9vcLWjqxpQSLzOTyYMr5xt/ZqO X-Received: by 10.112.142.36 with SMTP id rt4mr6315539lbb.3.1416841688055; Mon, 24 Nov 2014 07:08:08 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.72 with SMTP id y8ls139255lay.99.gmail; Mon, 24 Nov 2014 07:08:07 -0800 (PST) X-Received: by 10.112.234.201 with SMTP id ug9mr21314288lbc.14.1416841687428; Mon, 24 Nov 2014 07:08:07 -0800 (PST) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id tn9si15465159lbb.72.2014.11.24.07.08.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Nov 2014 07:08:07 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by mail-la0-f42.google.com with SMTP id s18so7843467lam.29 for ; Mon, 24 Nov 2014 07:08:07 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr20509268lbr.74.1416841687297; Mon, 24 Nov 2014 07:08:07 -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 ew9csp269565lbc; Mon, 24 Nov 2014 07:08:05 -0800 (PST) X-Received: by 10.224.119.195 with SMTP id a3mr29895877qar.19.1416841685212; Mon, 24 Nov 2014 07:08:05 -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 i34si15865129qgf.90.2014.11.24.07.08.03 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 24 Nov 2014 07:08:05 -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 1XsvFC-0003qk-4S; Mon, 24 Nov 2014 15:08:02 +0000 Received: from mail-bn1bn0100.outbound.protection.outlook.com ([157.56.110.100] helo=na01-bn1-obe.outbound.protection.outlook.com) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XsvF5-0003qf-VO for lng-odp@lists.linaro.org; Mon, 24 Nov 2014 15:07:56 +0000 Received: from DM2PR03CA0009.namprd03.prod.outlook.com (10.141.96.19) by BL2PR03MB1011.namprd03.prod.outlook.com (10.141.182.149) with Microsoft SMTP Server (TLS) id 15.1.11.14; Mon, 24 Nov 2014 15:07:48 +0000 Received: from BY2FFO11FD035.protection.gbl (2a01:111:f400:7c0c::165) by DM2PR03CA0009.outlook.office365.com (2a01:111:e400:2428::19) with Microsoft SMTP Server (TLS) id 15.1.26.15 via Frontend Transport; Mon, 24 Nov 2014 15:07:48 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD035.mail.protection.outlook.com (10.1.14.220) with Microsoft SMTP Server (TLS) id 15.1.6.13 via Frontend Transport; Mon, 24 Nov 2014 15:07:47 +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 sAOF7jjv001659; Mon, 24 Nov 2014 08:07:46 -0700 From: To: Date: Mon, 24 Nov 2014 17:04:16 +0200 Message-ID: <1416841456-28291-1-git-send-email-alexandru.badicioiu@linaro.org> X-Mailer: git-send-email 1.7.3.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 130613152677910183; (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)(189002)(19580395003)(102836001)(50986999)(99396003)(97736003)(86362001)(89996001)(48376002)(62966003)(69596002)(92726001)(575784001)(87936001)(20776003)(87286001)(110136001)(93916002)(68736004)(21056001)(229853001)(104166001)(84676001)(6806004)(81156004)(4396001)(31966008)(50226001)(36756003)(2351001)(47776003)(106466001)(50466002)(92566001)(95666004)(86152002)(64706001)(46102003)(104016003)(85326001)(120916001)(77156002)(33646002)(88136002)(44976005)(19580405001)(107046002); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR03MB1011; H:az84smr01.freescale.net; FPR:; 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:BL2PR03MB1011; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:; SRVR:BL2PR03MB1011; X-Forefront-PRVS: 040513D301 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:BL2PR03MB1011; X-Topics: crypto patch Subject: [lng-odp] [PATCH v0] 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.42 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 | 31 ++++++++++++++++++++++++++ test/validation/crypto/odp_crypto_test_rng.h | 18 +++++++++++++++ test/validation/crypto/test_vectors.h | 21 ++++++++++------- test/validation/odp_crypto.c | 2 + 5 files changed, 64 insertions(+), 9 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..2e25027 --- /dev/null +++ b/test/validation/crypto/odp_crypto_test_rng.c @@ -0,0 +1,31 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include +#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..438761d --- /dev/null +++ b/test/validation/crypto/odp_crypto_test_rng.h @@ -0,0 +1,18 @@ +/* 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 */ +CU_TestInfo test_rng[1]; + +#endif + diff --git a/test/validation/crypto/test_vectors.h b/test/validation/crypto/test_vectors.h index c151952..aaf0103 100644 --- a/test/validation/crypto/test_vectors.h +++ b/test/validation/crypto/test_vectors.h @@ -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] ODP_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] ODP_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[] ODP_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] ODP_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] ODP_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] ODP_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[] ODP_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] ODP_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] ODP_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 985302a..6b53952 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) @@ -19,6 +20,7 @@ CU_SuiteInfo suites[] = { { ODP_CRYPTO_SYNC_INP , NULL, NULL, NULL, NULL, test_array_sync }, { ODP_CRYPTO_ASYNC_INP , NULL, NULL, NULL, NULL, test_array_async }, + { ODP_CRYPTO_RNG, NULL, NULL, NULL, NULL, test_rng }, CU_SUITE_INFO_NULL, };