Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tls: Move tls_make_aad to header to allow sharing

move tls_make_aad as it is going to be reused
by the device offload code and rx path.
Remove unused recv parameter.

Signed-off-by: Ilya Lesokhin <ilyal@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ilya Lesokhin and committed by
David S. Miller
213ef6e7 ff45d820

+16 -17
+15
include/net/tls.h
··· 214 214 ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE, iv_size); 215 215 } 216 216 217 + static inline void tls_make_aad(char *buf, 218 + size_t size, 219 + char *record_sequence, 220 + int record_sequence_size, 221 + unsigned char record_type) 222 + { 223 + memcpy(buf, record_sequence, record_sequence_size); 224 + 225 + buf[8] = record_type; 226 + buf[9] = TLS_1_2_VERSION_MAJOR; 227 + buf[10] = TLS_1_2_VERSION_MINOR; 228 + buf[11] = size >> 8; 229 + buf[12] = size & 0xFF; 230 + } 231 + 217 232 static inline struct tls_context *tls_get_ctx(const struct sock *sk) 218 233 { 219 234 struct inet_connection_sock *icsk = inet_csk(sk);
+1 -17
net/tls/tls_sw.c
··· 39 39 40 40 #include <net/tls.h> 41 41 42 - static inline void tls_make_aad(int recv, 43 - char *buf, 44 - size_t size, 45 - char *record_sequence, 46 - int record_sequence_size, 47 - unsigned char record_type) 48 - { 49 - memcpy(buf, record_sequence, record_sequence_size); 50 - 51 - buf[8] = record_type; 52 - buf[9] = TLS_1_2_VERSION_MAJOR; 53 - buf[10] = TLS_1_2_VERSION_MINOR; 54 - buf[11] = size >> 8; 55 - buf[12] = size & 0xFF; 56 - } 57 - 58 42 static void trim_sg(struct sock *sk, struct scatterlist *sg, 59 43 int *sg_num_elem, unsigned int *sg_size, int target_size) 60 44 { ··· 233 249 sg_mark_end(ctx->sg_plaintext_data + ctx->sg_plaintext_num_elem - 1); 234 250 sg_mark_end(ctx->sg_encrypted_data + ctx->sg_encrypted_num_elem - 1); 235 251 236 - tls_make_aad(0, ctx->aad_space, ctx->sg_plaintext_size, 252 + tls_make_aad(ctx->aad_space, ctx->sg_plaintext_size, 237 253 tls_ctx->rec_seq, tls_ctx->rec_seq_size, 238 254 record_type); 239 255