From 77323bcf5361ded9ca6b8eb1fee77a8dfd34654c Mon Sep 17 00:00:00 2001 From: Matthew Macy Date: Sat, 30 Nov 2019 15:38:16 -0800 Subject: [PATCH] Add FreeBSD support to zio_crypto.h Minimal compatibility changes for FreeBSD. Reviewed-by: Jorgen Lundman Reviewed-by: Brian Behlendorf Signed-off-by: Matt Macy Closes #9631 --- include/sys/zio_crypt.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/include/sys/zio_crypt.h b/include/sys/zio_crypt.h index a029127914..fdd65f5a65 100644 --- a/include/sys/zio_crypt.h +++ b/include/sys/zio_crypt.h @@ -22,7 +22,11 @@ #include #include +#if defined(__FreeBSD__) && defined(_KERNEL) +#include +#else #include +#endif /* __FreeBSD__ */ #include #include #include @@ -47,8 +51,15 @@ typedef enum zio_crypt_type { /* table of supported crypto algorithms, modes and keylengths. */ typedef struct zio_crypt_info { /* mechanism name, needed by ICP */ +#if defined(__FreeBSD__) && defined(_KERNEL) + /* + * I've deliberately used a different name here, to catch + * ICP-using code. + */ + const char *ci_algname; +#else crypto_mech_name_t ci_mechname; - +#endif /* cipher mode type (GCM, CCM) */ zio_crypt_type_t ci_crypt_type; @@ -90,8 +101,13 @@ typedef struct zio_crypt_key { /* illumos crypto api current encryption key */ crypto_key_t zk_current_key; +#if defined(__FreeBSD__) && defined(_KERNEL) + /* Session for current encrpytion key. Must always be set */ + freebsd_crypt_session_t zk_session; +#else /* template of current encryption key for illumos crypto api */ crypto_ctx_template_t zk_current_tmpl; +#endif /* illumos crypto api current hmac key */ crypto_key_t zk_hmac_key;