ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] rngd vs haveged vs crng
@ 2019-04-25 10:29 Konstantin Lepikhov
  2019-04-25 19:17 ` Andrey Savchenko
  2019-05-22 23:08 ` Alexey Shabalin
  0 siblings, 2 replies; 81+ messages in thread
From: Konstantin Lepikhov @ 2019-04-25 10:29 UTC (permalink / raw)
  To: ALT Linux Devel Mailing List

Привет!

В продолжение обсуждения у кого энтропия длиннее^W лучше я тут провел
несколько тестов. Идея - замерить как быстро будет заканчиваться энтропия
в случае использования haveged/rngd/ничего (ядра).

В качесте теста был выбран rngtest из пакета rng-tools. rngtest позволяет
проверить качество энтропии из /dev/random по стандарту FIPS 140-2 и
замерить скорость чтения данных.

Кол-во запусков rngtest - 5 (выбрано просто так, чтобы быстрее).
Ядро: 5.0.0-lks-wks-alt0.3

1. запускаем rngtest без всего (rngd/haveged сервисы выключены). В этом
случае ядро будет само наполнять /dev/random.

$ rngtest -c 1000 </dev/random
...
rngtest: input channel speed: (min=1.721; avg=2.008; max=2.143)Mibits/s
rngtest: FIPS tests speed: (min=49.413; avg=60.802; max=151.377)Mibits/s
rngtest: Program run time: 9815390 microseconds

2. Запускаем тесты с rngd:

$ ll /dev/hwrng 
crw------- 1 root root 10, 183 23 apr 11:01 /dev/hwrng

$ egrep "^HRNGD" /etc/sysconfig/rngd
HRNGDEVICE=/dev/hwrng

$ cat /proc/cpuinfo
...
model name      : AMD FX(tm)-6300 Six-Core Processor
...
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt
pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid
aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 popcnt aes
xsave avx f16c lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a
misalignsse 3dnowprefetch osvw ibs xop skinit wdt lwp fma4 tce nodeid_msr
tbm topoext perfctr_core perfctr_nb cpb hw_pstate ssbd ibpb vmmcall bmi1
arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid
decodeassists pausefilter pfthreshold
bugs            : fxsave_leak sysret_ss_attrs null_seg spectre_v1
spectre_v2 spec_store_bypass

$ rngtest -c 1000 </dev/random
...
rngtest: input channel speed: (min=1.488; avg=5.397; max=18.217)Mibits/s
rngtest: FIPS tests speed: (min=40.324; avg=138.440; max=152.588)Mibits/s
rngtest: Program run time: 3673417 microseconds

run time отличается между тестами +- 0.5s.

3. Запускаем тесты с haveged:

$ service rngd stop && service haveged start
$ rngtest -c 1000 </dev/random
...
rngtest: input channel speed: (min=2.047; avg=17.271; max=21.076)Mibits/s
rngtest: FIPS tests speed: (min=20.465; avg=141.851; max=153.818)Mibits/s
rngtest: Program run time: 1239069 microseconds

run time отличается между тестами +- 0.5s.

Еще более интересные результаты на моем ноуте, который с Intel CPU и TPM:

1. Запускаем без всего, используем только ядро:

for i in $(seq 1 5); do rngtest -c 1000 </dev/random; done
rngtest 6.7
Copyright (c) 2004 by Henrique de Moraes Holschuh
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

rngtest: starting FIPS tests...
^Crngtest: bits received from input: 3720
rngtest: FIPS 140-2 successes: 0
rngtest: FIPS 140-2 failures: 0
rngtest: FIPS 140-2(2001-10-10) Monobit: 0
rngtest: FIPS 140-2(2001-10-10) Poker: 0
rngtest: FIPS 140-2(2001-10-10) Runs: 0
rngtest: FIPS 140-2(2001-10-10) Long run: 0
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=0.000; avg=0.000; max=0.000)bits/s
rngtest: FIPS tests speed: (min=0.000; avg=0.000; max=0.000)bits/s
rngtest: Program run time: 317191113 microseconds
....
(тут я не дождался и прервал тест). Видно, что ядро ничего может
сгенерить за приемлемое время.

