Support session information on FreeBSD.
authorJohn Baldwin <jhb@FreeBSD.org>
Sat, 21 Nov 2020 01:45:48 +0000 (17:45 -0800)
committerBenjamin Kaduk <kaduk@mit.edu>
Tue, 5 Jan 2021 23:16:16 +0000 (15:16 -0800)
commit7fd1ca723a06739e76a17d1065ac94bcfcfc4f9f
tree357317a138c05d6534bb5bab997249468b6b67dd
parentb39c215decf6e68c28cb64dcfaf5ae5a7e8d35b4
Support session information on FreeBSD.

FreeBSD's /dev/crypto does not provide a CIOCGSESSINFO ioctl, but it
does provide other ioctls that can be used to provide similar
functionality.

First, FreeBSD's /dev/crypto defines a CIOCGESSION2 ioctl which accepts
a 'struct session2_op'.  This structure extends 'struct session_op'
with a 'crid' member which can be used to either request an individual
driver by id, or a class of drivers via flags.

To determine if the available drivers for a given algorithm are
accelerated or not, use CIOCGESSION2 to first attempt to create an
accelerated (hardware) session.  If that fails, fall back to
attempting a software session.  In addition, when requesting a new
cipher session, use the current setting of the 'use_softdrivers' flag
to determine the value assigned to 'crid' when invoking CIOCGSESSION2.

Finally, use the returned 'crid' value from CIOCGSESSION2 to look up
the name of the associated driver via the CIOCFINDDEV ioctl.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/13468)
engines/e_devcrypto.c