Skip to content

Commit e469102

Browse files
committed
Make FIPS test less shaky
Signed-off-by: Matthias Büchse <[email protected]>
1 parent 2e182fb commit e469102

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Standards/scs-0101-w1-entropy-implementation-testing.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ reported as an error:
3636
- the service `rngd` is not running,
3737
- the special file `/proc/sys/kernel/random/entropy_avail` does not contain
3838
the value 256 (pinned since kernel 5.18),
39-
- the number of FIPS 140-2 failures exceeds 3 out of 1000 blocks
39+
- the number of FIPS 140-2 failures exceeds 5 out of 1000 blocks
4040
tested, as determined by `cat /dev/random | rngtest -c 1000` .
4141

4242
Note: The latter two items act as surrogates for the following item, which
@@ -50,6 +50,8 @@ The following items MUST be detected and reported as a warning:
5050

5151
- any flavor missing the attribute `hw_rng:allowed=True`,
5252
- any image missing the attribute `hw_rng_model: virtio`,
53+
- the number of FIPS 140-2 failures exceeds 3 out of 1000 blocks
54+
tested (compare with errors).
5355

5456
Note that the requirement regarding the kernel patch level will not be
5557
checked, because of two reasons: (a) we already check the file `entropy_avail`

Tests/iaas/entropy/entropy-check.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,16 @@ def check_fips_test(lines, image_name):
145145
if failure_re:
146146
fips_failures = failure_re.string[failure_re.regs[0][0]:failure_re.regs[0][1]].split(" ")[1]
147147
if int(fips_failures) <= 3:
148-
return True # this is the single 'successful' code path
148+
return True # strict test passed
149+
logger.warning(
150+
f"VM '{image_name}' didn't pass the strict FIPS 140-2 testing. "
151+
f"Expected a maximum of 3 failures, got {fips_failures}."
152+
)
153+
if int(fips_failures) <= 5:
154+
return True # lenient test passed
149155
logger.error(
150156
f"VM '{image_name}' didn't pass the FIPS 140-2 testing. "
151-
f"Expected a maximum of 3 failures, got {fips_failures}."
157+
f"Expected a maximum of 5 failures, got {fips_failures}."
152158
)
153159
else:
154160
logger.error(f"VM '{image_name}': failed to determine fips failures")

0 commit comments

Comments
 (0)