Skip to content

Commit 213ef6e

Browse files
Ilya Lesokhindavem330
Ilya Lesokhin
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ff45d82 commit 213ef6e

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

include/net/tls.h

+15
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,21 @@ static inline void tls_fill_prepend(struct tls_context *ctx,
214214
ctx->iv + TLS_CIPHER_AES_GCM_128_SALT_SIZE, iv_size);
215215
}
216216

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+
217232
static inline struct tls_context *tls_get_ctx(const struct sock *sk)
218233
{
219234
struct inet_connection_sock *icsk = inet_csk(sk);

net/tls/tls_sw.c

+1-17
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,6 @@
3939

4040
#include <net/tls.h>
4141

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-
5842
static void trim_sg(struct sock *sk, struct scatterlist *sg,
5943
int *sg_num_elem, unsigned int *sg_size, int target_size)
6044
{
@@ -249,7 +233,7 @@ static int tls_push_record(struct sock *sk, int flags,
249233
sg_mark_end(ctx->sg_plaintext_data + ctx->sg_plaintext_num_elem - 1);
250234
sg_mark_end(ctx->sg_encrypted_data + ctx->sg_encrypted_num_elem - 1);
251235

252-
tls_make_aad(0, ctx->aad_space, ctx->sg_plaintext_size,
236+
tls_make_aad(ctx->aad_space, ctx->sg_plaintext_size,
253237
tls_ctx->rec_seq, tls_ctx->rec_seq_size,
254238
record_type);
255239

0 commit comments

Comments
 (0)