linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* BUG: p8_aes_ctr randomly returns wrong results
@ 2019-03-13 12:37 Ondrej Mosnáček
  2019-03-13 12:48 ` Ondrej Mosnáček
  2019-03-15  1:26 ` Daniel Axtens
  0 siblings, 2 replies; 4+ messages in thread
From: Ondrej Mosnáček @ 2019-03-13 12:37 UTC (permalink / raw)
  To: linux-crypto, Herbert Xu
  Cc: Paulo Flabiano Smorigo, marcelo.cerri, leo.barbosa, linuxppc-dev,
	Stephan Mueller

Hi,

FYI, the p8_aes_ctr crypto driver (drivers/crypto/vmx/aes_ctr.c) seems
to be seriously broken. When I do repeated encryption using libkcapi
multiple times in a row, I sometimes get a wrong result. This happens
more often with long messages (e.g. at 16 KiB it already happens very
frequently).

To reproduce:
1. Install or locally build libkcapi [1] (you will need the kcapi-enc
binary in PATH) on a ppc64le system.
2. Run the following in bash:
for i in {1..100}; do head -c $((16*1024)) /dev/zero | kcapi-enc -e -c
'ctr(aes)' -p test -s test --pbkdfiter 1 2>/dev/null | sha256sum; done
| sort -u

Expected result:
All invocations produce output with identical checksum.

Actual result:
Multiple different checksums are produced.

When I run 'rmmod vmx_crypto' before running the reproducer, I get
only one (correct) checksum, so this is definitely a bug in the
driver. Other ciphers (cbc(aes), xts(aes)) are not affected, even
though the glue code is very similar. That leads me to believe the
problem is somewhere in the assembly code.

[1] http://github.com/smuellerDD/libkcapi

Cheers,
Ondrej

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

end of thread, other threads:[~2019-03-15  1:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13 12:37 BUG: p8_aes_ctr randomly returns wrong results Ondrej Mosnáček
2019-03-13 12:48 ` Ondrej Mosnáček
2019-03-14  0:53   ` Daniel Axtens
2019-03-15  1:26 ` Daniel Axtens

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).