Skip to content

Commit 20e833d

Browse files
garyrhookherbertx
authored andcommitted
crypto: ccp - memset structure fields to zero before reuse
The AES GCM function reuses an 'op' data structure, which members contain values that must be cleared for each (re)use. This fix resolves a crypto self-test failure: alg: aead: gcm-aes-ccp encryption test failed (wrong result) on test vector 2, cfg="two even aligned splits" Fixes: 36cf515 ("crypto: ccp - Enable support for AES GCM on v5 CCPs") Cc: <[email protected]> Signed-off-by: Gary R Hook <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 95566aa commit 20e833d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/crypto/ccp/ccp-ops.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,
622622

623623
unsigned long long *final;
624624
unsigned int dm_offset;
625+
unsigned int jobid;
625626
unsigned int ilen;
626627
bool in_place = true; /* Default value */
627628
int ret;
@@ -660,9 +661,11 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,
660661
p_tag = scatterwalk_ffwd(sg_tag, p_inp, ilen);
661662
}
662663

664+
jobid = CCP_NEW_JOBID(cmd_q->ccp);
665+
663666
memset(&op, 0, sizeof(op));
664667
op.cmd_q = cmd_q;
665-
op.jobid = CCP_NEW_JOBID(cmd_q->ccp);
668+
op.jobid = jobid;
666669
op.sb_key = cmd_q->sb_key; /* Pre-allocated */
667670
op.sb_ctx = cmd_q->sb_ctx; /* Pre-allocated */
668671
op.init = 1;
@@ -813,6 +816,13 @@ static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q,
813816
final[0] = cpu_to_be64(aes->aad_len * 8);
814817
final[1] = cpu_to_be64(ilen * 8);
815818

819+
memset(&op, 0, sizeof(op));
820+
op.cmd_q = cmd_q;
821+
op.jobid = jobid;
822+
op.sb_key = cmd_q->sb_key; /* Pre-allocated */
823+
op.sb_ctx = cmd_q->sb_ctx; /* Pre-allocated */
824+
op.init = 1;
825+
op.u.aes.type = aes->type;
816826
op.u.aes.mode = CCP_AES_MODE_GHASH;
817827
op.u.aes.action = CCP_AES_GHASHFINAL;
818828
op.src.type = CCP_MEMTYPE_SYSTEM;

0 commit comments

Comments
 (0)