diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/engine/hw_cryptodev.c | 25 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/engine/hw_cryptodev.c | 25 |
2 files changed, 40 insertions, 10 deletions
diff --git a/src/lib/libcrypto/engine/hw_cryptodev.c b/src/lib/libcrypto/engine/hw_cryptodev.c index 859af048ee..b8217cdea1 100644 --- a/src/lib/libcrypto/engine/hw_cryptodev.c +++ b/src/lib/libcrypto/engine/hw_cryptodev.c | |||
@@ -112,17 +112,32 @@ static struct { | |||
112 | * Return a fd if /dev/crypto seems usable, 0 otherwise. | 112 | * Return a fd if /dev/crypto seems usable, 0 otherwise. |
113 | */ | 113 | */ |
114 | static int | 114 | static int |
115 | open_dev_crypto() | ||
116 | { | ||
117 | static int fd = -1; | ||
118 | |||
119 | if (fd == -1) { | ||
120 | if (fd = open("/dev/crypto", O_RDWR, 0) == -1) | ||
121 | return (-1); | ||
122 | /* close on exec */ | ||
123 | if (fcntl(fd, F_SETFD, 1) == -1) { | ||
124 | close(fd); | ||
125 | fd = -1; | ||
126 | return (-1); | ||
127 | } | ||
128 | } | ||
129 | return (fd); | ||
130 | } | ||
131 | |||
132 | static int | ||
115 | get_dev_crypto() | 133 | get_dev_crypto() |
116 | { | 134 | { |
117 | int fd, retfd; | 135 | int fd, retfd; |
118 | 136 | ||
119 | if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1) | 137 | if ((fd = open_dev_crypto()) == -1) |
120 | return (-1); | 138 | return (-1); |
121 | if (ioctl(fd, CRIOGET, &retfd) == -1) { | 139 | if (ioctl(fd, CRIOGET, &retfd) == -1) |
122 | close(fd); | ||
123 | return (-1); | 140 | return (-1); |
124 | } | ||
125 | close(fd); | ||
126 | 141 | ||
127 | /* close on exec */ | 142 | /* close on exec */ |
128 | if (fcntl(retfd, F_SETFD, 1) == -1) { | 143 | if (fcntl(retfd, F_SETFD, 1) == -1) { |
diff --git a/src/lib/libssl/src/crypto/engine/hw_cryptodev.c b/src/lib/libssl/src/crypto/engine/hw_cryptodev.c index 859af048ee..b8217cdea1 100644 --- a/src/lib/libssl/src/crypto/engine/hw_cryptodev.c +++ b/src/lib/libssl/src/crypto/engine/hw_cryptodev.c | |||
@@ -112,17 +112,32 @@ static struct { | |||
112 | * Return a fd if /dev/crypto seems usable, 0 otherwise. | 112 | * Return a fd if /dev/crypto seems usable, 0 otherwise. |
113 | */ | 113 | */ |
114 | static int | 114 | static int |
115 | open_dev_crypto() | ||
116 | { | ||
117 | static int fd = -1; | ||
118 | |||
119 | if (fd == -1) { | ||
120 | if (fd = open("/dev/crypto", O_RDWR, 0) == -1) | ||
121 | return (-1); | ||
122 | /* close on exec */ | ||
123 | if (fcntl(fd, F_SETFD, 1) == -1) { | ||
124 | close(fd); | ||
125 | fd = -1; | ||
126 | return (-1); | ||
127 | } | ||
128 | } | ||
129 | return (fd); | ||
130 | } | ||
131 | |||
132 | static int | ||
115 | get_dev_crypto() | 133 | get_dev_crypto() |
116 | { | 134 | { |
117 | int fd, retfd; | 135 | int fd, retfd; |
118 | 136 | ||
119 | if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1) | 137 | if ((fd = open_dev_crypto()) == -1) |
120 | return (-1); | 138 | return (-1); |
121 | if (ioctl(fd, CRIOGET, &retfd) == -1) { | 139 | if (ioctl(fd, CRIOGET, &retfd) == -1) |
122 | close(fd); | ||
123 | return (-1); | 140 | return (-1); |
124 | } | ||
125 | close(fd); | ||
126 | 141 | ||
127 | /* close on exec */ | 142 | /* close on exec */ |
128 | if (fcntl(retfd, F_SETFD, 1) == -1) { | 143 | if (fcntl(retfd, F_SETFD, 1) == -1) { |