summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src
diff options
context:
space:
mode:
authormarkus <markus@openbsd.org>2002-06-18 14:36:53 +0000
committermarkus <markus@openbsd.org>2002-06-18 14:36:53 +0000
commit876aa5390477c5333cb247d6f9e32c5ef429e16f (patch)
treeabe5fa61203d39ef67984ca4db9ecd00890cc5a1 /lib/libssl/src
parentRemove all traces of the PCCONS stuff. (Remove pc.h and references to NPC (diff)
downloadwireguard-openbsd-876aa5390477c5333cb247d6f9e32c5ef429e16f.tar.xz
wireguard-openbsd-876aa5390477c5333cb247d6f9e32c5ef429e16f.zip
unbreak sshd with privsep: open /dev/crypto, keep fd, and call
CRIOGET per EVP_Init(); ok niklas@, miod@
Diffstat (limited to 'lib/libssl/src')
-rw-r--r--lib/libssl/src/crypto/engine/hw_cryptodev.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/libssl/src/crypto/engine/hw_cryptodev.c b/lib/libssl/src/crypto/engine/hw_cryptodev.c
index 859af048ee5..b8217cdea1d 100644
--- a/lib/libssl/src/crypto/engine/hw_cryptodev.c
+++ b/lib/libssl/src/crypto/engine/hw_cryptodev.c
@@ -112,17 +112,32 @@ static struct {
* Return a fd if /dev/crypto seems usable, 0 otherwise.
*/
static int
+open_dev_crypto()
+{
+ static int fd = -1;
+
+ if (fd == -1) {
+ if (fd = open("/dev/crypto", O_RDWR, 0) == -1)
+ return (-1);
+ /* close on exec */
+ if (fcntl(fd, F_SETFD, 1) == -1) {
+ close(fd);
+ fd = -1;
+ return (-1);
+ }
+ }
+ return (fd);
+}
+
+static int
get_dev_crypto()
{
int fd, retfd;
- if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1)
+ if ((fd = open_dev_crypto()) == -1)
return (-1);
- if (ioctl(fd, CRIOGET, &retfd) == -1) {
- close(fd);
+ if (ioctl(fd, CRIOGET, &retfd) == -1)
return (-1);
- }
- close(fd);
/* close on exec */
if (fcntl(retfd, F_SETFD, 1) == -1) {