linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] crypto: atmel-aes - Fix saving of IV for CTR mode
@ 2019-12-13 12:38 Dan Carpenter
  2019-12-13 14:45 ` [PATCH] crypto: atmel-aes - Fix CTR counter overflow when multiple fragments Tudor.Ambarus
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2019-12-13 12:38 UTC (permalink / raw)
  To: tudor.ambarus; +Cc: linux-crypto

Hello Tudor Ambarus,

The patch 371731ec2179: "crypto: atmel-aes - Fix saving of IV for CTR
mode" from Dec 5, 2019, leads to the following static checker warning:

	drivers/crypto/atmel-aes.c:1058 atmel_aes_ctr_transfer()
	warn: right shifting more than type allows 16 vs 16

drivers/crypto/atmel-aes.c
  1044          /* Check for transfer completion. */
  1045          ctx->offset += dd->total;
  1046          if (ctx->offset >= req->cryptlen)
  1047                  return atmel_aes_transfer_complete(dd);
  1048  
  1049          /* Compute data length. */
  1050          datalen = req->cryptlen - ctx->offset;
  1051          ctx->blocks = DIV_ROUND_UP(datalen, AES_BLOCK_SIZE);
  1052          ctr = be32_to_cpu(ctx->iv[3]);
  1053  
  1054          /* Check 16bit counter overflow. */
  1055          start = ctr & 0xffff;
  1056          end = start + ctx->blocks - 1;
  1057  
  1058          if (ctx->blocks >> 16 || end < start) {
                    ^^^^^^^^^^^^^^^^^
Impossible condition.

  1059                  ctr |= 0xffff;
  1060                  datalen = AES_BLOCK_SIZE * (0x10000 - start);
  1061                  fragmented = true;
  1062          }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-20  7:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-13 12:38 [bug report] crypto: atmel-aes - Fix saving of IV for CTR mode Dan Carpenter
2019-12-13 14:45 ` [PATCH] crypto: atmel-aes - Fix CTR counter overflow when multiple fragments Tudor.Ambarus
2019-12-20  7:08   ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).