Fix the socket BIO control methods to use ktls_crypto_info_t.
authorJohn Baldwin <jhb@FreeBSD.org>
Tue, 1 Sep 2020 00:02:01 +0000 (17:02 -0700)
committerBenjamin Kaduk <bkaduk@akamai.com>
Sun, 6 Sep 2020 03:11:50 +0000 (20:11 -0700)
This is mostly a cosmetic cleanup I missed when adding the
ktls_crypto_info_t type.  However, while fixing this I noticed that
the changes to extract the size from crypto_info from the wrapper
structure for Linux KTLS had not been propagated from bss_sock.c to
bss_conn.c, so I've fixed that to use the correct length.

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

crypto/bio/bss_conn.c
crypto/bio/bss_sock.c

index 6cff2a99acf32083157f49bc2b167c0767318927..79e31f80bf225611710b569be415991a6de2f2a0 100644 (file)
@@ -377,11 +377,8 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
     long ret = 1;
     BIO_CONNECT *data;
 # ifndef OPENSSL_NO_KTLS
-#  ifdef __FreeBSD__
-    struct tls_enable *crypto_info;
-#  else
-    struct tls12_crypto_info_aes_gcm_128 *crypto_info;
-#  endif
+    size_t crypto_info_len;
+    ktls_crypto_info_t *crypto_info;
 # endif
 
     data = (BIO_CONNECT *)b->ptr;
@@ -544,12 +541,13 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
         break;
 # ifndef OPENSSL_NO_KTLS
     case BIO_CTRL_SET_KTLS:
+        crypto_info = (ktls_crypto_info_t *)ptr;
 #  ifdef __FreeBSD__
-        crypto_info = (struct tls_enable *)ptr;
+        crypto_info_len = sizeof(*crypto_info);
 #  else
-        crypto_info = (struct tls12_crypto_info_aes_gcm_128 *)ptr;
+        crypto_info_len = crypto_info->tls_crypto_info_len;
 #  endif
-        ret = ktls_start(b->num, crypto_info, sizeof(*crypto_info), num);
+        ret = ktls_start(b->num, crypto_info, crypto_info_len, num);
         if (ret)
             BIO_set_ktls_flag(b, num);
         break;
index ff2bde7a58b2a84ba112cfd2f682776131ef96a8..6c6c610b0e6d3574971c0c89138ee5bf6963475e 100644 (file)
@@ -155,11 +155,7 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
     int *ip;
 # ifndef OPENSSL_NO_KTLS
     size_t crypto_info_len;
-#  ifdef __FreeBSD__
-    struct tls_enable *crypto_info;
-#  else
-    struct tls_crypto_info_all *crypto_info;
-#  endif
+    ktls_crypto_info_t *crypto_info;
 # endif
 
     switch (cmd) {
@@ -190,11 +186,10 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
         break;
 # ifndef OPENSSL_NO_KTLS
     case BIO_CTRL_SET_KTLS:
+        crypto_info = (ktls_crypto_info_t *)ptr;
 #  ifdef __FreeBSD__
-        crypto_info = (struct tls_enable *)ptr;
         crypto_info_len = sizeof(*crypto_info);
 #  else
-        crypto_info = (struct tls_crypto_info_all *)ptr;
         crypto_info_len = crypto_info->tls_crypto_info_len;
 #  endif
         ret = ktls_start(b->num, crypto_info, crypto_info_len, num);