Skip to content

Commit

Permalink
tls: rx: use a define for tag length
Browse files Browse the repository at this point in the history
TLS 1.3 has to strip padding, and it starts out 16 bytes
from the end of the record. Make it clear this is because
of the auth tag.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Apr 8, 2022
1 parent 863533e commit a8340cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/net/tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#define TLS_AAD_SPACE_SIZE 13

#define MAX_IV_SIZE 16
#define TLS_TAG_SIZE 16
#define TLS_MAX_REC_SEQ_SIZE 8

/* For CCM mode, the full 16-bytes of IV is made of '4' fields of given sizes.
Expand Down
4 changes: 2 additions & 2 deletions net/tls/tls_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ static int padding_length(struct tls_prot_info *prot, struct sk_buff *skb)

/* Determine zero-padding length */
if (prot->version == TLS_1_3_VERSION) {
int back = TLS_TAG_SIZE + 1;
char content_type = 0;
int err;
int back = 17;

while (content_type == 0) {
if (back > rxm->full_len - prot->prepend_size)
Expand Down Expand Up @@ -2496,7 +2496,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx)

/* Sanity-check the sizes for stack allocations. */
if (iv_size > MAX_IV_SIZE || nonce_size > MAX_IV_SIZE ||
rec_seq_size > TLS_MAX_REC_SEQ_SIZE) {
rec_seq_size > TLS_MAX_REC_SEQ_SIZE || tag_size != TLS_TAG_SIZE) {
rc = -EINVAL;
goto free_priv;
}
Expand Down

0 comments on commit a8340cc

Please sign in to comment.