crypto/cryptosoft: fix buffer pointer

Fix issue where input buffer pointer was modified during crypto operations.

Ensures original buffer pointer remains valid for the caller.

Signed-off-by: makejian <makejian@xiaomi.com>
This commit is contained in:
makejian 2025-06-09 21:00:05 +08:00 committed by Xiang Xiao
parent 2878fa3c38
commit 791e223001

View file

@ -61,6 +61,7 @@ int swcr_id = -1;
int swcr_encdec(FAR struct cryptop *crp, FAR struct cryptodesc *crd,
FAR struct swcr_data *sw, caddr_t buf)
{
FAR char *output;
unsigned char blk[EALG_MAX_BLOCK_LEN];
FAR unsigned char *iv;
FAR unsigned char *ivp;
@ -117,6 +118,7 @@ int swcr_encdec(FAR struct cryptop *crp, FAR struct cryptodesc *crd,
i = crd->crd_len;
buf = buf + crd->crd_skip;
output = crp->crp_dst;
while (i > 0)
{
bcopy(buf, blk, exf->blocksize);
@ -173,8 +175,8 @@ int swcr_encdec(FAR struct cryptop *crp, FAR struct cryptodesc *crd,
ivp = nivp;
}
bcopy(blk, crp->crp_dst, exf->blocksize);
crp->crp_dst += exf->blocksize;
bcopy(blk, output, exf->blocksize);
output += exf->blocksize;
i -= blks;