X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/78b4ea88288a9f1e26fefa060c409d4888938536..HEAD:/symm/sha3.c diff --git a/symm/sha3.c b/symm/sha3.c index 97b41e3c..36bd430b 100644 --- a/symm/sha3.c +++ b/symm/sha3.c @@ -231,7 +231,7 @@ static void leftenc_sz(shake_ctx *ctx, size_t n) octet b[9]; unsigned i; - SET64(t, ((n&~MASK32) >> 16) >> 16, n&MASK32); + SET64(t, ((n&~(size_t)MASK32) >> 16) >> 16, n&MASK32); STORE64_B_(b + 1, t); for (i = 1; i < 8 && !b[i]; i++); i--; b[i] = 8 - i; @@ -244,7 +244,7 @@ static void rightenc_sz(shake_ctx *ctx, size_t n) octet b[9]; unsigned i; - SET64(t, ((n&~MASK32) >> 16) >> 16, n&MASK32); + SET64(t, ((n&~(size_t)MASK32) >> 16) >> 16, n&MASK32); STORE64_B_(b, t); for (i = 0; i < 7 && !b[i]; i++); b[8] = 8 - i; @@ -563,7 +563,7 @@ static gcipher *shake128_gcinit(const void *k, size_t sz) static gcipher *shake256_gcinit(const void *k, size_t sz) { shake_gcctx *cc = S_CREATE(shake_gcctx); - cc->gc.ops = &shake128_gcops; + cc->gc.ops = &shake256_gcops; shake256_init(&cc->c); shake_hash(&cc->c, k, sz); shake_xof(&cc->c); return (&cc->gc); } @@ -957,6 +957,7 @@ grand *kmac256_rand(const void *perso, size_t psz, const void *k, size_t sz) #include +#include #include #include @@ -979,7 +980,7 @@ static int vrf_sha3_mct(void (*initfn)(sha3_ctx *), sha3_done(&ctx, d.buf); } - if (memcmp(d.buf, out->buf, out->len) != 0) { + if (MEMCMP(d.buf, !=, out->buf, out->len)) { ok = 0; printf("\nfail\n\tsteps = %d\n\tinput = ", n); type_hex.dump(in, stdout); @@ -1037,7 +1038,7 @@ static int vrf_shaky(void (*initfn)(shake_ctx *, p += i; sz -= i; } - if (memcmp(d.buf, want->buf, want->len) != 0) { + if (MEMCMP(d.buf, !=, want->buf, want->len)) { ok = 0; printf("\nfail (get):\n\tstep = %i\n\tinput = ", *ip); type_hex.dump(m, stdout); @@ -1071,7 +1072,7 @@ static int vrf_shaky(void (*initfn)(shake_ctx *, p += i; sz -= i; } - if (memcmp(d.buf, want->buf, want->len) != 0) { + if (MEMCMP(d.buf, !=, want->buf, want->len)) { ok = 0; printf("\nfail (mask):\n\tstep = %i\n\tinput = ", *ip); type_hex.dump(m, stdout); @@ -1131,7 +1132,7 @@ static int vrf_kmac(void (*initfn)(kmac_ctx *, const void *, size_t, if (tsz) kmac_done(&ctx, d.buf, tsz); else { kmac_xof(&ctx); kmac_get(&ctx, d.buf, d.len); } - if (memcmp(d.buf, want->buf, want->len) != 0) { + if (MEMCMP(d.buf, !=, want->buf, want->len)) { ok = 0; printf("\nfail"); printf("\n\tperso = `%s'", perso->buf);