Skip to content
Permalink
Browse files
LRNG - add interface for gathering of raw entropy
The test interface allows a privileged process to capture the raw
unconditioned noise that is collected by the LRNG for statistical
analysis. Such testing allows the analysis how much entropy
the interrupt noise source provides on a given platform.
Extracted noise data is not used to seed the LRNG. This
is a test interface and not appropriate for production systems.
Yet, the interface is considered to be sufficiently secured for
production systems.

Access to the data is given through the lrng_raw debugfs file. The
data buffer should be multiples of sizeof(u32) to fill the entire
buffer. Using the option lrng_testing.boot_test=1 the raw noise of
the first 1000 entropy events since boot can be sampled.

This test interface allows generating the data required for
analysis whether the LRNG is in compliance with SP800-90B
sections 3.1.3 and 3.1.4.

In addition, the test interface allows gathering of the conatenated raw
entropy data to verify that the concatenation works appropriately.
This includes sampling of the following raw data:

* high-resolution time stamp

* Jiffies

* IRQ number

* IRQ flags

* return instruction pointer

* array logic batching the high-resolution time stamp

Finally, the execution duration for processing a time stamp can be
obtained with the LRNG raw entropy interface.

If a test interface is not compiled, its code is a noop which has no
impact on the performance.

CC: "Eric W. Biederman" <ebiederm@xmission.com>
CC: "Alexander E. Patrakov" <patrakov@gmail.com>
CC: "Ahmed S. Darwish" <darwish.07@gmail.com>
CC: "Theodore Y. Ts'o" <tytso@mit.edu>
CC: Willy Tarreau <w@1wt.eu>
CC: Matthew Garrett <mjg59@srcf.ucam.org>
CC: Vito Caputo <vcaputo@pengaru.com>
CC: Andreas Dilger <adilger.kernel@dilger.ca>
CC: Jan Kara <jack@suse.cz>
CC: Ray Strode <rstrode@redhat.com>
CC: William Jon McCann <mccann@jhu.edu>
CC: zhangjs <zachary@baishancloud.com>
CC: Andy Lutomirski <luto@kernel.org>
CC: Florian Weimer <fweimer@redhat.com>
CC: Lennart Poettering <mzxreary@0pointer.de>
CC: Nicolai Stange <nstange@suse.de>
Reviewed-by: Roman Drahtmueller <draht@schaltsekun.de>
Tested-by: Roman Drahtmüller <draht@schaltsekun.de>
Tested-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
Tested-by: Neil Horman <nhorman@redhat.com>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
  • Loading branch information
smuellerDD authored and intel-lab-lkp committed Aug 20, 2020
1 parent ca7b52e commit 89b15c614286cea77d633ade2a9045060a492149
Show file tree
Hide file tree
Showing 3 changed files with 700 additions and 0 deletions.
@@ -163,4 +163,128 @@ config LRNG_APT_CUTOFF
default 325 if !LRNG_APT_BROKEN
default 32 if LRNG_APT_BROKEN

menuconfig LRNG_TESTING_MENU
bool "LRNG testing interfaces"
depends on DEBUG_FS
help
Enable one or more of the following test interfaces.

If unsure, say N.

if LRNG_TESTING_MENU

config LRNG_RAW_HIRES_ENTROPY
bool "Enable entropy test interface to hires timer noise source"
default y
help
The test interface allows a privileged process to capture
the raw unconditioned high resolution time stamp noise that
is collected by the LRNG for statistical analysis. Extracted
noise data is not used to seed the LRNG.

The raw noise data can be obtained using the lrng_raw_hires
debugfs file. Using the option lrng_testing.boot_raw_hires_test=1
the raw noise of the first 1000 entropy events since boot
can be sampled.

config LRNG_RAW_JIFFIES_ENTROPY
bool "Enable entropy test interface to Jiffies noise source"
help
The test interface allows a privileged process to capture
the raw unconditioned Jiffies that is collected by
the LRNG for statistical analysis. This data is used for
seeding the LRNG if a high-resolution time stamp is not
available. If a high-resolution time stamp is detected,
the Jiffies value is not collected by the LRNG and no
data is provided via the test interface. Extracted noise
data is not used to seed the random number generator.

