Page MenuHomeFreeBSD

random(4): Add regression tests for uint128 implementation, Chacha CTR

Authored by cem on May 24 2019, 12:11 AM.



Add some basic regression tests to verify behavior of both uint128
implementations at typical boundary conditions, to run on all architectures.

Test uint128 increment behavior of Chacha in keystream mode, as used by
'kern.random.use_chacha20_cipher=1' to verify assumptions. These
assumptions are critical to the safety of using Chacha as a PRF in Fortuna
(as implemented), but do not impact arc4random at all.

Test Plan

Tests pass on amd64, and I'm looking for volunteers or cluster resources to
validate !x86 archs, especially big endian.

Tests pass on ref12-ppc64 as well.

Diff Detail

rS FreeBSD src repository - subversion
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Add missing mtree declaration.

Fix hash.c build on ppc64

unit_test.h has some x86-specific constructs, and we only need kassert/ctassert
for hash.c.

Rebase onto SVN head

  • keystream API takes blocks, not bytes still
  • Drop uint128_add64 API tests, which does not exist

I would like to commit these tests, which cover the existing r344913, as soon
as possible. The other tests will be moved to associated commits.

@delphij , this one technically touches sys/dev/random (fix a declaration name typo but mostly add #ifndef _KERNEL compatibility shims), so I need secteam blessing to commit. I'd appreciate a look when you get a chance.

gordon added a subscriber: gordon.

This looks straightforward. Approved.

This revision is now accepted and ready to land.Jun 17 2019, 12:11 PM