2. Запускаем с rngd:

$ ll /dev/hwrng 
crw------- 1 root root 10, 183 23 apr 11:01 /dev/hwrng

$ egrep "^HRNGD" /etc/sysconfig/rngd
HRNGDEVICE=/dev/hwrng

$ cat /proc/cpuinfo
...
model name	: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
...
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca
cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx
pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl
xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64
monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1
sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand
lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs
ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase
tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt
intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp
hwp_notify hwp_act_window hwp_epp flush_l1d
bugs		: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
l1tf

$ dmesg|fgrep tpm
[    9.695064] tpm_tis MSFT0101:00: 2.0 TPM (device-id 0xFE, rev-id 4)

$ for i in $(seq 1 5); do rngtest -c 1000 </dev/random; done
rngtest 6.7
Copyright (c) 2004 by Henrique de Moraes Holschuh
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

rngtest: starting FIPS tests...
^Crngtest: bits received from input: 4997088
rngtest: FIPS 140-2 successes: 249
rngtest: FIPS 140-2 failures: 0
rngtest: FIPS 140-2(2001-10-10) Monobit: 0
rngtest: FIPS 140-2(2001-10-10) Poker: 0
rngtest: FIPS 140-2(2001-10-10) Runs: 0
rngtest: FIPS 140-2(2001-10-10) Long run: 0
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=24.220; avg=31.911; max=51.710)Kibits/s
rngtest: FIPS tests speed: (min=26.128; avg=54.413; max=181.652)Mibits/s
rngtest: Program run time: 152957345 microseconds
(тут я опять прервал тест). Уже получше, но все равно скорость не очень
приемлема для реальных условий.

3. Запускаем с haveged:

$ for i in $(seq 1 5); do rngtest -c 1000 </dev/random; done
...
rngtest 6.7
Copyright (c) 2004 by Henrique de Moraes Holschuh
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

rngtest: starting FIPS tests...
rngtest: bits received from input: 20000032
rngtest: FIPS 140-2 successes: 1000
rngtest: FIPS 140-2 failures: 0
rngtest: FIPS 140-2(2001-10-10) Monobit: 0
rngtest: FIPS 140-2(2001-10-10) Poker: 0
rngtest: FIPS 140-2(2001-10-10) Runs: 0
rngtest: FIPS 140-2(2001-10-10) Long run: 0
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=2.810; avg=20.824; max=23.635)Mibits/s
rngtest: FIPS tests speed: (min=14.983; avg=176.216; max=188.846)Mibits/s
rngtest: Program run time: 1024351 microseconds

среднее отклонение run time +- 10000ms

В общем, выводы можно сделать.

-- 
WBR et al.


^ permalink raw reply	[flat|nested] 81+ messages in thread

end of thread, other threads:[~2019-09-21  0:33 UTC | newest]

