From patchwork Thu Nov 3 00:41:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 80567 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp396631qge; Wed, 2 Nov 2016 17:42:41 -0700 (PDT) X-Received: by 10.31.197.194 with SMTP id v185mr5342147vkf.84.1478133761769; Wed, 02 Nov 2016 17:42:41 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h37si1870893uah.128.2016.11.02.17.42.41; Wed, 02 Nov 2016 17:42:41 -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 6C30660EFB; Thu, 3 Nov 2016 00:42:41 +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 1783A60F1C; Thu, 3 Nov 2016 00:42:09 +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 3DA9360EFB; Thu, 3 Nov 2016 00:42:06 +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 AF2CB60D9D for ; Thu, 3 Nov 2016 00:42:04 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id 62so50072555oif.1 for ; Wed, 02 Nov 2016 17:42:04 -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:in-reply-to :references; bh=4JR+0AhbwV1mSY+qowNq1LcI7yI9yLd8TNfTfoQFen4=; b=G3YCIfVrh1txSscjQ/5PYFTHtW8tlH+CNadV8ixWSIEgUqUd2ZpyQQj/yqv6xgKcSj 8/bE4kt7r98v4vAqiMusztRmE0CF2PsCm3MtjACGGvzA1jK8rcx+rGGr2g2Es1sNH6cu hBPM40wNVP2kI36kGFWd2BnogCwH0xVv/zUcNXYd2YU7nwsxPsLuZXhmJtLEMCy28MCa wMugNLNzfiSyCdhrb5n7lLORrHC2+6VutUSMCT67rF4sMPWAbRAH4D3eL9S6OCAQH7QJ HVO9UERpxzWTdONASOZrH3QpoUjf+9dzYxf6pg8//smkPtOv53JMU6fLpgmSMs5Z8FvN 4m8A== X-Gm-Message-State: ABUngvdeBIVvWdE5uFRGifUHZmkvpNwPcEjFsN72/bTD8dQne514CZTKkuL1DS6ec0H2k9w2G0c= X-Received: by 10.157.8.67 with SMTP id 61mr3911223oty.231.1478133724109; Wed, 02 Nov 2016 17:42:04 -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.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Nov 2016 17:42:03 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 2 Nov 2016 19:41:54 -0500 Message-Id: <1478133719-10981-2-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478133719-10981-1-git-send-email-bill.fischofer@linaro.org> References: <1478133719-10981-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 2/7] api: random: add ability to generate repeatable random data 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" Add the new API odp_random_seeded_data() to allow generation of repeatable deterministic random data from a user-specified seed value that is updated by each call. Sequences of calls using the same initial seed value will generate the same pseudo-random sequence. The caller may specify the kind of data that is to be generated however the only required kind that need be supported is ODP_RANDOM_BASIC. Attempts to generate repeatable ODP_RANDOM_TRUE are contradictory and should be failed. Signed-off-by: Bill Fischofer --- include/odp/api/spec/random.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 2.7.4 diff --git a/include/odp/api/spec/random.h b/include/odp/api/spec/random.h index 62f2376..69d35c8 100644 --- a/include/odp/api/spec/random.h +++ b/include/odp/api/spec/random.h @@ -59,6 +59,28 @@ typedef enum { int odp_random_data(uint8_t *buf, uint32_t len, odp_random_kind_t kind); /** + * Generate repeatable random byte data + * + * For testing purposes it is often useful to generate "random" sequences + * that are repeatable. This is accomplished by supplying a seed value that + * is used for pseudo-random data generation. The caller provides + * + * @param[out] buf Output buffer + * @param len Length of output buffer in bytes + * @param kind Specifies the type of random data required. Request + * will fail if the implementation is unable to provide + * repeatable random of the requested type. This is + * always true for true random and may be true for + * cryptographic random. + * @param[in,out] seed Seed value to use + * + * @return Number of bytes written + * @retval <0 on failure + */ +int odp_random_seeded_data(uint8_t *buf, uint32_t len, + odp_random_kind_t kind, uint32_t *seed); + +/** * @} */