Skip to content

Commit a8d18fb

Browse files
uudiingregkh
authored andcommitted
net/tls: Fix authentication failure in CCM mode
commit 5961060 upstream. When the TLS cipher suite uses CCM mode, including AES CCM and SM4 CCM, the first byte of the B0 block is flags, and the real IV starts from the second byte. The XOR operation of the IV and rec_seq should be skip this byte, that is, add the iv_offset. Fixes: f295b3a ("net/tls: Add support of AES128-CCM based ciphers") Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> Cc: Vakul Garg <vakul.garg@nxp.com> Cc: stable@vger.kernel.org # v5.2+ Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent dbe73da commit a8d18fb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎net/tls/tls_sw.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ static int tls_do_encryption(struct sock *sk,
515515
memcpy(&rec->iv_data[iv_offset], tls_ctx->tx.iv,
516516
prot->iv_size + prot->salt_size);
517517

518-
xor_iv_with_seq(prot->version, rec->iv_data, tls_ctx->tx.rec_seq);
518+
xor_iv_with_seq(prot->version, rec->iv_data + iv_offset, tls_ctx->tx.rec_seq);
519519

520520
sge->offset += prot->prepend_size;
521521
sge->length -= prot->prepend_size;
@@ -1487,7 +1487,7 @@ static int decrypt_internal(struct sock *sk, struct sk_buff *skb,
14871487
else
14881488
memcpy(iv + iv_offset, tls_ctx->rx.iv, prot->salt_size);
14891489

1490-
xor_iv_with_seq(prot->version, iv, tls_ctx->rx.rec_seq);
1490+
xor_iv_with_seq(prot->version, iv + iv_offset, tls_ctx->rx.rec_seq);
14911491

14921492
/* Prepare AAD */
14931493
tls_make_aad(aad, rxm->full_len - prot->overhead_size +

0 commit comments

Comments
 (0)