diff --git a/libc-test/build.rs b/libc-test/build.rs index 9654367814bdd..78bd62e612801 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3221,6 +3221,7 @@ fn test_linux(target: &str) { } let arm = target.contains("arm"); + let aarch64 = target.contains("aarch64"); let i686 = target.contains("i686"); let mips = target.contains("mips"); let mips32 = mips && !target.contains("64"); @@ -3232,7 +3233,7 @@ fn test_linux(target: &str) { let x32 = target.contains("x32"); let x86_32 = target.contains("i686"); let x86_64 = target.contains("x86_64"); - let aarch64_musl = target.contains("aarch64") && musl; + let aarch64_musl = aarch64 && musl; let gnueabihf = target.contains("gnueabihf"); let x86_64_gnux32 = target.contains("gnux32") && x86_64; let riscv64 = target.contains("riscv64"); @@ -3591,6 +3592,25 @@ fn test_linux(target: &str) { // FIXME: The size of `iv` has been changed since Linux v6.0 // https://github.com/torvalds/linux/commit/94dfc73e7cf4a31da66b8843f0b9283ddd6b8381 "af_alg_iv" => true, + + // FIXME: Requires >= 5.1 kernel headers. + // Everything that uses install-musl.sh has 4.19 kernel headers. + "tls12_crypto_info_aes_gcm_256" + if (aarch64 || arm || i686 || mips64 || s390x || x86_64) && musl => + { + true + } + + // FIXME: Requires >= 5.11 kernel headers. + // Everything that uses install-musl.sh has 4.19 kernel headers. + // mips-unknown-linux-musl and mips64-unknown-linux-musl use + // openwrt-sdk which has 5.4 kernel headers. + "tls12_crypto_info_chacha20_poly1305" + if (aarch64 || arm || i686 || mips || s390x || x86_64) && musl => + { + true + } + _ => false, } }); @@ -3915,6 +3935,37 @@ fn test_linux(target: &str) { // FIXME: Requires linux 6.5 "NFT_MSG_MAX" => true, + // FIXME: Requires >= 5.1 kernel headers. + // Everything that uses install-musl.sh has 4.19 kernel headers. + "TLS_1_3_VERSION" + | "TLS_1_3_VERSION_MAJOR" + | "TLS_1_3_VERSION_MINOR" + | "TLS_CIPHER_AES_GCM_256" + | "TLS_CIPHER_AES_GCM_256_IV_SIZE" + | "TLS_CIPHER_AES_GCM_256_KEY_SIZE" + | "TLS_CIPHER_AES_GCM_256_SALT_SIZE" + | "TLS_CIPHER_AES_GCM_256_TAG_SIZE" + | "TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE" + if (aarch64 || arm || i686 || mips64 || s390x || x86_64) && musl => + { + true + } + + // FIXME: Requires >= 5.11 kernel headers. + // Everything that uses install-musl.sh has 4.19 kernel headers. + // mips-unknown-linux-musl and mips64-unknown-linux-musl use + // openwrt-sdk which has 5.4 kernel headers. + "TLS_CIPHER_CHACHA20_POLY1305" + | "TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE" + | "TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE" + | "TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE" + | "TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE" + | "TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE" + if (aarch64 || arm || i686 || mips || s390x || x86_64) && musl => + { + true + } + _ => false, } }); diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index d60d9d9fec7b8..1957a7d657d7c 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2910,7 +2910,34 @@ TIOCSCTTY TIOCSPGRP TIOCSSOFTCAR TIOCSTI +TLS_1_2_VERSION +TLS_1_2_VERSION_MAJOR +TLS_1_2_VERSION_MINOR +TLS_1_3_VERSION +TLS_1_3_VERSION_MAJOR +TLS_1_3_VERSION_MINOR +TLS_CIPHER_AES_GCM_128 +TLS_CIPHER_AES_GCM_128_IV_SIZE +TLS_CIPHER_AES_GCM_128_KEY_SIZE +TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE +TLS_CIPHER_AES_GCM_128_SALT_SIZE +TLS_CIPHER_AES_GCM_128_TAG_SIZE +TLS_CIPHER_AES_GCM_256 +TLS_CIPHER_AES_GCM_256_IV_SIZE +TLS_CIPHER_AES_GCM_256_KEY_SIZE +TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE +TLS_CIPHER_AES_GCM_256_SALT_SIZE +TLS_CIPHER_AES_GCM_256_TAG_SIZE +TLS_CIPHER_CHACHA20_POLY1305 +TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE +TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE +TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE +TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE +TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE TLS_GET_RECORD_TYPE +TLS_RX +TLS_SET_RECORD_TYPE +TLS_TX TUN_READQ_SIZE TUN_TAP_DEV TUN_TUN_DEV diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 59fabeb046cba..50b50703ec8e2 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -686,6 +686,37 @@ s! { pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, } + + // linux/tls.h + + pub struct tls_crypto_info { + pub version: ::__u16, + pub cipher_type: ::__u16, + } + + pub struct tls12_crypto_info_aes_gcm_128 { + pub info: tls_crypto_info, + pub iv: [::c_uchar; TLS_CIPHER_AES_GCM_128_IV_SIZE], + pub key: [::c_uchar; TLS_CIPHER_AES_GCM_128_KEY_SIZE], + pub salt: [::c_uchar; TLS_CIPHER_AES_GCM_128_SALT_SIZE], + pub rec_seq: [::c_uchar; TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_aes_gcm_256 { + pub info: tls_crypto_info, + pub iv: [::c_uchar; TLS_CIPHER_AES_GCM_256_IV_SIZE], + pub key: [::c_uchar; TLS_CIPHER_AES_GCM_256_KEY_SIZE], + pub salt: [::c_uchar; TLS_CIPHER_AES_GCM_256_SALT_SIZE], + pub rec_seq: [::c_uchar; TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_chacha20_poly1305 { + pub info: tls_crypto_info, + pub iv: [::c_uchar; TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE], + pub key: [::c_uchar; TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE], + pub salt: [::c_uchar; TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE], + pub rec_seq: [::c_uchar; TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE], + } } s_no_extra_traits! { @@ -3238,6 +3269,41 @@ pub const HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: ::c_uint = 14; pub const HWTSTAMP_FILTER_NTP_ALL: ::c_uint = 15; // linux/tls.h +pub const TLS_TX: ::c_int = 1; +pub const TLS_RX: ::c_int = 2; + +pub const TLS_1_2_VERSION_MAJOR: ::__u8 = 0x3; +pub const TLS_1_2_VERSION_MINOR: ::__u8 = 0x3; +pub const TLS_1_2_VERSION: ::__u16 = + ((TLS_1_2_VERSION_MAJOR as ::__u16) << 8) | (TLS_1_2_VERSION_MINOR as ::__u16); + +pub const TLS_1_3_VERSION_MAJOR: ::__u8 = 0x3; +pub const TLS_1_3_VERSION_MINOR: ::__u8 = 0x4; +pub const TLS_1_3_VERSION: ::__u16 = + ((TLS_1_3_VERSION_MAJOR as ::__u16) << 8) | (TLS_1_3_VERSION_MINOR as ::__u16); + +pub const TLS_CIPHER_AES_GCM_128: ::__u16 = 51; +pub const TLS_CIPHER_AES_GCM_128_IV_SIZE: usize = 8; +pub const TLS_CIPHER_AES_GCM_128_KEY_SIZE: usize = 16; +pub const TLS_CIPHER_AES_GCM_128_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_AES_GCM_128_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_AES_GCM_256: ::__u16 = 52; +pub const TLS_CIPHER_AES_GCM_256_IV_SIZE: usize = 8; +pub const TLS_CIPHER_AES_GCM_256_KEY_SIZE: usize = 32; +pub const TLS_CIPHER_AES_GCM_256_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_AES_GCM_256_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_CHACHA20_POLY1305: ::__u16 = 54; +pub const TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE: usize = 12; +pub const TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE: usize = 32; +pub const TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE: usize = 0; +pub const TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE: usize = 8; + +pub const TLS_SET_RECORD_TYPE: ::c_int = 1; pub const TLS_GET_RECORD_TYPE: ::c_int = 2; pub const SOL_TLS: ::c_int = 282;