tools/testing/selftests/net/tls.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/tls.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/tls.c- Extension
.c- Size
- 85878 bytes
- Lines
- 3354
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
arpa/inet.herrno.herror.hfcntl.hpoll.hstdio.hstdlib.hunistd.hlinux/tls.hlinux/tcp.hlinux/socket.hsys/epoll.hsys/types.hsys/sendfile.hsys/socket.hsys/stat.hkselftest_harness.h
Detected Declarations
struct tls_crypto_info_keysstruct raw_recfunction tls_crypto_info_initfunction memrndfunction ulp_sock_pairfunction tls_send_cmsgfunction __tls_recv_cmsgfunction tls_recv_cmsgfunction chunked_sendfilefunction test_mutliprocfunction tls_send_keyupdatefunction tls_recv_keyupdatefunction parse_tls_recordsfunction __attribute__
Annotated Snippet
struct tls_crypto_info_keys {
union {
struct tls_crypto_info crypto_info;
struct tls12_crypto_info_aes_gcm_128 aes128;
struct tls12_crypto_info_chacha20_poly1305 chacha20;
struct tls12_crypto_info_sm4_gcm sm4gcm;
struct tls12_crypto_info_sm4_ccm sm4ccm;
struct tls12_crypto_info_aes_ccm_128 aesccm128;
struct tls12_crypto_info_aes_gcm_256 aesgcm256;
struct tls12_crypto_info_aria_gcm_128 ariagcm128;
struct tls12_crypto_info_aria_gcm_256 ariagcm256;
};
size_t len;
};
static void tls_crypto_info_init(uint16_t tls_version, uint16_t cipher_type,
struct tls_crypto_info_keys *tls12,
char key_generation)
{
memset(tls12, key_generation, sizeof(*tls12));
memset(tls12, 0, sizeof(struct tls_crypto_info));
switch (cipher_type) {
case TLS_CIPHER_CHACHA20_POLY1305:
tls12->len = sizeof(struct tls12_crypto_info_chacha20_poly1305);
tls12->chacha20.info.version = tls_version;
tls12->chacha20.info.cipher_type = cipher_type;
break;
case TLS_CIPHER_AES_GCM_128:
tls12->len = sizeof(struct tls12_crypto_info_aes_gcm_128);
tls12->aes128.info.version = tls_version;
tls12->aes128.info.cipher_type = cipher_type;
break;
case TLS_CIPHER_SM4_GCM:
tls12->len = sizeof(struct tls12_crypto_info_sm4_gcm);
tls12->sm4gcm.info.version = tls_version;
tls12->sm4gcm.info.cipher_type = cipher_type;
break;
case TLS_CIPHER_SM4_CCM:
tls12->len = sizeof(struct tls12_crypto_info_sm4_ccm);
tls12->sm4ccm.info.version = tls_version;
tls12->sm4ccm.info.cipher_type = cipher_type;
break;
case TLS_CIPHER_AES_CCM_128:
tls12->len = sizeof(struct tls12_crypto_info_aes_ccm_128);
tls12->aesccm128.info.version = tls_version;
tls12->aesccm128.info.cipher_type = cipher_type;
break;
case TLS_CIPHER_AES_GCM_256:
tls12->len = sizeof(struct tls12_crypto_info_aes_gcm_256);
tls12->aesgcm256.info.version = tls_version;
tls12->aesgcm256.info.cipher_type = cipher_type;
break;
case TLS_CIPHER_ARIA_GCM_128:
tls12->len = sizeof(struct tls12_crypto_info_aria_gcm_128);
tls12->ariagcm128.info.version = tls_version;
tls12->ariagcm128.info.cipher_type = cipher_type;
break;
case TLS_CIPHER_ARIA_GCM_256:
tls12->len = sizeof(struct tls12_crypto_info_aria_gcm_256);
tls12->ariagcm256.info.version = tls_version;
tls12->ariagcm256.info.cipher_type = cipher_type;
break;
default:
break;
}
}
static void memrnd(void *s, size_t n)
{
int *dword = s;
char *byte;
for (; n >= 4; n -= 4)
*dword++ = rand();
byte = (void *)dword;
while (n--)
*byte++ = rand();
}
static void ulp_sock_pair(struct __test_metadata *_metadata,
int *fd, int *cfd, bool *notls)
{
struct sockaddr_in addr;
socklen_t len;
int sfd, ret;
*notls = false;
len = sizeof(addr);
Annotation
- Immediate include surface: `arpa/inet.h`, `errno.h`, `error.h`, `fcntl.h`, `poll.h`, `stdio.h`, `stdlib.h`, `unistd.h`.
- Detected declarations: `struct tls_crypto_info_keys`, `struct raw_rec`, `function tls_crypto_info_init`, `function memrnd`, `function ulp_sock_pair`, `function tls_send_cmsg`, `function __tls_recv_cmsg`, `function tls_recv_cmsg`, `function chunked_sendfile`, `function test_mutliproc`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.