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

net/tls: getsockopt supports complete algorithm list

AES_CCM_128 and CHACHA20_POLY1305 are already supported by tls,
similar to setsockopt, getsockopt also needs to support these
two algorithms.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tianjia Zhang and committed by
David S. Miller
3fb59a5d 39d8fb96

+42
+42
net/tls/tls_main.c
··· 421 421 rc = -EFAULT; 422 422 break; 423 423 } 424 + case TLS_CIPHER_AES_CCM_128: { 425 + struct tls12_crypto_info_aes_ccm_128 *aes_ccm_128 = 426 + container_of(crypto_info, 427 + struct tls12_crypto_info_aes_ccm_128, info); 428 + 429 + if (len != sizeof(*aes_ccm_128)) { 430 + rc = -EINVAL; 431 + goto out; 432 + } 433 + lock_sock(sk); 434 + memcpy(aes_ccm_128->iv, 435 + cctx->iv + TLS_CIPHER_AES_CCM_128_SALT_SIZE, 436 + TLS_CIPHER_AES_CCM_128_IV_SIZE); 437 + memcpy(aes_ccm_128->rec_seq, cctx->rec_seq, 438 + TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE); 439 + release_sock(sk); 440 + if (copy_to_user(optval, aes_ccm_128, sizeof(*aes_ccm_128))) 441 + rc = -EFAULT; 442 + break; 443 + } 444 + case TLS_CIPHER_CHACHA20_POLY1305: { 445 + struct tls12_crypto_info_chacha20_poly1305 *chacha20_poly1305 = 446 + container_of(crypto_info, 447 + struct tls12_crypto_info_chacha20_poly1305, 448 + info); 449 + 450 + if (len != sizeof(*chacha20_poly1305)) { 451 + rc = -EINVAL; 452 + goto out; 453 + } 454 + lock_sock(sk); 455 + memcpy(chacha20_poly1305->iv, 456 + cctx->iv + TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE, 457 + TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE); 458 + memcpy(chacha20_poly1305->rec_seq, cctx->rec_seq, 459 + TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE); 460 + release_sock(sk); 461 + if (copy_to_user(optval, chacha20_poly1305, 462 + sizeof(*chacha20_poly1305))) 463 + rc = -EFAULT; 464 + break; 465 + } 424 466 case TLS_CIPHER_SM4_GCM: { 425 467 struct tls12_crypto_info_sm4_gcm *sm4_gcm_info = 426 468 container_of(crypto_info,