The raw noise data can be obtained using the lrng_raw_jiffies
debugfs file. Using the option lrng_testing.boot_raw_jiffies_test=1
the raw noise of the first 1000 entropy events since boot
can be sampled.

config LRNG_RAW_IRQ_ENTROPY
bool "Enable entropy test interface to IRQ number noise source"
help
The test interface allows a privileged process to capture
the raw unconditioned interrupt number that is collected by
the LRNG for statistical analysis. This data is used for
seeding the random32 PRNG external to the LRNG if a
high-resolution time stamp is available or it will be used to
seed the LRNG otherwise. Extracted noise data is not used to
seed the random number generator.

The raw noise data can be obtained using the lrng_raw_irq
debugfs file. Using the option lrng_testing.boot_raw_irq_test=1
the raw noise of the first 1000 entropy events since boot
can be sampled.

config LRNG_RAW_IRQFLAGS_ENTROPY
bool "Enable entropy test interface to IRQ flags noise source"
help
The test interface allows a privileged process to capture
the raw unconditioned interrupt flags that is collected by
the LRNG for statistical analysis. This data is used for
seeding the random32 PRNG external to the LRNG if a
high-resolution time stamp is available or it will be used to
seed the LRNG otherwise. Extracted noise data is not used to
seed the random number generator.

The raw noise data can be obtained using the lrng_raw_irqflags
debugfs file. Using the option lrng_testing.boot_raw_irqflags_test=1
the raw noise of the first 1000 entropy events since boot
can be sampled.

config LRNG_RAW_RETIP_ENTROPY
bool "Enable entropy test interface to RETIP value noise source"
help
The test interface allows a privileged process to capture
the raw unconditioned return instruction pointer value
that is collected by the LRNG for statistical analysis.
This data is used for seeding the random32 PRNG external
to the LRNG if a high-resolution time stamp is available or
it will be used to seed the LRNG otherwise. Extracted noise
data is not used to seed the random number generator.

The raw noise data can be obtained using the lrng_raw_retip
debugfs file. Using the option lrng_testing.boot_raw_retip_test=1
the raw noise of the first 1000 entropy events since boot
can be sampled.

config LRNG_RAW_ARRAY
bool "Enable test interface to LRNG raw entropy storage array"
help
The test interface allows a privileged process to capture
the raw noise data that is collected by the LRNG
in the per-CPU array for statistical analysis. The purpose
of this interface is to verify that the array handling code
truly only concatenates data and provides the same entropy
rate as the raw unconditioned noise source when assessing
the collected data byte-wise.

The data can be obtained using the lrng_raw_array debugfs
file. Using the option lrng_testing.boot_raw_array=1
the raw noise of the first 1000 entropy events since boot
can be sampled.

config LRNG_IRQ_PERF
bool "Enable LRNG interrupt performance monitor"
help
With this option, the performance monitor of the LRNG
interrupt handling code is enabled. The file provides
the execution time of the interrupt handler in
cycles.

The interrupt performance data can be obtained using
the lrng_irq_perf debugfs file. Using the option
lrng_testing.boot_irq_perf=1 the performance data of
the first 1000 entropy events since boot can be sampled.

config LRNG_TESTING
bool
default y if (LRNG_RAW_ENTROPY || LRNG_RAW_ARRAY || LRNG_IRQ_PERF)

endif #LRNG_TESTING_MENU

endif # LRNG
@@ -15,3 +15,4 @@ obj-$(CONFIG_LRNG_DRBG) += lrng_drbg.o
obj-$(CONFIG_LRNG_KCAPI) += lrng_kcapi.o
obj-$(CONFIG_LRNG_JENT) += lrng_jent.o
obj-$(CONFIG_LRNG_HEALTH_TESTS) += lrng_health.o
obj-$(CONFIG_LRNG_TESTING) += lrng_testing.o

0 comments on commit 89b15c6

Please sign in to comment.