[PATCH 5/5] Add arc4random() etc. from OpenBSD 5.8

Howland, Craig D howland@LGSInnovations.com
Fri Mar 18 18:18:00 GMT 2016


On 03/18/2016 12:50 PM, Corinna Vinschen wrote:
> On Mar 18 12:39, Craig Howland wrote:
>> On 03/18/2016 06:49 AM, Sebastian Huber wrote:
>>> ...
>>> diff --git a/newlib/libc/stdlib/chacha_private.h b/newlib/libc/stdlib/chacha_private.h
>>> new file mode 100644
>>> index 0000000..b48c981
>>> --- /dev/null
>>> +++ b/newlib/libc/stdlib/chacha_private.h
>>> @@ -0,0 +1,224 @@
>>> +/*
>>> +...
>>> +#include <stdint.h>
>>> +
>>> +typedef uint8_t u8;
>>> +typedef uint32_t u32;
>>> +
>>> +typedef struct
>>> +{
>>> +  u32 input[16]; /* could be compressed */
>>> +} chacha_ctx;
>>> +
>>> +#define U8C(v) (v##U)
>>> +#define U32C(v) (v##U)
>> Not good, as may or may not match what is defined in stdint.h, and can be
>> inaccurate, for example if long is needed for 32 bits. However, they are
>> only used in the 2 lines below, so just get rid of these two defines.
>> (Realistically, I would expect it to still provide the correct results, but
>> it is definitely an error in usage.)
>>
>>> +
>>> +#define U8V(v) ((u8)(v) & U8C(0xFF))
>>> +#define U32V(v) ((u32)(v) & U32C(0xFFFFFFFF))
>>>
>> #define U8V(v) ((u8)(v) & UINT8_C(0xFF))
>> #define U32V(v) ((u32)(v) & UINT32_C(0xFFFFFFFF))
>> (For that matter, the '& mask' is not needed, as the cast does it.)
> Pleae send a patch.
	* libc/stdlib/chacha_private.h (u32v(), u8v()):  remove un-necessary
	and with mask (which also removes non-standard integer-constant macros).

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: chacha_private.h.patch.txt
URL: <http://sourceware.org/pipermail/newlib/attachments/20160318/e99347c3/attachment.txt>


More information about the Newlib mailing list