Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: qce - Hold back a block of data to be transferred as part of final

If the available data to transfer is exactly a multiple of block size, save
the last block to be transferred in qce_ahash_final (with the last block
bit set) if this is indeed the end of data stream. If not this saved block
will be transferred as part of next update. If this block is not held back
and if this is indeed the end of data stream, the digest obtained will be
wrong since qce_ahash_final will see that rctx->buflen is 0 and return
doing nothing which in turn means that a digest will not be copied to the
destination result buffer. qce_ahash_final cannot be made to alter this
behavior and allowed to proceed if rctx->buflen is 0 because the crypto
engine BAM does not allow for zero length transfers.

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Thara Gopinath and committed by
Herbert Xu
38de3cf2 a01dc5c1

+19
+19
drivers/crypto/qce/sha.c
··· 216 216 217 217 /* calculate how many bytes will be hashed later */ 218 218 hash_later = total % blocksize; 219 + 220 + /* 221 + * At this point, there is more than one block size of data. If 222 + * the available data to transfer is exactly a multiple of block 223 + * size, save the last block to be transferred in qce_ahash_final 224 + * (with the last block bit set) if this is indeed the end of data 225 + * stream. If not this saved block will be transferred as part of 226 + * next update. If this block is not held back and if this is 227 + * indeed the end of data stream, the digest obtained will be wrong 228 + * since qce_ahash_final will see that rctx->buflen is 0 and return 229 + * doing nothing which in turn means that a digest will not be 230 + * copied to the destination result buffer. qce_ahash_final cannot 231 + * be made to alter this behavior and allowed to proceed if 232 + * rctx->buflen is 0 because the crypto engine BAM does not allow 233 + * for zero length transfers. 234 + */ 235 + if (!hash_later) 236 + hash_later = blocksize; 237 + 219 238 if (hash_later) { 220 239 unsigned int src_offset = req->nbytes - hash_later; 221 240 scatterwalk_map_and_copy(rctx->buf, req->src, src_offset,