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 - simplify qce_xts_swapiv()

Declare 'swap' as zero-initialized and use a single index variable to
simplify the byte-swapping loop in qce_xts_swapiv(). Add a comment for
clarity.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Thorsten Blum and committed by
Herbert Xu
3787fb76 1ee57ab9

+6 -6
+6 -6
drivers/crypto/qce/common.c
··· 280 280 #ifdef CONFIG_CRYPTO_DEV_QCE_SKCIPHER 281 281 static void qce_xts_swapiv(__be32 *dst, const u8 *src, unsigned int ivsize) 282 282 { 283 - u8 swap[QCE_AES_IV_LENGTH]; 284 - u32 i, j; 283 + u8 swap[QCE_AES_IV_LENGTH] = {0}; 284 + unsigned int i, offset; 285 285 286 286 if (ivsize > QCE_AES_IV_LENGTH) 287 287 return; 288 288 289 - memset(swap, 0, QCE_AES_IV_LENGTH); 289 + offset = QCE_AES_IV_LENGTH - ivsize; 290 290 291 - for (i = (QCE_AES_IV_LENGTH - ivsize), j = ivsize - 1; 292 - i < QCE_AES_IV_LENGTH; i++, j--) 293 - swap[i] = src[j]; 291 + /* Reverse and right-align IV bytes. */ 292 + for (i = 0; i < ivsize; i++) 293 + swap[offset + i] = src[ivsize - 1 - i]; 294 294 295 295 qce_cpu_to_be32p_array(dst, swap, QCE_AES_IV_LENGTH); 296 296 }