From patchwork Mon Dec 5 01:15:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 86471 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1257944qgi; Sun, 4 Dec 2016 17:15:57 -0800 (PST) X-Received: by 10.237.33.173 with SMTP id l42mr47607258qtc.271.1480900557650; Sun, 04 Dec 2016 17:15:57 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f33si7809089qta.334.2016.12.04.17.15.57; Sun, 04 Dec 2016 17:15:57 -0800 (PST) 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 dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E922A6363E; Mon, 5 Dec 2016 01:15:56 +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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 05FF8635E2; Mon, 5 Dec 2016 01:15:50 +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 C868463608; Mon, 5 Dec 2016 01:15:26 +0000 (UTC) Received: from mail-oi0-f41.google.com (mail-oi0-f41.google.com [209.85.218.41]) by lists.linaro.org (Postfix) with ESMTPS id 31568635E1 for ; Mon, 5 Dec 2016 01:15:25 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id b126so323708125oia.2 for ; Sun, 04 Dec 2016 17:15:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PpOQlW1cD4iuQYzQLt/olUP87H7VH+40xGmhoUPdiyQ=; b=iNjz3DQelhUJGNX3IeVT/Qm72eReFVuyPjE61QEcAFBPMvedBtyQ74l3BdECHvh6Zp eH1aGk5N8Yf2Gy1S390rdMpqgoL+qxfSUwI4gj7hvFxNeNghd+D6egRgtKt3czQLTuB3 rJHNLbdjuHxePaOgCCxjQOQvwPbAx4FynkpHejEl9EXMX82p/DmImo90wdhQyZuGAPq6 5uXELE8TTJBif40/xau6SWceICY1ZwFW5ic9l0q1GY9ZDTq5cnymO5l8ZOi4vGkCJ35h rZDb++0hEelezKxIc282nD5901yJMo/nFsAjWV93E8yyZSCga2O6sigju6g00QZKWdHJ tpwQ== X-Gm-Message-State: AKaTC02Mt6uuaKYE06T73wLW296s43tlYckKUDV1Uc3qd7SS3D9fN9YNcpbBRvy5Vkela74hHi0= X-Received: by 10.157.37.195 with SMTP id q61mr32024814ota.195.1480900524607; Sun, 04 Dec 2016 17:15:24 -0800 (PST) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id t43sm5378971otd.27.2016.12.04.17.15.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Dec 2016 17:15:24 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sun, 4 Dec 2016 19:15:14 -0600 Message-Id: <1480900520-21989-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [lng-odp] [API-NEXT PATCHv5 1/7] api: random: replace use_entropy with odp_rand_kind parameter 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" Address bug https://bugs.linaro.org/show_bug.cgi?id=2557 by replacing the use_entropy parameter with a more comprehensive enum that specifies the kind of random data requested. Signed-off-by: Bill Fischofer --- Changes in v5: - Change return type from int to int32_t for random APIs Changes in v4: - Normalize random API signatures with other ODP APIs - Add new odp_random_seeded_data() API for repeatable random data generation - Add additional tests for new odp_random_seeded_data() API - Break out crypto section of User Guide to its own sub-document - Add User Guide docuemntation for ODP random data API. Changes in v3: - Address commments by Petri - Rename ODP_RAND_NORMAL to ODP_RANDOM_BASIC to avoid confusion with the mathematical term "normal" include/odp/api/spec/random.h | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/include/odp/api/spec/random.h b/include/odp/api/spec/random.h index 00fa15b..e732c3a 100644 --- a/include/odp/api/spec/random.h +++ b/include/odp/api/spec/random.h @@ -24,18 +24,39 @@ extern "C" { */ /** + * Random kind selector + */ +typedef enum { + /** Basic random, presumably pseudo-random generated by SW */ + ODP_RANDOM_BASIC, + /** Cryptographic quality random */ + ODP_RANDOM_CRYPTO, + /** True random, generated from a HW entropy source */ + ODP_RANDOM_TRUE, +} odp_random_kind_t; + +/** * Generate random byte data * - * @param[out] buf Output buffer - * @param size Size of output buffer - * @param use_entropy Use entropy + * The intent in supporting different kinds of random data is to allow + * tradeoffs between performance and the quality of random data needed. The + * assumption is that basic random is cheap while true random is relatively + * expensive in terms of time to generate, with cryptographic random being + * something in between. Implementations that support highly efficient true + * random are free to use this for all requested kinds. So it is always + * permissible to "upgrade" a random data request, but never to "downgrade" + * such requests. * - * @todo Define the implication of the use_entropy parameter + * @param[out] buf Output buffer + * @param len Length of output buffer in bytes + * @param kind Specifies the type of random data required. Request + * is expected to fail if the implementation is unable to + * provide the requested type. * * @return Number of bytes written * @retval <0 on failure */ -int32_t odp_random_data(uint8_t *buf, int32_t size, odp_bool_t use_entropy); +int32_t odp_random_data(uint8_t *buf, uint32_t len, odp_random_kind_t kind); /** * @}