From patchwork Wed Oct 26 16:39:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 79461 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp160043qge; Wed, 26 Oct 2016 09:40:56 -0700 (PDT) X-Received: by 10.107.164.209 with SMTP id d78mr3383103ioj.182.1477500056138; Wed, 26 Oct 2016 09:40:56 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x74si3272281ita.72.2016.10.26.09.40.55; Wed, 26 Oct 2016 09:40:56 -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 dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 951DA61843; Wed, 26 Oct 2016 16:40:55 +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 DE9FC61892; Wed, 26 Oct 2016 16:39:41 +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 BDCD460CB6; Wed, 26 Oct 2016 16:39:33 +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 9F85060CAA for ; Wed, 26 Oct 2016 16:39:29 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id y2so154442342oie.0 for ; Wed, 26 Oct 2016 09:39:29 -0700 (PDT) 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=LASrwAqwXSzS/gAwqfZ4JuEgkK6Ukz+VAnW0TpyYuJw=; b=ZyJ1iRRFmr7xwPl1v5GyET3odCrC0dCbUpdACxzeDvVB+8MjcpF+gVxiXjJH7AY8MD fyYnnO0wySgUUzLBHFkSzp79yJXfLrjHMVN++sXQuUs7kSJRpS3pWvU2N8Xuzftcw1lm /iXY6v2Ej1/ASMMjtrHSjTR+Kl3N4dkua4LP8+1ZbZkj40/vKIusdhAvNAKlI2NR1lPH EukvbCtJ649LFblgOLf5kalhk5/sepCk3NkSMEbRVd+ebeD7+0V6TXqslijNHZrcStvF qFrpzhRxSq3ZBaqMTgWzwQccj0vm6T8qSYEc8iFWflzY/zIOfdXVvHR6NwQyu7I0GF1z 5dmg== X-Gm-Message-State: ABUngvcepV69rl7MIblEQumicdGKZkWTvs5VtcEybHf0mTbY2aN51kEKA0YDQkmdoXcZ9+3Z25M= X-Received: by 10.202.4.17 with SMTP id 17mr2200430oie.91.1477499969074; Wed, 26 Oct 2016 09:39:29 -0700 (PDT) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id f68sm844369otb.36.2016.10.26.09.39.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Oct 2016 09:39:28 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 26 Oct 2016 11:39:23 -0500 Message-Id: <1477499966-30632-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv3 1/4] 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 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 | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/include/odp/api/spec/random.h b/include/odp/api/spec/random.h index 00fa15b..723630e 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 * + * 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. + * * @param[out] buf Output buffer * @param size Size of output buffer - * @param use_entropy Use entropy - * - * @todo Define the implication of the use_entropy parameter + * @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, int32_t size, odp_random_kind_t kind); /** * @}