tls: Move tls_make_aad to header to allow sharing
authorIlya Lesokhin <ilyal@mellanox.com>
Mon, 13 Nov 2017 08:22:47 +0000 (10:22 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Nov 2017 07:26:34 +0000 (16:26 +0900)
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>
include/net/tls.h
net/tls/tls_sw.c

index 7cb58a6b8fd0cc3fb936c353974ea69a7204d0a0..70becd0a92996e7e7a30121af50a847e019ca186 100644 (file)
@@ -214,6 +214,21 @@ static inline void tls_fill_prepend(struct tls_context *ctx,
               ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE, iv_size);
 }
 
+static inline void tls_make_aad(char *buf,
+                               size_t size,
+                               char *record_sequence,
+                               int record_sequence_size,
+                               unsigned char record_type)
+{
+       memcpy(buf, record_sequence, record_sequence_size);
+
+       buf[8] = record_type;
+       buf[9] = TLS_1_2_VERSION_MAJOR;
+       buf[10] = TLS_1_2_VERSION_MINOR;
+       buf[11] = size >> 8;
+       buf[12] = size & 0xFF;
+}
+
 static inline struct tls_context *tls_get_ctx(const struct sock *sk)
 {
        struct inet_connection_sock *icsk = inet_csk(sk);
index fcd92a9c2d063a9714ef20db7e643f04b0f35957..73d19210dd497193ff545ee15305113e6090f731 100644 (file)
 
 #include <net/tls.h>
 
-static inline void tls_make_aad(int recv,
-                               char *buf,
-                               size_t size,
-                               char *record_sequence,
-                               int record_sequence_size,
-                               unsigned char record_type)
-{
-       memcpy(buf, record_sequence, record_sequence_size);
-
-       buf[8] = record_type;
-       buf[9] = TLS_1_2_VERSION_MAJOR;
-       buf[10] = TLS_1_2_VERSION_MINOR;
-       buf[11] = size >> 8;
-       buf[12] = size & 0xFF;
-}
-
 static void trim_sg(struct sock *sk, struct scatterlist *sg,
                    int *sg_num_elem, unsigned int *sg_size, int target_size)
 {
@@ -249,7 +233,7 @@ static int tls_push_record(struct sock *sk, int flags,
        sg_mark_end(ctx->sg_plaintext_data + ctx->sg_plaintext_num_elem - 1);
        sg_mark_end(ctx->sg_encrypted_data + ctx->sg_encrypted_num_elem - 1);
 
-       tls_make_aad(0, ctx->aad_space, ctx->sg_plaintext_size,
+       tls_make_aad(ctx->aad_space, ctx->sg_plaintext_size,
                     tls_ctx->rec_seq, tls_ctx->rec_seq_size,
                     record_type);