Merge pull request #3354 from SparkiDev/mac_arm_asm_2

ARM ASM ChaCha20: Fix calc of left over bytes
pull/3373/head
toddouska 2020-10-08 14:49:33 -07:00 committed by GitHub
commit c69e9927fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -2839,10 +2839,10 @@ static void wc_Chacha_encrypt_bytes(ChaCha* ctx, const byte* m, byte* c,
} }
if (bytes > 0) { if (bytes > 0) {
wc_Chacha_encrypt_64(ctx->X, m, c, bytes, (byte*)ctx->over); wc_Chacha_encrypt_64(ctx->X, m, c, bytes, (byte*)ctx->over);
if (bytes > 64) if (bytes > CHACHA_CHUNK_BYTES)
ctx->X[CHACHA_IV_BYTES] = PLUSONE(ctx->X[CHACHA_IV_BYTES]); ctx->X[CHACHA_IV_BYTES] = PLUSONE(ctx->X[CHACHA_IV_BYTES]);
else ctx->left = CHACHA_CHUNK_BYTES - (bytes & (CHACHA_CHUNK_BYTES - 1));
ctx->left = CHACHA_CHUNK_BYTES - bytes; ctx->left &= CHACHA_CHUNK_BYTES - 1;
ctx->X[CHACHA_IV_BYTES] = PLUSONE(ctx->X[CHACHA_IV_BYTES]); ctx->X[CHACHA_IV_BYTES] = PLUSONE(ctx->X[CHACHA_IV_BYTES]);
} }
} }

View File

@ -4857,7 +4857,7 @@ static int chacha_test(void)
} }
/* Streaming test */ /* Streaming test */
for (i = 1; i <= (int)CHACHA_CHUNK_BYTES; i++) { for (i = 1; i <= (int)CHACHA_CHUNK_BYTES + 1; i++) {
int j, rem; int j, rem;
ret = wc_Chacha_SetKey(&enc, keys[0], keySz); ret = wc_Chacha_SetKey(&enc, keys[0], keySz);