X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/6a0eb24483f0e24865f9c93bb1690cdf3f54ead4..141c12847a1c2f8cc8db03d420551584e689fb87:/symm/salsa20.c diff --git a/symm/salsa20.c b/symm/salsa20.c index a055f3b1..7806e6ca 100644 --- a/symm/salsa20.c +++ b/symm/salsa20.c @@ -97,7 +97,8 @@ static core__functype *pick_core(void) cpu_feature_p(CPUFEAT_ARM_NEON)); #endif #if CPUFAM_ARM64 - DISPATCH_PICK_COND(salsa20_core, salsa20_core_arm64, 1); + DISPATCH_PICK_COND(salsa20_core, salsa20_core_arm64, + cpu_feature_p(CPUFEAT_ARM_NEON)); #endif DISPATCH_PICK_FALLBACK(salsa20_core, simple_core); } @@ -162,6 +163,8 @@ static void populate(salsa20_matrix a, const void *key, size_t ksz) /*----- Salsa20 implementation --------------------------------------------*/ +static const octet zerononce[XSALSA20_NONCESZ]; + /* --- @salsa20_init@ --- * * * Arguments: @salsa20_ctx *ctx@ = context to fill in @@ -177,8 +180,6 @@ static void populate(salsa20_matrix a, const void *key, size_t ksz) void salsa20_init(salsa20_ctx *ctx, const void *key, size_t ksz, const void *nonce) { - static const octet zerononce[SALSA20_NONCESZ]; - populate(ctx->a, key, ksz); salsa20_setnonce(ctx, nonce ? nonce : zerononce); } @@ -423,8 +424,6 @@ SALSA20_VARS(DEFHSALSA20) void XSALSA20_INIT(r, XSALSA20_CTX(r) *ctx, \ const void *key, size_t ksz, const void *nonce) \ { \ - static const octet zerononce[XSALSA20_NONCESZ]; \ - \ populate(ctx->k, key, ksz); \ ctx->s.a[ 0] = SALSA20_A256; \ ctx->s.a[ 1] = SALSA20_B256; \ @@ -872,6 +871,7 @@ SALSA20_VARS(DEFXGRAND) #include #include +#include #include #include @@ -901,7 +901,7 @@ static const int perm[] = { } \ for (i = 0; i < SALSA20_OUTSZ/4; i++) STORE32_L(d.buf + 4*i, b[i]); \ \ - if (d.len != v[2].len || memcmp(d.buf, v[2].buf, v[2].len) != 0) { \ + if (d.len != v[2].len || MEMCMP(d.buf, !=, v[2].buf, v[2].len)) { \ ok = 0; \ printf("\nfail core:" \ "\n\titerations = %d" \ @@ -971,7 +971,7 @@ SALSA20_VARS(DEFVCORE) } \ if (sz) BASE##_ENCRYPT(r, &ctx, p, q, sz); \ \ - if (d.len != v[5].len || memcmp(d.buf, v[5].buf, v[5].len) != 0) { \ + if (d.len != v[5].len || MEMCMP(d.buf, !=, v[5].buf, v[5].len)) { \ ok = 0; \ printf("\nfail encrypt:" \ "\n\tstep = %lu" \