diff --git a/,gitignore b/,gitignore deleted file mode 100644 index 6b29aac..0000000 --- a/,gitignore +++ /dev/null @@ -1,2 +0,0 @@ -__PYCACHE__ -.* diff --git a/src/cha4block.h b/src/cha4block.h index 9500f72..a82d001 100644 --- a/src/cha4block.h +++ b/src/cha4block.h @@ -1,3 +1,10 @@ +#if defined(__x86_64__) +#include // AVX2 +#include // SSSE3 +#elif defined(__aarch64__) +#include "sse2neon.h" +#endif + #define VEC4_ROT(A, IMM) \ _mm_or_si128(_mm_slli_epi32(A, IMM), _mm_srli_epi32(A, (32 - IMM))) diff --git a/src/cha8block.h b/src/cha8block.h index 0991163..f493a5e 100644 --- a/src/cha8block.h +++ b/src/cha8block.h @@ -1,3 +1,6 @@ +#include // AVX2 +#include // SSSE3 + #define VEC8_ROT(A, IMM) \ _mm256_or_si256(_mm256_slli_epi32(A, IMM), _mm256_srli_epi32(A, (32 - IMM))) diff --git a/src/chacha20.h b/src/chacha20.h index 91be67f..2f84dd0 100644 --- a/src/chacha20.h +++ b/src/chacha20.h @@ -1,7 +1,7 @@ #include #include -static const uint64_t CHA_BLOCK_SIZE = 64; +#define CHA_BLOCK_SIZE 64 typedef struct cha_ctx { uint32_t state[16]; @@ -15,20 +15,11 @@ typedef struct cha_ctx { #pragma GCC target("ssse3") #pragma GCC target("avx2") #endif - -#include // SSE2 -#include "cha4block.h" - -#include // AVX2 -#include // SSSE3 #include "cha8block.h" - -#elif defined(__aarch64__) -#include "sse2neon.h" -#include "cha4block.h" #endif #include "cha1block.h" +#include "cha4block.h" #include #include @@ -40,7 +31,6 @@ typedef struct cha_ctx { #include #include - /// @brief Initialize cha_ctx /// @param ctx holds ChaCha20 state /// @param key 32 byte key @@ -79,7 +69,8 @@ void cha_update(cha_ctx* ctx, uint8_t* out, uint64_t outlen) { if (ctx->uncount) { memmove(ctx->unconsumed, ctx->unconsumed + N, ctx->uncount); } - if (c == out + outlen) return; + if (c == out + outlen) + return; } #if defined(__x86_64__) // TODO: Handle resume if we are not at block boundary