Thread overview: 81+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-25 10:29 [devel] rngd vs haveged vs crng Konstantin Lepikhov
2019-04-25 19:17 ` Andrey Savchenko
2019-04-25 19:21   ` Denis Medvedev
2019-04-25 19:26     ` Michael Shigorin
2019-04-26  0:01       ` Leonid Krivoshein
2019-04-26  0:19         ` Leonid Krivoshein
2019-04-26  4:43         ` Anton Farygin
2019-04-26  0:51         ` Leonid Krivoshein
2019-04-26 12:45       ` Mikhail Efremov
2019-04-26 22:46       ` Alexey V. Vissarionov
2019-04-27  4:17         ` Denis Medvedev
2019-04-27  5:37           ` Ivan A. Melnikov
2019-05-22 23:08 ` Alexey Shabalin
2019-05-23  4:37   ` Anton Farygin
2019-05-27 11:59   ` Michael Shigorin
2019-05-27 14:18     ` Anton Farygin
2019-05-28  0:08       ` Leonid Krivoshein
2019-05-27 23:53     ` Leonid Krivoshein
2019-05-28  5:08       ` Anton Farygin
2019-05-28  8:57       ` Alexey V. Vissarionov
2019-05-28 10:51         ` Anton Farygin
2019-05-29  8:44           ` Anton Gorlov
2019-05-29  8:46           ` Anton Gorlov
2019-05-29 10:52             ` Anton Farygin
2019-05-30  1:11               ` [devel] rngd vs haveged vs crng (khwrngd) Vitaly Chikunov
2019-05-30  4:39                 ` Anton Farygin
2019-05-30  5:16                   ` Anton Farygin
2019-05-30 16:40                     ` Alexey V. Vissarionov
2019-05-30 16:51                       ` Anton Farygin
2019-05-30 17:20                         ` Alexey V. Vissarionov
2019-05-31 10:51                         ` Andrey Savchenko
2019-05-31  6:50                       ` Anton Farygin
2019-05-31 10:56                         ` Alexey V. Vissarionov
2019-05-31 16:58                           ` Anton Farygin
2019-08-30 23:06                             ` Alexey Shabalin
2019-08-31  6:36                               ` Leonid Krivoshein
2019-08-31 12:35                                 ` Alexey V. Vissarionov
2019-08-31 14:47                                   ` Leonid Krivoshein
2019-08-31 15:42                                     ` Alexey V. Vissarionov
2019-09-02 21:31                                       ` Leonid Krivoshein
2019-09-02 22:25                                         ` Paul Wolneykien
2019-09-03  5:58                                           ` Alexey V. Vissarionov
2019-09-03  6:02                                             ` Anton Farygin
2019-09-03  8:49                                               ` Paul Wolneykien
2019-09-03 19:52                                                 ` Leonid Krivoshein
2019-09-03 20:01                                                   ` Andrey Savchenko
2019-09-03 20:56                                                     ` Leonid Krivoshein
2019-09-04  2:22                                                       ` Alexey V. Vissarionov
2019-09-03 23:31                                                   ` Paul Wolneykien
2019-09-03  8:49                                             ` Paul Wolneykien
2019-09-03  9:54                                               ` Alexey V. Vissarionov
2019-09-03 10:01                                                 ` Paul Wolneykien
2019-09-03 10:29                                                   ` Alexey V. Vissarionov
2019-09-03 10:35                                                     ` Paul Wolneykien
2019-09-03 10:38                                                       ` Alexey V. Vissarionov
2019-09-03 10:46                                                         ` Michael Shigorin
2019-09-03  7:02                                           ` Leonid Krivoshein
2019-09-03  8:49                                             ` Paul Wolneykien
2019-09-03 19:46                                               ` Leonid Krivoshein
2019-09-03 23:33                                                 ` Paul Wolneykien
2019-09-04  3:36                                                   ` Leonid Krivoshein
2019-09-20 10:47                                               ` Sergey Bolshakov
2019-09-20 12:23                                                 ` Alexey V. Vissarionov
2019-09-21  0:33                                                     ` Leonid Krivoshein
2019-09-03  7:28                                           ` Aleksei Nikiforov
2019-09-03  8:25                                             ` Alexey V. Vissarionov
2019-09-02 23:59                                         ` Alexey V. Vissarionov
2019-09-03  7:37                                           ` Leonid Krivoshein
2019-09-03 10:12                                             ` Alexey V. Vissarionov
2019-09-03 20:51                                               ` Leonid Krivoshein
2019-08-31  7:30                               ` Anton Farygin
2019-05-31 14:12               ` [devel] rngd vs haveged vs crng Anton Gorlov
2019-05-31 14:12               ` Anton Gorlov
2019-05-30 17:54           ` Alexey V. Vissarionov
2019-05-31  5:08             ` Anton Farygin
2019-05-31 11:01               ` Alexey V. Vissarionov
2019-05-31 17:01                 ` Anton Farygin
2019-05-28  0:53   ` Leonid Krivoshein
2019-09-17 20:08     ` Nikolai Kostrigin
2019-09-17 21:51       ` Alexey V. Vissarionov
2019-09-17 23:29         ` Leonid Krivoshein

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git