Your message dated Fri, 24 Jul 2026 17:00:10 +0000
with message-id <[email protected]>
and subject line Bug#847962: fixed in rng-tools 6.17-1
has caused the Debian Bug report #847962,
regarding rng-tools: Patch to fix the broken FIPS 140-2 runs test
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
847962: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=847962
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: rng-tools
Version: 2-unofficial-mt.14-1
Severity: normal
Tags: patch

Hi,

So I recently wrote some code to do the FIPS 140 tests, and though test
suites are good and all that, for something like this I also wanted to
run it against an independent implementation as a cross correlation on
sanity, and found the code in rng-tools which looked like it would be a
good candidate for that ...

Except they disagreed on a small, but large enough to be disturbing,
number of blocks for the Runs and Poker tests.  At first glance we did
appear to be using the same thresholds, so clearly Something Was Wrong.

Happily (for me :), it turns out that my code was correct.
Also happily (for you, I hope ;), I've attached a patch that fixes two
bugs in the Runs test in rng-tools (which broke both tests).

You can pull it from here:
http://anonscm.debian.org/cgit/users/ron/rng-tools.git/commit/?id=27c260ae79e3b02f81062328497648b1e5f46613

And if reportbug --attach actually worked, the git-format-patch export
should be included in this mail.  There's a full description of the
bugs in the commit message of it.

This might be a good one to also push upstream, if they haven't found
and fixed it already.  I've only looked at the code in your fork so far.

  Cheers,
  Ron
>From 27c260ae79e3b02f81062328497648b1e5f46613 Mon Sep 17 00:00:00 2001
From: Ron <[email protected]>
Date: Sat, 24 Jan 2015 19:12:50 +1030
Subject: [PATCH] Fix the broken FIPS 140-2 runs test

There were two (related) bugs in the Runs test that this patch fixes.

