mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
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:
parent
2878fa3c38
commit
791e223001
1 changed files with 4 additions and 2 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue