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

Corinna Vinschen vinschen@redhat.com
Fri Mar 18 16:50:00 GMT 2016


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.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20160318/f61ddcd0/attachment.sig>


More information about the Newlib mailing list