The first is it was not handling the special case of ctx->rlength == -1
so if the first bit of a block was not equal to ctx->last_bit (which is
either carried over 'uselessly' from the previous block or set to 0 for
the very first bit of a testing session, but either way is 'random' at
the start of a new block), then it will try to record that event into
ctx->runs[-1 + (6 * ctx->current_bit)].  Which in the 'best' case, will
record it as a run of 0's when it should have been a run of one 1's,
and in the worst case will instead increment ctx->poker[15] (when the
fips_ctx_t struct isn't padded between those two fields).

In any reasonable length run it will hit both cases and break both the
Runs test and the Poker test results.

The second bug is that the same code was wrongly incrementing the count
for ctx->current_bit, when the run it observed is actually instead for
ctx->last_bit.  This wouldn't make a whole lot of difference to the end
result, except for the code outside of that loop which records the
final run of the block (correctly) for ctx->current_bit.  That means
the final run will record 0's or 1's into the opposite set of bins that
the main processing loop does, again (in the worst case) resulting in a
wrong count for some run length of both 0's and 1's, which some portion
of the time will cause a false (positive or negative) Runs test result.

Signed-off-by: Ron <[email protected]>
---
 fips.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fips.c b/fips.c
index a4d5e32..f1c82ca 100644
--- a/fips.c
+++ b/fips.c
@@ -93,11 +93,10 @@ static void fips_test_store(fips_ctx_t *ctx, unsigned int rng_data)
 		if (ctx->current_bit != ctx->last_bit) {
 			/* If runlength is 1-6 count it in correct bucket. 0's go in
 			   runs[0-5] 1's go in runs[6-11] hence the 6*current_bit below */
-			if (ctx->rlength < 5) {
-				ctx->runs[ctx->rlength +
-				     (6 * ctx->current_bit)]++;
-			} else {
-				ctx->runs[5 + (6 * ctx->current_bit)]++;
+			if (ctx->rlength > 4) {
+				ctx->runs[5 + (6 * ctx->last_bit)]++;
+			} else if (ctx->rlength >= 0 ) {
+				ctx->runs[ctx->rlength + (6 * ctx->last_bit)]++;
 			}
 
 			/* Check if we just failed longrun test */
-- 
2.1.1


--- End Message ---
--- Begin Message ---
Source: rng-tools
Source-Version: 6.17-1
Done: Bastian Germann <[email protected]>

We believe that the bug you reported is fixed in the latest version of
rng-tools, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Bastian Germann <[email protected]> (supplier of updated rng-tools package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Tue, 21 Jul 2026 23:03:41 +0200
Source: rng-tools
Binary: rng-tools rng-tools-dbgsym
Architecture: source amd64
Version: 6.17-1
Distribution: experimental
Urgency: medium
Maintainer: Bastian Germann <[email protected]>
Changed-By: Bastian Germann <[email protected]>
Description:
 rng-tools  - Daemon to use a Hardware TRNG
Closes: 847962 922677 970388
Changes:
 rng-tools (6.17-1) experimental; urgency=medium
 .
   * Scan GitHub for new versions (Closes: #970388)
   * Update debhelper-compat to 14
   * Update to latest upstream version, reintroducing the rng-tools source
     package (Closes: #922677, #847962)
Checksums-Sha1:
 b88b8a5df7426e0075b497b07930274d67a684b6 1626 rng-tools_6.17-1.dsc
 48cccc9c79bc168545a526465ea0443081fdf6f4 70000 rng-tools_6.17.orig.tar.gz
 3933a59b2fb213e14d9b5fe99b060db168c5bded 10888 rng-tools_6.17-1.debian.tar.xz
 910778467b3afc9af0f64add5fc67de0344a2a73 133848 
rng-tools-dbgsym_6.17-1_amd64.deb
 a2bc70a0eec8869350faff0139b14b5c465138f8 7729 rng-tools_6.17-1_amd64.buildinfo
 6bef037f3ac30ded6aed330c4460be94f178b921 49004 rng-tools_6.17-1_amd64.deb
Checksums-Sha256:
 592762e1a2be7cd0b221f17ae3ed3a2214ae8da3d81eddd2c35d51ce0f4a3b76 1626 
rng-tools_6.17-1.dsc
 bae3740f3502c01330915aeb22b89441e9d8e14b72448f6a078d365c1c9fda29 70000 
rng-tools_6.17.orig.tar.gz
 0305bde070840848e6936b2c99576fc69e00783c751c5acb159b012bfc754129 10888 
rng-tools_6.17-1.debian.tar.xz
 90abaf324e4b99c344070974f19d92c4a322e8aadfc3ebeba001ccf81e4ba9d4 133848 
rng-tools-dbgsym_6.17-1_amd64.deb
 11fdc76234567996baae50bf4dcdf22682b32406b93cf34b670de67299419993 7729 
rng-tools_6.17-1_amd64.buildinfo
 1abcbd53815426d5235cb90c88e1857d3016f3e1281e710b70a00a63bac07278 49004 
rng-tools_6.17-1_amd64.deb
Files:
 73ce3f6a6552494599eb6e0f69e90a28 1626 utils optional rng-tools_6.17-1.dsc
 54922b431f269daed906ddc42de1a516 70000 utils optional 
rng-tools_6.17.orig.tar.gz
 4920dab48048edd4201fa5f30ed5c1f7 10888 utils optional 
rng-tools_6.17-1.debian.tar.xz
 ec854710c3d4db7f7d849184b117cc72 133848 debug optional 
rng-tools-dbgsym_6.17-1_amd64.deb
 1d57f4702dcfae7f98e76da143e8b860 7729 utils optional 
rng-tools_6.17-1_amd64.buildinfo
 975dab1f40020fc62d2967c948f4d39c 49004 utils optional 
rng-tools_6.17-1_amd64.deb

-----BEGIN PGP SIGNATURE-----

iQHEBAEBCgAuFiEEQGIgyLhVKAI3jM5BH1x6i0VWQxQFAmpf72cQHGJhZ2VAZGVi
aWFuLm9yZwAKCRAfXHqLRVZDFCuvC/sEvdb19c9lMiT+hjrHqEcgx99fpJyz4wUA
m8TzO/dqZwTqA1cH0hsSd8uzNVvC8LximY5pIYQf8rc51WrWTEyNeW3ol3mx42Va
K4N1E5Eof3OuImPGXFsscewFSDq7xtswhn9iDlVAqzeXKlR1/wdMk2JeDxw2+OWf
tw9RhGtILuRJ6Fi6JZ8VYU1QjXnf5XWfPVdmXsKI5i1c7+y0vmWaWkEek1hHPRsV
wH+VtWhAbpmTF20Bes7m2TlIG2AKmmRY2drWI24pBOqQY2Hg3bD3iQjyu2RTpNCk
v7x1RVSQyJ+8XVKsgVk5oZzjaGRs2fTkd+vBObvMtYtTzHkL8UiSE70Pcvh34zMa
yaL6H3FSS/x3Qc+3HNERwmia5hnWHO3g9CriJKJHkWph8z8nSvT/DfA6LTR5Ddkx
wv1aIRx8ukccacZacsOXrj6ziZMTDJahJtJI3GvY8oR3zqflB52PAb8HSaHb2bAV
UF6hBzj18RUp8p4bq2Sam5RTiS7rCkY=
=jT8W
-----END PGP SIGNATURE-----

Attachment: pgpSZ3y3qAVhs.pgp
Description: PGP signature


--- End Message ---

Reply via email to