Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions wolfcrypt/src/port/ti/ti-aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,17 @@ int wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
aes->left = 0;
XMEMSET(tmp, 0x0, WC_AES_BLOCK_SIZE);
}
else {
/* buffered bytes do not fill a block: encrypt the partial block
* without advancing the counter, emit the new bytes, and keep
* the remaining buffered bytes for the next call */
ret = AesProcess(aes, (byte*)out_block, (byte const *)tmp, WC_AES_BLOCK_SIZE,
AES_CFG_DIR_ENCRYPT, AES_CFG_MODE_CTR_NOCTR);
if (ret != 0)
return ret;
XMEMCPY(out, out_block+aes->left, odd);
aes->left += odd;
}
in += odd;
out+= odd;
sz -= odd;
Expand Down
17 changes: 13 additions & 4 deletions wolfcrypt/src/port/ti/ti-hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,19 @@ static int hashCopy(wolfssl_TI_Hash *src, wolfssl_TI_Hash *dst)
{
if (src == NULL || dst == NULL)
return BAD_FUNC_ARG;
/* only copy hash, zero the rest of the struct to avoid double-free */
dst->msg = NULL;
dst->used = 0;
dst->len = 0;
/* copy the accumulated message into a fresh buffer so each descriptor
* owns its own allocation and can be freed independently */
dst->used = src->used;
dst->len = src->len;
if ((src->msg != NULL) && (src->len > 0)) {
dst->msg = (byte*)XMALLOC(src->len, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (dst->msg == NULL)
return MEMORY_E;
XMEMCPY(dst->msg, src->msg, src->len);
}
else {
dst->msg = NULL;
}
Comment on lines +130 to +142
XMEMCPY(dst->hash, src->hash, sizeof(dst->hash));
return 0;
}
Expand Down
Loading