From patchwork Thu Nov 3 00:41:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 80566 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp396518qge; Wed, 2 Nov 2016 17:42:15 -0700 (PDT) X-Received: by 10.31.148.22 with SMTP id w22mr4816660vkd.87.1478133735113; Wed, 02 Nov 2016 17:42:15 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n79si1858438vkd.218.2016.11.02.17.42.14; Wed, 02 Nov 2016 17:42:15 -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 628C660F4B; Thu, 3 Nov 2016 00:42:14 +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_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 BA0B860D9D; Thu, 3 Nov 2016 00:42:07 +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 3C52660F0F; Thu, 3 Nov 2016 00:42:05 +0000 (UTC) Received: from mail-oi0-f51.google.com (mail-oi0-f51.google.com [209.85.218.51]) by lists.linaro.org (Postfix) with ESMTPS id D1DCF60D56 for ; Thu, 3 Nov 2016 00:42:03 +0000 (UTC) Received: by mail-oi0-f51.google.com with SMTP id v84so49914277oie.3 for ; Wed, 02 Nov 2016 17:42:03 -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=AWZWr9e9oFxD9lXBf0Euky/VcSEtjl08OjiNaoy/x2k=; b=X5t96uBvhmqWEjkA838w3e0Fx6x20Z/FSx2BwApHeCVL5FaTONin+rR5sE4OncAbR5 ZsBbThEwslMeSc07Zpm5DCHFW0PZ+JknlqtK+7NzKcKk+rfxyFEBkSt1Qq76/6BLke1O QY0rNZOjKCfe6xRZjPtVrlpGngAKqbKTMFDh9RZyzxdkFeI/exxs7M7LQU1jfzB1SJsi XujnynBJwCz6gP4iMAHKyMLKB16hNGtbZbPJGL08mQ1zhlbHDZBQ7/JxSZqF3om+RmdW LiH2oMZ2HAjCLtEaWsc49EhddxCwPuSOCz0cMgbzNgTOsWbYkwOc3WLEdBmrXfUxr79q dUnQ== X-Gm-Message-State: ABUngveiKBgLXKpdL+tpAaosO2xNbd2WNHNzHPJQkb4JdUgjKZ5OL6gy0D5Xe9WfIehjR1jbcK8= X-Received: by 10.157.43.124 with SMTP id f57mr4422391otd.83.1478133723198; Wed, 02 Nov 2016 17:42:03 -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 p82sm1352229oia.25.2016.11.02.17.42.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Nov 2016 17:42:02 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 2 Nov 2016 19:41:53 -0500 Message-Id: <1478133719-10981-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 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 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..62f2376 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); +int odp_random_data(uint8_t *buf, uint32_t len, odp_random_kind_t kind); /** * @}