Skip to content

Multiple changes to crypto/ansi_cprng.c

George Spelvin linux-crypto 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest25 patches 27 repliesIn review
  2. v116 of 17 patches 19 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/25crypto: ansi_cprng - unroll _get_more_prng_bytescrypto/ansi_cprng.c+35 -560 replies
2/25crypto: ansi_cprng - Additional _get_more_prng_bytes cleanupcrypto/ansi_cprng.c+3 -80 replies
3/25crypto: ansi_cprng - Use %phN rather than print_hex_dump for debugcrypto/ansi_cprng.c+1 -40 replies
4/25crypto: ansi_cprng - Make debug output more like NIST test vectorscrypto/ansi_cprng.c+12 -130 replies
5/25crypto: ansi_cprng - Eliminate ctx->I and ctx->last_rand_datacrypto/ansi_cprng.c+24 -262 replies
6/25crypto: ansi_cprng - Make cont_test a boolcrypto/ansi_cprng.c+5 -50 replies
7/25crypto: ansi_cprng - Shrink context some morecrypto/ansi_cprng.c+2 -20 replies
8/25crypto: ansi_cprng - Don't call reset_prng_context from cprng_initcrypto/ansi_cprng.c+14 -330 replies
9/25crypto: ansi_cprng - Make length types consistentcrypto/ansi_cprng.c+4 -40 replies
10/25crypto: ansi_cprng - Use u8 data types consistently internallycrypto/ansi_cprng.c+11 -120 replies
11/25crypto: ansi_cprng - Eliminate unused PRNG_FIXED_SIZE flagcrypto/ansi_cprng.c+1 -130 replies
12/25crypto: ansi_cprng - Get rid of rdata buffer in fips_cprng_resetcrypto/ansi_cprng.c+1 -20 replies
13/25crypto: Add appropriate consts to RNG APIcrypto/ansi_cprng.c crypto/krng.c crypto/rng.c +2 more+14 -101 reply
14/25crypto: tcrypt - Add const qualifiers all over the test code.crypto/tcrypt.c crypto/tcrypt.h crypto/testmgr.c +1 more+276 -2680 replies
15/25crypto: testmgr - Merge seed arrays in struct cprng_testveccrypto/testmgr.c crypto/testmgr.h+53 -820 replies
16/25crypto: testmgr - Report failure on zero-length crypto_rng_get_bytescrypto/testmgr.c+2 -00 replies
17/25crypto: testmgr - Don't crash if CPRNG test result is largecrypto/testmgr.c+5 -00 replies
18/25crypto: testmgr - Add CPRNG stutter test.crypto/testmgr.c+89 -90 replies
19/25crypto: ansi_cprng - simplify get_prng_bytescrypto/ansi_cprng.c+25 -490 replies
20/25crypto: ansi_cprng - simplify xor_vectors() to xor_block()crypto/ansi_cprng.c+6 -70 replies
21/25crypto: ansi_cprng - Rename rand_data_valid more sensiblycrypto/ansi_cprng.c+5 -50 replies
22/25crypto: ansi_cprng - Tweak commentscrypto/ansi_cprng.c+11 -60 replies
23/25crypto: ansi_cprng - Introduce a "union cipherblock"crypto/ansi_cprng.c+41 -320 replies
24/25crypto: ansi_cprng - Introduce non-deterministic modecrypto/ansi_cprng.c+40 -120 replies
25/25crypto: ansi_cprng - If non-deterministic, don't buffer old outputcrypto/ansi_cprng.c+7 -55 replies

Reviews trailers per patch

None of the 25 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNeil Horman
SeriesA-b
1/25
2/25
3/25
4/25
5/25
6/25
7/25
8/25
9/25
10/25
11/25
12/25
13/25
14/25
15/25
16/25
17/25
18/25
19/25
20/25
21/25
22/25
23/25
24/25
25/25

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/25] Multiple changes to crypto/ansi_cprng.c

This is a reworked version of my earlier patch series, based on feedback from Neil Horman and Stephan Mueller. Thank you both very much!

It's mostly the same content as before, but I've tried to improve comments and commit messages to address questions, to reorder the patches to put the questionable stuff at the end, and I've also (at Neil's prodding) made some larger scale changes.

I've added appropriate const qualifiers to the RNG API, and also const declarations to all of the self-tests in testmgr.h. (That's a very large but simple patch.)

The significant code improvement is the addition of what I call the "stutter test" to testmgr. This reads from the RNG in irregular chunks and verifies that the output matches that produced by a more regular pattern. This should prevent any recurrence of CVE-2013-4345. (It itself passed an important test by detecting a bug in my code!)

Dropped change:
* Neil said he wanted deterministic to remain the default, so I dropped the patch that changed the default seedsize.

Pending issues:
* Neil would like me to post the results of the NIST and FIPS test vectors. The current code doesn't print anything on a successful test; I need to know what result format is wanted.
* Stephan says he has the FIPS test vectors referred to above and will send them to me when he finds them.
* Is non-deterministic mode (last three patches) wanted?

George Spelvin (25):
crypto: ansi_cprng - unroll _get_more_prng_bytes
crypto: ansi_cprng - Additional _get_more_prng_bytes cleanup
crypto: ansi_cprng - Use %phN rather than print_hex_dump for debug
crypto: ansi_cprng - Make debug output more like NIST test vectors
crypto: ansi_cprng - Eliminate ctx->I and ctx->last_rand_data
crypto: ansi_cprng - Make cont_test a bool
crypto: ansi_cprng - Shrink context some more
crypto: ansi_cprng - Don't call reset_prng_context from cprng_init
crypto: ansi_cprng - Make length types consistent
crypto: ansi_cprng - Use u8 data types consistently internally
crypto: ansi_cprng - Eliminate unused PRNG_FIXED_SIZE flag
crypto: ansi_cprng - Get rid of rdata buffer in fips_cprng_reset
crypto: Add appropriate consts to RNG API
crypto: tcrypt - Add const qualifiers all over the test code.
crypto: testmgr - Merge seed arrays in struct cprng_testvec
crypto: testmgr - Report failure on zero-length crypto_rng_get_bytes
crypto: testmgr - Don't crash if CPRNG test result is large
crypto: testmgr - Add CPRNG stutter test.
crypto: ansi_cprng - simplify get_prng_bytes
crypto: ansi_cprng - simplify xor_vectors() to xor_block()
crypto: ansi_cprng - Rename rand_data_valid more sensibly
crypto: ansi_cprng - Tweak comments
crypto: ansi_cprng - Introduce a "union cipherblock"
crypto: ansi_cprng - Introduce non-deterministic mode
crypto: ansi_cprng - If non-deterministic, don't buffer old output

 crypto/ansi_cprng.c    | 369 ++++++++++++++++--------------------
 crypto/krng.c          |   2 +-
 crypto/rng.c           |   3 +-
 crypto/tcrypt.c        |  46 ++---
 crypto/tcrypt.h        |  30 +--
 crypto/testmgr.c       | 190 +++++++++++++------
 crypto/testmgr.h       | 502 ++++++++++++++++++++++++-------------------------
 include/crypto/rng.h   |   2 +-
 include/linux/crypto.h |   6 +-
 9 files changed, 587 insertions(+), 563 deletions(-)
Signature · 1 line
2.1.3