The Linux kernel added a user space API to its crypto functions at 2.6 via a new new socket family AF_ALG. Also see crypto: af_alg - User-space interface for Crypto API on LWN.
I'm working with Gentoo, and it requires one to configure and build the kernel. It appears the default settings omit AF_ALG, so I'm [currently] working with a kernel that lacks the support. OpenSSL 1.1.0 has an Engine interface into the crypto API. Its failing its self tests due to lack of support for AF_ALG.
I'd like to know how to detect availability of AF_ALG at both compile time and runtime. I have not found a way to detect availability at compile time. I think we can use alg_get_type to detect runtime availability, but I'm not certain.
How can I determine availability of AF_ALG at compile time and at runtime?
The socket(2) man pages has this to say: "Some socket types may not be implemented by all protocol families." But it does not discuss how to detect availability.
The kernel docs cover the API in Chapter 4. User Space Interface, but it does not appear to discuss how to detect availability.
For completeness, it looks like the following kernel configuration parameters need to be set for Gentoo (from Marek VaĊĦut's Utilizing the crypto accelerators):
CONFIG_CRYPTO_USER_API=mCONFIG_CRYPTO_USER_API_HASH=mCONFIG_CRYPTO_USER_API_SKCIPHER=m
syscall,__NR_io_setup,__NR_eventfdand__NR_io_destroy. - jww