Skip to content

Commit 1825bd8

Browse files
authored
Merge pull request #9550 from JacobBarthelmeh/caam
sanity checks on buffer size with AES and CAAM Integrity use
2 parents d26c11c + e93835a commit 1825bd8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

wolfcrypt/src/port/caam/caam_integrity.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,9 @@ static Error caamAes(struct DescStruct* desc)
759759
ctx[ctxIdx] = buf;
760760
sz += buf->dataSz;
761761

762+
if (ctx[ctxIdx]->dataSz + offset > (MAX_CTX * sizeof(UINT4))) {
763+
return SizeIsTooLarge;
764+
}
762765
memcpy((unsigned char*)&local[offset],
763766
(unsigned char*)ctx[ctxIdx]->data, ctx[ctxIdx]->dataSz);
764767
offset += ctx[ctxIdx]->dataSz;
@@ -958,6 +961,9 @@ static Error caamAead(struct DescStruct* desc)
958961
ctx[ctxIdx] = buf;
959962
sz += buf->dataSz;
960963

964+
if (ctx[ctxIdx]->dataSz + offset > (MAX_CTX * sizeof(UINT4))) {
965+
return SizeIsTooLarge;
966+
}
961967
memcpy((unsigned char*)&local[offset],
962968
(unsigned char*)ctx[ctxIdx]->data, ctx[ctxIdx]->dataSz);
963969
offset += ctx[ctxIdx]->dataSz;

0 commit comments

Comments
 (0)