On Thu, Dec 8, 2016 at 2:05 AM, Savolainen, Petri (Nokia - FI/Espoo)
<petri.savolai...@nokia-bell-labs.com> wrote:
>>  /**
>> + * Random kind selector
>> + *
>> + * The kind of random denotes the statistical quality of the random data
>> + * returned. Basic random simply appears uniformly distributed,
>> Cryptographic
>> + * random is statistically random and suitable for use by cryptographic
>> + * functions. True random is generated from a hardware entropy source
>> rather
>> + * than an algorithm and is thus completely unpredictable. These form a
>> + * hierarchy where higher quality data is presumably more costly to
>> generate
>> + * than lower quality data.
>> + */
>> +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;
>> +
>> +/**
>> + * Query random max kind
>> + *
>> + * Implementations support the returned max kind and all kinds weaker
>> than it.
>
> I think this is still not explicit enough on the order: which end is "max" on 
> the enumeration. Something like:
>
> "The maximum kind value is ODP_RANDOM_TRUE."
>
> Or in the enum:
>
> /** True random, generated from a HW entropy source. This is the maximum kind 
> value. */
> ODP_RANDOM_TRUE,
>
>
>> + *
>> + * @return kind The maximum odp_random_kind_t supported by this
>> implementation
>> + */
>> +odp_random_kind_t odp_random_max_kind(void);
>> +
>
>> +
>> +/**
>> + * 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-provided seed value is
>> + * updated for each call to continue the sequence. Restarting a series of
>> + * calls with the same initial seed value will generate the same sequence
>> of
>> + * random test data.
>> + *
>> + * This function should be used only for testing purposes. Use
>> + * odp_random_data() for production.
>>   *
>> - * @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
>> + *                     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
>>   */
>> -int32_t odp_random_data(uint8_t *buf, int32_t size, odp_bool_t
>> use_entropy);
>> +int32_t odp_random_repeatable_data(uint8_t *buf, uint32_t len,
>> +                                odp_random_kind_t kind, uint32_t *seed);
>
>
>
> It seems that you missed my proposal for the prototype. See under.
>
> /**
>  * Generate repeatable random data for testing purposes
>  *
>  * For testing purposes it is often useful to generate "random" sequences
>  * that are repeatable...
>  *
>  * This function should be used only for testing purposes, use 
> odp_random_data()
>  * for production.
>  */
> int32_t odp_random_test_data(uint8_t *buf, uint32_t len, odp_random_kind_t 
> kind, uint64_t *seed);
>
>
> It's a function to generate random data for testing purposes. Also note the 
> longer seed, which enables usage of e.g. 48 bit random libraries.
>

v8 submitted with suggested changes except seed is kept as uint32_t
since these alternate rand functions have been deprecated. See
http://stackoverflow.com/questions/25269428/why-are-drand48-and-friends-obsolete
for a discussion.

>
> -Petri
>
>
>
>
>
>
>

Reply via email to