diff options
author | John Baldwin <jhb@FreeBSD.org> | 2020-11-20 17:07:35 -0800 |
---|---|---|
committer | Benjamin Kaduk <bkaduk@akamai.com> | 2021-02-18 13:38:20 -0800 |
commit | b6de54b2c1062f15819174784d9bd53c85c432d3 (patch) | |
tree | b5af6a57aa717dcae834f124fd6cd2eb2d2dc1ca /crypto | |
parent | 01cf4f868e08f82daa16d049fa7d241d8089c8d8 (diff) |
Use CRIOGET to fetch a crypto descriptor when present.
FreeBSD's current /dev/crypto implementation requires that consumers
clone a separate file descriptor via the CRIOGET ioctl that can then
be used with other ioctls such as CIOCGSESSION.
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(cherry picked from commit b39c215decf6e68c28cb64dcfaf5ae5a7e8d35b4)
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13853)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/engine/eng_devcrypto.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crypto/engine/eng_devcrypto.c b/crypto/engine/eng_devcrypto.c index 49e9ce1af3..f03c017181 100644 --- a/crypto/engine/eng_devcrypto.c +++ b/crypto/engine/eng_devcrypto.c @@ -758,8 +758,9 @@ static int devcrypto_unload(ENGINE *e) void engine_load_devcrypto_int() { ENGINE *e = NULL; + int fd; - if ((cfd = open("/dev/crypto", O_RDWR, 0)) < 0) { + if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { #ifndef ENGINE_DEVCRYPTO_DEBUG if (errno != ENOENT) #endif @@ -767,6 +768,16 @@ void engine_load_devcrypto_int() return; } +#ifdef CRIOGET + if (ioctl(fd, CRIOGET, &cfd) < 0) { + fprintf(stderr, "Could not create crypto fd: %s\n", strerror(errno)); + cfd = -1; + return; + } +#else + cfd = fd; +#endif + if ((e = ENGINE_new()) == NULL || !ENGINE_set_destroy_function(e, devcrypto_unload)) { ENGINE_free(e); |