aboutsummaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorEric van Gyzen <vangyzen@FreeBSD.org>2020-12-11 14:32:42 +0000
committerEric van Gyzen <vangyzen@FreeBSD.org>2020-12-11 14:32:42 +0000
commit4617b1f62b3b05364bd9fc4b501df8d504c18fac (patch)
tree21ded7874104c9f60a96a6424013ddf11e1c6dc9 /sbin
parent580a173a05bdb83632c7330d940c91e0526ed0e3 (diff)
downloadsrc-4617b1f62b3b05364bd9fc4b501df8d504c18fac.tar.gz
src-4617b1f62b3b05364bd9fc4b501df8d504c18fac.zip
decryptcore: preload OpenSSL error strings; seed PRNG
As in r360226, preload OpenSSL error strings and seed the PRNG before entering capability mode. MFC after: 2 weeks Sponsored by: Dell EMC Isilon
Notes
Notes: svn path=/head/; revision=368553
Diffstat (limited to 'sbin')
-rw-r--r--sbin/decryptcore/decryptcore.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sbin/decryptcore/decryptcore.c b/sbin/decryptcore/decryptcore.c
index 80050c9a0bfb..cc1807b18a80 100644
--- a/sbin/decryptcore/decryptcore.c
+++ b/sbin/decryptcore/decryptcore.c
@@ -170,6 +170,19 @@ decrypt(int ofd, const char *privkeyfile, const char *keyfile,
goto failed;
}
+ /*
+ * Obsolescent OpenSSL only knows about /dev/random, and needs to
+ * pre-seed before entering cap mode. For whatever reason,
+ * RSA_pub_encrypt uses the internal PRNG.
+ */
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ {
+ unsigned char c[1];
+ RAND_bytes(c, 1);
+ }
+#endif
+ ERR_load_crypto_strings();
+
caph_cache_catpages();
if (caph_enter() < 0) {
pjdlog_errno(LOG_ERR, "Unable to enter capability mode");