symm/cbc-def.h: Fix discarding output for short inputs.
[catacomb] / symm / chacha.c
index 3419861..a554c19 100644 (file)
@@ -72,6 +72,7 @@ static void simple_core(unsigned r, const chacha_matrix src,
 
 #if CPUFAM_X86 || CPUFAM_AMD64
 extern core__functype chacha_core_x86ish_sse2;
+extern core__functype chacha_core_x86ish_avx;
 #endif
 
 #if CPUFAM_ARMEL
@@ -85,6 +86,8 @@ extern core__functype chacha_core_arm64;
 static core__functype *pick_core(void)
 {
 #if CPUFAM_X86 || CPUFAM_AMD64
+  DISPATCH_PICK_COND(chacha_core, chacha_core_x86ish_avx,
+                    cpu_feature_p(CPUFEAT_X86_AVX));
   DISPATCH_PICK_COND(chacha_core, chacha_core_x86ish_sse2,
                     cpu_feature_p(CPUFEAT_X86_SSE2));
 #endif
@@ -221,7 +224,7 @@ void chacha_seek(chacha_ctx *ctx, unsigned long i)
 void chacha_seeku64(chacha_ctx *ctx, kludge64 i)
 {
   ctx->a[12] = LO64(i); ctx->a[13] = HI64(i);
-  ctx->bufi = CHACHA_OUTSZ;
+  ctx->off = CHACHA_OUTSZ;
 }
 
 void chacha_seek_ietf(chacha_ctx *ctx, uint32 i)