forked from wolfSSL/wolfssl
ARM ASM ChaCha20: Fix calc of left over bytes
This commit is contained in:
@ -2839,10 +2839,10 @@ static void wc_Chacha_encrypt_bytes(ChaCha* ctx, const byte* m, byte* c,
|
||||
}
|
||||
if (bytes > 0) {
|
||||
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]);
|
||||
else
|
||||
ctx->left = CHACHA_CHUNK_BYTES - bytes;
|
||||
ctx->left = CHACHA_CHUNK_BYTES - (bytes & (CHACHA_CHUNK_BYTES - 1));
|
||||
ctx->left &= CHACHA_CHUNK_BYTES - 1;
|
||||
ctx->X[CHACHA_IV_BYTES] = PLUSONE(ctx->X[CHACHA_IV_BYTES]);
|
||||
}
|
||||
}
|
||||
|
@ -4857,7 +4857,7 @@ static int chacha_test(void)
|
||||
}
|
||||
|
||||
/* Streaming test */
|
||||
for (i = 1; i <= (int)CHACHA_CHUNK_BYTES; i++) {
|
||||
for (i = 1; i <= (int)CHACHA_CHUNK_BYTES + 1; i++) {
|
||||
int j, rem;
|
||||
|
||||
ret = wc_Chacha_SetKey(&enc, keys[0], keySz);
|
||||
|
Reference in New Issue
Block a user