From cdb0ce047d5c1f05836526cbdb52998c13c627e5 Mon Sep 17 00:00:00 2001 From: Michael Hamburg Date: Sun, 28 May 2017 12:29:43 -0700 Subject: [PATCH] avoid warning for uninitialized entropy; change asm cpuid to look more like cpuid.h in the vain hope that this will compile better --- src/spongerng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spongerng.c b/src/spongerng.c index d604b1c..fbcef7c 100644 --- a/src/spongerng.c +++ b/src/spongerng.c @@ -30,7 +30,7 @@ static void get_cpu_entropy(uint8_t *entropy, size_t len) { static char tested = 0, have_rdrand = 0; if (!tested) { uint32_t a,b,c,d; - a=1; __asm__("cpuid" : "+a"(a), "=b"(b), "=c"(c), "=d"(d)); + __asm__("cpuid" : "=a"(a), "=b"(b), "=c"(c), "=d"(d) : "0"(1)); have_rdrand = (c>>30)&1; tested = 1; } @@ -80,7 +80,7 @@ void decaf_spongerng_next ( ) { if (prng->sponge->params->remaining) { /* nondet */ - uint8_t cpu_entropy[32]; + uint8_t cpu_entropy[32] = {0}; get_cpu_entropy(cpu_entropy, sizeof(cpu_entropy)); decaf_spongerng_stir(prng,cpu_entropy,sizeof(cpu_entropy)); decaf_bzero(cpu_entropy,sizeof(cpu_entropy));