From patchwork Tue Oct 25 22:03:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 79287 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp99112qge; Tue, 25 Oct 2016 15:03:49 -0700 (PDT) X-Received: by 10.200.39.140 with SMTP id w12mr20485082qtw.28.1477433029826; Tue, 25 Oct 2016 15:03:49 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b124si14673159qke.101.2016.10.25.15.03.49; Tue, 25 Oct 2016 15:03:49 -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 6F3A860F3F; Tue, 25 Oct 2016 22:03:49 +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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2 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 7F00C60885; Tue, 25 Oct 2016 22:03:21 +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 74E2360821; Tue, 25 Oct 2016 22:03:17 +0000 (UTC) Received: from mail-oi0-f47.google.com (mail-oi0-f47.google.com [209.85.218.47]) by lists.linaro.org (Postfix) with ESMTPS id B54A5607BE for ; Tue, 25 Oct 2016 22:03:14 +0000 (UTC) Received: by mail-oi0-f47.google.com with SMTP id i127so67803334oia.2 for ; Tue, 25 Oct 2016 15:03:14 -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=SCxPkXwe8GXKOY9zaWYel2txIG/mrHoFuDayhzFZm8c=; b=cycVHiMDF6hxd1WURTTzcDCt9EybkVN7m0Xm2xHtbZrIYiHmqgdyZC8AgT4V38SWym GEmVFZ+RgIKIhucZ7WcWJRmPjDnmsfEFULs6grXr95L+HFTz73nRdo0t+RTQpQYTb57Q PhqH3OOH+3xBcaiUCQwTcoymF1b7VgZstPpUsxf22iS426ltIac6nlV7xSROd5JpfZNM gm3TgMNSG9O6ao+YUCyIzwmg4MB+7cJVnMT02e/SPorU5Cb+lM5M1Dgz3IB2cbob4BSc xgSe5p5QGSDEQ8t6H7xQILSRfClTV4lRJtIBL2CPc0uAGd1WRHoj9Vuj7YVgQh+zDDcd dF+Q== X-Gm-Message-State: ABUngvcW7jaW6xfryzQ9632Rzb7/RADoxiBELRwvyD10OBQwyOUkt34VYtIjys3DRVqxTn9RqEQ= X-Received: by 10.157.16.120 with SMTP id o53mr4270453oto.11.1477432994113; Tue, 25 Oct 2016 15:03:14 -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 s23sm7363519ots.1.2016.10.25.15.03.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Oct 2016 15:03:13 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 25 Oct 2016 17:03:09 -0500 Message-Id: <1477432992-21770-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 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 --- 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..97df4bc 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 { + /** Normal random, presumably pseudo-random generated by SW */ + ODP_RAND_NORMAL, + /** Cryptographic quality random */ + ODP_RAND_CRYPTO, + /** True random, generated from a HW entropy source */ + ODP_RAND_TRUE, +} odp_rand_kind_t; + +/** * Generate random byte data * * @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 + * + * @note The indent in supporting different kinds of random data is to allow + * tradeoffs between performance and the quality of random data needed. The + * assumption is that normal 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. */ -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_rand_kind_t kind); /** * @}