openssl: Enable os option for with-rand-seed as well
PATCH 1/1 openssl: Enable os option for with-rand-seed as well
with openSSL 1.1.1d we start seeing errors like
Error Generating Key
139979727451584:error:2406C06E:random number generator:RAND_DRBG_instantiate:error retrieving entropy:../openssl-1.1.1d/crypto/rand/drbg_lib.c:342:
when using openssl from openssl-native on build hosts, this is due to limiting the random seed to devrandom, to support older hosts, since the option allows to have a comma separated list of methods to try, we can try the default first and if that fails then fallback to devrandom, this will ensure that it keeps working with build systems which dont support getrandom()
--- meta/recipes-connectivity/openssl/openssl_1.1.1d.bb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
meta/recipes-connectivity/openssl/openssl_1.1.1d.bb +3 -3
@@ -43,10 +43,10 @@ do_configure[cleandirs] = "${B}" EXTRA_OECONF_append_libc-musl = " no-async" EXTRA_OECONF_append_libc-musl_powerpc64 = " no-asm" -# This prevents openssl from using getrandom() which is not available on older glibc versions +# adding devrandom prevents openssl from using getrandom() which is not available on older glibc versions # (native versions can be built with newer glibc, but then relocated onto a system with older glibc) -EXTRA_OECONF_class-native = "--with-rand-seed=devrandom" -EXTRA_OECONF_class-nativesdk = "--with-rand-seed=devrandom" +EXTRA_OECONF_class-native = "--with-rand-seed=os,devrandom" +EXTRA_OECONF_class-nativesdk = "--with-rand-seed=os,devrandom" # Relying on hardcoded built-in paths causes openssl-native to not be relocateable from sstate. CFLAGS_append_class-native = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"
Signature · 1 line
2.23.0
Quoted 5 lines · Khem Raj
with openSSL 1.1.1d we start seeing errors like
Error Generating Key
139979727451584:error:2406C06E:random number generator:RAND_DRBG_instantiate:error retrieving entropy:../openssl-1.1.1d/crypto/rand/drbg_lib.c:342:
Quoted 7 lines
when using openssl from openssl-native on build hosts, this is due to limiting the random seed to devrandom, to support older hosts, since the option allows to have a comma separated list of methods to try, we can try the default first and if that fails then fallback to devrandom, this will ensure that it keeps working with build systems which dont support
getrandom()
...
Thanks for fixing this problem!
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedThanks for fix, I was seeing these issues in couple components using nodejs-native (example bellow) and can confirm that this is now fixed.
internal/crypto/random.js:118
if (ex) throw ex;
^Error: error:2406C06E:random number generator:RAND_DRBG_instantiate:error
retrieving entropy
at handleError (internal/crypto/random.js:117:14)
at Object.randomBytes (internal/crypto/random.js:52:19)
at
TOPDIR/BUILD/work/x86_64-linux/node-gyp-native/0.12.2+gitAUTOINC+7e98c99ce7-r4/recipe-sysroot-native/usr/lib/node_modules/npm/lib/npm.js:424:32
at Object.<anonymous>
(TOPDIR/BUILD/work/x86_64-linux/node-gyp-native/0.12.2+gitAUTOINC+7e98c99ce7-r4/recipe-sysroot-native/usr/lib/node_modules/npm/lib/npm.js:476:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
Quoted 54 lines · Khem Raj
with openSSL 1.1.1d we start seeing errors like
Error Generating Key 139979727451584:error:2406C06E:random number generator:RAND_DRBG_instantiate:error retrieving entropy:../openssl-1.1.1d/crypto/rand/drbg_lib.c:342:
when using openssl from openssl-native on build hosts, this is due to limiting the random seed to devrandom, to support older hosts, since the option allows to have a comma separated list of methods to try, we can try the default first and if that fails then fallback to devrandom, this will ensure that it keeps working with build systems which dont support
getrandom()Signed-off-by Khem Raj <[email protected]>Cc Adrian Bunk <[email protected]>Cc Alexander Kanavin <[email protected]>--- meta/recipes-connectivity/openssl/openssl_1.1.1d.bb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)meta/recipes-connectivity/openssl/openssl_1.1.1d.bb +0
-1@@ -43,10 +43,10 @@ do_configure[cleandirs] = "${B}" EXTRA_OECONF_append_libc-musl = " no-async" EXTRA_OECONF_append_libc-musl_powerpc64 = " no-asm" -# This prevents openssl from using getrandom() which is not available onolder glibc versions
+# adding devrandom prevents openssl from usinggetrandom()which is not available on older glibc versions
# (native versions can be built with newer glibc, but then relocated onto
a system with older glibc)meta/recipes-connectivity/openssl/openssl_1.1.1d.bb +2
-2-EXTRA_OECONF_class-native = "--with-rand-seed=devrandom" -EXTRA_OECONF_class-nativesdk = "--with-rand-seed=devrandom" +EXTRA_OECONF_class-native = "--with-rand-seed=os,devrandom" +EXTRA_OECONF_class-nativesdk = "--with-rand-seed=os,devrandom" # Relying on hardcoded built-in paths causes openssl-native to not berelocateable from sstate.
CFLAGS_append_class-native = " -DOPENSSLDIR=/not/builtin
-DENGINESDIR=/not/builtin"
--
2.23.0--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Hello Raj,
Quoted 13 lines · Khem Raj
with openSSL 1.1.1d we start seeing errors like
Error Generating Key
139979727451584:error:2406C06E:random number generator:RAND_DRBG_instantiate:error retrieving entropy:../openssl-1.1.1d/crypto/rand/drbg_lib.c:342:when using openssl from openssl-native on build hosts, this is due to limiting the random seed to devrandom, to support older hosts, since the option allows to have a comma separated list of methods to try, we can try the default first and if that fails then fallback to devrandom, this will ensure that it keeps working with build systems which dont support
getrandom()
Quoted 4 lines
Signed-off-by Khem Raj <[email protected]>Cc Adrian Bunk <[email protected]>Cc Alexander Kanavin <[email protected]>---
Just as a test report for this patch:
I've tested this patch on the HW (i.MX8M Mini EVK) and unfortunately my sshd given up with a message: PRNG is not seeded
Reverting commits (effectively rolling back to openssl 1.1.1c) made sshd operable again.:53b5654d6e openssl: Enable os option for with-rand-seed as well 2c6b9b918c openssl: Upgrade 1.1.1c -> 1.1.1d
I'm not sure whether this is related to the Kernel used in i.MX8M Mini series or the openssl version used...
I'd try to use a different HW to verify this patch further (perhaps Altera CV) to see if the sshd is broken there as well.
-- andrey
Quoted 23 lines · Andrey Zhizhikin
Hello Raj,
Quoted 13 lines · Khem Raj
with openSSL 1.1.1d we start seeing errors like
Error Generating Key
139979727451584:error:2406C06E:random number generator:RAND_DRBG_instantiate:error retrieving entropy:../openssl-1.1.1d/crypto/rand/drbg_lib.c:342:when using openssl from openssl-native on build hosts, this is due to limiting the random seed to devrandom, to support older hosts, since the option allows to have a comma separated list of methods to try, we can try the default first and if that fails then fallback to devrandom, this will ensure that it keeps working with build systems which dont support
getrandom()Quoted 4 lines
Signed-off-by Khem Raj <[email protected]>Cc Adrian Bunk <[email protected]>Cc Alexander Kanavin <[email protected]>---
Just as a test report for this patch:
Quoted 7 lines
I've tested this patch on the HW (i.MX8M Mini EVK) and unfortunately my sshd given up with a message: PRNG is not seeded
Reverting commits (effectively rolling back to openssl 1.1.1c) made sshd operable again.:
53b5654d6eopenssl: Enable os option for with-rand-seed as well2c6b9b918copenssl: Upgrade 1.1.1c -> 1.1.1d
Do you have rng-tools on the image? That helped me with the kernel random pool initialization for sshd in iMX8 and openssl 1.1.1x.
I don't see how 53b5654d6e could change this behavior for target openssl. 2c6b9b918c could change the behavior and would be suprise. Maybe also target recipe needs --with-rand-seed=os,devrandom on iMX8 or similar platforms.
-Mikko
Quoted 32 lines · On Fri, Sep 20, 2019 at 01:38:29PM +0000, [email protected] wrote:
Quoted 23 lines · Andrey Zhizhikin
Hello Raj,
Quoted 13 lines · Khem Raj
with openSSL 1.1.1d we start seeing errors like
Error Generating Key
139979727451584:error:2406C06E:random number generator:RAND_DRBG_instantiate:error retrieving entropy:../openssl-1.1.1d/crypto/rand/drbg_lib.c:342:when using openssl from openssl-native on build hosts, this is due to limiting the random seed to devrandom, to support older hosts, since the option allows to have a comma separated list of methods to try, we can try the default first and if that fails then fallback to devrandom, this will ensure that it keeps working with build systems which dont support
getrandom()Quoted 4 lines
Signed-off-by Khem Raj <[email protected]>Cc Adrian Bunk <[email protected]>Cc Alexander Kanavin <[email protected]>---
Just as a test report for this patch:
Quoted 7 lines
I've tested this patch on the HW (i.MX8M Mini EVK) and unfortunately my sshd given up with a message: PRNG is not seeded
Reverting commits (effectively rolling back to openssl 1.1.1c) made sshd operable again.:
53b5654d6eopenssl: Enable os option for with-rand-seed as well2c6b9b918copenssl: Upgrade 1.1.1c -> 1.1.1d
Quoted 6 lines
Do you have rng-tools on the image? That helped me with the kernel random pool initialization for sshd in iMX8 and openssl 1.1.1x.
I don't see how
53b5654d6ecould change this behavior for target openssl.2c6b9b918ccould change the behavior and would be suprise.
...
OpenSSL is full of surprises...
CHANGES says:
Linux kernels 4.8 and later, don't have a reliable way to detect that /dev/urandom has been properly seeded, so a failure is raised for this case (i.e. the getentropy(2) call has already failed).
It seems to be correct to give an error here, and lack of rng-tools and/or kernel support for the iMX8 RNG is something that should be fixed by the user.
OTOH, this kind of changes make it hard to justify upgrading openssl in stable branches.
Quoted 1 line
-Mikko
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 4 lines · On Fri, Sep 20, 2019 at 3:38 PM <[email protected]> wrote:
Do you have rng-tools on the image? That helped me with the kernel random pool initialization for sshd in iMX8 and openssl 1.1.1x.
No, but I would definitely try it! Thanks a lot for the tip here!
Quoted 4 lines
I don't see how
53b5654d6ecould change this behavior for target openssl.2c6b9b918ccould change the behavior and would be suprise. Maybe also target recipe needs --with-rand-seed=os,devrandom on iMX8 or similar platforms.
This has puzzled me as well.. Actually, the 53b5654d6e is related to 2c6b9b918c in a way that it fixes the build issue with various components. That was the reason I reverted both of them since they are going in pair. Strangely enough, when reverting the openssl version to 1.1.1c - sshd starts to work normally.
I'm building now Arria10 to see if I can reproduce the issue there as well.
-- andrey
Quoted 1 line
...
Just as a follow-up on this issue, if someone else would stumbled upon the same:
I've built cyclone5 machine off the master and it was 100% operable. Then I looked at the i.MX8M configuration and found out that openssl recipe was overlaid for me with the option --with-rand-seed=devrandom, which effectively cause this erratic behavior. Changing the compile option to --with-rand-seed=os,devrandom made an SSHD fully operable again, so indeed this is the right option to use for devices which are not properly seeding /dev/urandom.
Mikko/Adrian, thank a lot for your advises here in the direction to look into!
-- andrey