summaryrefslogtreecommitdiffstats
path: root/net/tls/tls_sw.c
diff options
context:
space:
mode:
authorSabrina Dubroca <sd@queasysnail.net>2023-10-09 22:50:48 +0200
committerDavid S. Miller <davem@davemloft.net>2023-10-13 12:26:10 +0200
commit1a074f7618e8b82a7cebf45df6e005d2284446ce (patch)
treee87977b94d9aeea66d5e61670a8a42dff3520452 /net/tls/tls_sw.c
parenttls: move tls_prot_info initialization out of tls_set_sw_offload (diff)
downloadlinux-1a074f7618e8b82a7cebf45df6e005d2284446ce.tar.xz
linux-1a074f7618e8b82a7cebf45df6e005d2284446ce.zip
tls: also use init_prot_info in tls_set_device_offload
Most values are shared. Nonce size turns out to be equal to IV size for all offloadable ciphers. Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tls/tls_sw.c')
-rw-r--r--net/tls/tls_sw.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index b8e89bbb4a49..0995d3d14f4b 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -2620,9 +2620,10 @@ static struct tls_sw_context_rx *init_ctx_rx(struct tls_context *ctx)
return sw_ctx_rx;
}
-static int init_prot_info(struct tls_prot_info *prot,
- const struct tls_crypto_info *crypto_info,
- const struct tls_cipher_desc *cipher_desc)
+int init_prot_info(struct tls_prot_info *prot,
+ const struct tls_crypto_info *crypto_info,
+ const struct tls_cipher_desc *cipher_desc,
+ int mode)
{
u16 nonce_size = cipher_desc->nonce;
@@ -2635,6 +2636,11 @@ static int init_prot_info(struct tls_prot_info *prot,
prot->tail_size = 0;
}
+ if (mode == TLS_HW) {
+ prot->aad_size = 0;
+ prot->tail_size = 0;
+ }
+
/* Sanity-check the sizes for stack allocations. */
if (nonce_size > TLS_MAX_IV_SIZE || prot->aad_size > TLS_MAX_AAD_SIZE)
return -EINVAL;
@@ -2696,7 +2702,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx)
goto free_priv;
}
- rc = init_prot_info(prot, crypto_info, cipher_desc);
+ rc = init_prot_info(prot, crypto_info, cipher_desc, TLS_SW);
if (rc)
goto free_priv;