From 924a443998d91f0135caa996d76a41db19e81234 Mon Sep 17 00:00:00 2001 From: Valentyn Faychuk Date: Sun, 8 Sep 2024 02:56:25 +0300 Subject: [PATCH] rewrote ioctl layer, updated scripts --- .gitignore | 1 + Cargo.toml | 11 +- Occlum.json | 80 ++ build.rs | 5 + build_client.sh | 19 +- build_server.sh | 19 +- examples/mratls_grpcs_client.rs | 6 +- examples/mratls_grpcs_server.rs | 5 +- examples/mratls_https_client.rs | 11 +- examples/mratls_https_server.rs | 2 +- src/bindings.rs | 1988 +++++++++++++++++++++++++++++++ src/config.rs | 29 +- src/error.rs | 6 +- src/lib.rs | 6 +- src/prelude.rs | 3 +- src/quote.rs | 334 ++++++ src/racert.rs | 10 +- 17 files changed, 2480 insertions(+), 55 deletions(-) create mode 100644 Occlum.json create mode 100644 src/bindings.rs create mode 100644 src/quote.rs diff --git a/.gitignore b/.gitignore index ecd78e8..5863575 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ target Cargo.lock client_instance server_instance +lib diff --git a/Cargo.toml b/Cargo.toml index 2f3895f..6285ec5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,9 @@ hyper = "1.4.1" hyper-util = "0.1.7" hyper-rustls = { version = "0.27", features = ["http2"] } prost = "0.13" +#cfg-if = "1.0" +base64 = "0.22" +lazy_static = "1.5" [dependencies.tonic] version = "0.12" @@ -59,10 +62,10 @@ version = "0.11" version = "1" features = ["full"] -[dev-dependencies.cargo-husky] -version = "1" -default-features = false -features = ["precommit-hook", "run-cargo-test", "run-cargo-clippy"] +#[dev-dependencies.cargo-husky] +#version = "1" +#default-features = false +#features = ["precommit-hook", "run-cargo-test", "run-cargo-clippy"] [build-dependencies] tonic-build = "0.12" diff --git a/Occlum.json b/Occlum.json new file mode 100644 index 0000000..5dc95d5 --- /dev/null +++ b/Occlum.json @@ -0,0 +1,80 @@ +{ + "resource_limits": { + "kernel_space_heap_size": "32MB", + "kernel_space_stack_size": "1MB", + "user_space_size": "300MB", + "max_num_of_threads": 32 + }, + "process": { + "default_stack_size": "4MB", + "default_heap_size": "32MB", + "default_mmap_size": "100MB" + }, + "entry_points": [ + "/bin" + ], + "env": { + "default": [ + "OCCLUM=yes" + ], + "untrusted": [ + "EXAMPLE" + ] + }, + "metadata": { + "product_id": 0, + "version_number": 0, + "debuggable": false, + "enable_kss": false, + "family_id": { + "high": "0x0", + "low": "0x0" + }, + "ext_prod_id": { + "high": "0x0", + "low": "0x0" + } + }, + "feature": { + "amx": 0, + "pkru": 0, + "enable_edmm": false, + "enable_posix_shm": false + }, + "mount": [ + { + "target": "/", + "type": "unionfs", + "options": { + "layers": [ + { + "target": "/", + "type": "sefs", + "source": "./build/mount/__ROOT", + "options": { + "MAC": "" + } + }, + { + "target": "/", + "type": "sefs", + "source": "./run/mount/__ROOT" + } + ] + } + }, + { + "target": "/host", + "type": "hostfs", + "source": "." + }, + { + "target": "/proc", + "type": "procfs" + }, + { + "target": "/dev", + "type": "devfs" + } + ] +} diff --git a/build.rs b/build.rs index 520f3da..665dccb 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,9 @@ fn main() { + // TODO: should be conditional on the target platform (musl vs glibc) + println!("cargo:rustc-link-search=/opt/occlum/toolchains/dcap_lib/musl"); + // Cargo will automatically know it must look for `libocclum_dcap.a` + println!("cargo:rustc-link-lib=occlum_dcap"); + tonic_build::configure() .build_server(true) .compile(&["examples/echo.proto"], &["examples"]) diff --git a/build_client.sh b/build_client.sh index 364808a..38a4061 100755 --- a/build_client.sh +++ b/build_client.sh @@ -3,16 +3,17 @@ set -e SCRIPT=$0 EXAMPLE=$1 +EXEC=$2 if [ $# -eq 0 ] || [ "$EXAMPLE" != "https" ] && [ "$EXAMPLE" != "grpcs" ]; then - echo "usage: $SCRIPT https|grpcs" + echo "usage: $SCRIPT https|grpcs [--run]" exit 1 fi FEATURES=$(if [ "$EXAMPLE" == "https" ]; then echo "reqwest,occlum"; else echo "tonic,occlum"; fi) -occlum-cargo build --example mratls_"${EXAMPLE}"_client --features="$FEATURES" -strip target/x86_64-unknown-linux-musl/debug/examples/mratls_"${EXAMPLE}"_client +occlum-cargo build --release --example mratls_"${EXAMPLE}"_client --features="$FEATURES" +strip target/x86_64-unknown-linux-musl/release/examples/mratls_"${EXAMPLE}"_client cat > client.yaml < server.yaml < Result<(), Box> { let mut mrsigner = [0u8; 32]; hex::decode_to_slice(mrsigner_hex, &mut mrsigner).expect("mrsigner decoding failed"); - let config = RaTlsConfig::new().allow_instance_measurement( - InstanceMeasurement::new().with_mrsigners(vec![SGXMeasurement::new(mrsigner)]), - ); + let config = RaTlsConfig::new() + .allow_instance_measurement(InstanceMeasurement::new().with_mrsigners(vec![mrsigner])); let tls = ClientConfig::from_ratls_config(config) .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("{}", e)))?; diff --git a/examples/mratls_grpcs_server.rs b/examples/mratls_grpcs_server.rs index b7d377c..b1eb668 100644 --- a/examples/mratls_grpcs_server.rs +++ b/examples/mratls_grpcs_server.rs @@ -33,9 +33,8 @@ async fn main() -> Result<(), Box> { let mut mrsigner = [0u8; 32]; hex::decode_to_slice(mrsigner_hex, &mut mrsigner).expect("mrsigner decoding failed"); - let config = RaTlsConfig::new().allow_instance_measurement( - InstanceMeasurement::new().with_mrsigners(vec![SGXMeasurement::new(mrsigner)]), - ); + let config = RaTlsConfig::new() + .allow_instance_measurement(InstanceMeasurement::new().with_mrsigners(vec![mrsigner])); let mut tls = ServerConfig::from_ratls_config(config) .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("{}", e)))?; diff --git a/examples/mratls_https_client.rs b/examples/mratls_https_client.rs index 532df8a..a7b325c 100644 --- a/examples/mratls_https_client.rs +++ b/examples/mratls_https_client.rs @@ -9,11 +9,12 @@ async fn main() -> Result<(), Box> { let mut mrsigner = [0u8; 32]; hex::decode_to_slice(mrsigner_hex, &mut mrsigner)?; - let client = ClientBuilder::new() - .use_ratls(RaTlsConfig::new().allow_instance_measurement( - InstanceMeasurement::new().with_mrsigners(vec![SGXMeasurement::new(mrsigner)]), - )) - .build()?; + let client = + ClientBuilder::new() + .use_ratls(RaTlsConfig::new().allow_instance_measurement( + InstanceMeasurement::new().with_mrsigners(vec![mrsigner]), + )) + .build()?; let res = client.get("https://127.0.0.1:8000").send().await?; let data = res.text().await?; diff --git a/examples/mratls_https_server.rs b/examples/mratls_https_server.rs index e03bde7..6da12c0 100644 --- a/examples/mratls_https_server.rs +++ b/examples/mratls_https_server.rs @@ -19,7 +19,7 @@ async fn main() -> Result<(), Box> { .bind_ratls( SocketAddr::from(([127, 0, 0, 1], 8000)), RaTlsConfig::new().allow_instance_measurement( - InstanceMeasurement::new().with_mrsigners(vec![SGXMeasurement::new(mrsigner)]), + InstanceMeasurement::new().with_mrsigners(vec![mrsigner]), ), ) .unwrap() diff --git a/src/bindings.rs b/src/bindings.rs new file mode 100644 index 0000000..b104d01 --- /dev/null +++ b/src/bindings.rs @@ -0,0 +1,1988 @@ +/* automatically generated by rust-bindgen 0.70.1 */ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(dead_code)] + +pub const _STDINT_H: u32 = 1; +pub const _FEATURES_H: u32 = 1; +pub const _DEFAULT_SOURCE: u32 = 1; +pub const __GLIBC_USE_ISOC2X: u32 = 0; +pub const __USE_ISOC11: u32 = 1; +pub const __USE_ISOC99: u32 = 1; +pub const __USE_ISOC95: u32 = 1; +pub const __USE_POSIX_IMPLICITLY: u32 = 1; +pub const _POSIX_SOURCE: u32 = 1; +pub const _POSIX_C_SOURCE: u32 = 200809; +pub const __USE_POSIX: u32 = 1; +pub const __USE_POSIX2: u32 = 1; +pub const __USE_POSIX199309: u32 = 1; +pub const __USE_POSIX199506: u32 = 1; +pub const __USE_XOPEN2K: u32 = 1; +pub const __USE_XOPEN2K8: u32 = 1; +pub const _ATFILE_SOURCE: u32 = 1; +pub const __USE_MISC: u32 = 1; +pub const __USE_ATFILE: u32 = 1; +pub const __USE_FORTIFY_LEVEL: u32 = 0; +pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; +pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; +pub const _STDC_PREDEF_H: u32 = 1; +pub const __STDC_IEC_559__: u32 = 1; +pub const __STDC_IEC_559_COMPLEX__: u32 = 1; +pub const __STDC_ISO_10646__: u32 = 201706; +pub const __GNU_LIBRARY__: u32 = 6; +pub const __GLIBC__: u32 = 2; +pub const __GLIBC_MINOR__: u32 = 31; +pub const _SYS_CDEFS_H: u32 = 1; +pub const __glibc_c99_flexarr_available: u32 = 1; +pub const __WORDSIZE: u32 = 64; +pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; +pub const __SYSCALL_WORDSIZE: u32 = 64; +pub const __LONG_DOUBLE_USES_FLOAT128: u32 = 0; +pub const __HAVE_GENERIC_SELECTION: u32 = 1; +pub const __GLIBC_USE_LIB_EXT2: u32 = 0; +pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X: u32 = 0; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X: u32 = 0; +pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; +pub const _BITS_TYPES_H: u32 = 1; +pub const __TIMESIZE: u32 = 64; +pub const _BITS_TYPESIZES_H: u32 = 1; +pub const __OFF_T_MATCHES_OFF64_T: u32 = 1; +pub const __INO_T_MATCHES_INO64_T: u32 = 1; +pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1; +pub const __STATFS_MATCHES_STATFS64: u32 = 1; +pub const __FD_SETSIZE: u32 = 1024; +pub const _BITS_TIME64_H: u32 = 1; +pub const _BITS_WCHAR_H: u32 = 1; +pub const _BITS_STDINT_INTN_H: u32 = 1; +pub const _BITS_STDINT_UINTN_H: u32 = 1; +pub const INT8_MIN: i32 = -128; +pub const INT16_MIN: i32 = -32768; +pub const INT32_MIN: i32 = -2147483648; +pub const INT8_MAX: u32 = 127; +pub const INT16_MAX: u32 = 32767; +pub const INT32_MAX: u32 = 2147483647; +pub const UINT8_MAX: u32 = 255; +pub const UINT16_MAX: u32 = 65535; +pub const UINT32_MAX: u32 = 4294967295; +pub const INT_LEAST8_MIN: i32 = -128; +pub const INT_LEAST16_MIN: i32 = -32768; +pub const INT_LEAST32_MIN: i32 = -2147483648; +pub const INT_LEAST8_MAX: u32 = 127; +pub const INT_LEAST16_MAX: u32 = 32767; +pub const INT_LEAST32_MAX: u32 = 2147483647; +pub const UINT_LEAST8_MAX: u32 = 255; +pub const UINT_LEAST16_MAX: u32 = 65535; +pub const UINT_LEAST32_MAX: u32 = 4294967295; +pub const INT_FAST8_MIN: i32 = -128; +pub const INT_FAST16_MIN: i64 = -9223372036854775808; +pub const INT_FAST32_MIN: i64 = -9223372036854775808; +pub const INT_FAST8_MAX: u32 = 127; +pub const INT_FAST16_MAX: u64 = 9223372036854775807; +pub const INT_FAST32_MAX: u64 = 9223372036854775807; +pub const UINT_FAST8_MAX: u32 = 255; +pub const UINT_FAST16_MAX: i32 = -1; +pub const UINT_FAST32_MAX: i32 = -1; +pub const INTPTR_MIN: i64 = -9223372036854775808; +pub const INTPTR_MAX: u64 = 9223372036854775807; +pub const UINTPTR_MAX: i32 = -1; +pub const PTRDIFF_MIN: i64 = -9223372036854775808; +pub const PTRDIFF_MAX: u64 = 9223372036854775807; +pub const SIG_ATOMIC_MIN: i32 = -2147483648; +pub const SIG_ATOMIC_MAX: u32 = 2147483647; +pub const SIZE_MAX: i32 = -1; +pub const WINT_MIN: u32 = 0; +pub const WINT_MAX: u32 = 4294967295; +pub const _STDLIB_H: u32 = 1; +pub const WNOHANG: u32 = 1; +pub const WUNTRACED: u32 = 2; +pub const WSTOPPED: u32 = 2; +pub const WEXITED: u32 = 4; +pub const WCONTINUED: u32 = 8; +pub const WNOWAIT: u32 = 16777216; +pub const __WNOTHREAD: u32 = 536870912; +pub const __WALL: u32 = 1073741824; +pub const __WCLONE: u32 = 2147483648; +pub const __ENUM_IDTYPE_T: u32 = 1; +pub const __W_CONTINUED: u32 = 65535; +pub const __WCOREFLAG: u32 = 128; +pub const __HAVE_FLOAT128: u32 = 0; +pub const __HAVE_DISTINCT_FLOAT128: u32 = 0; +pub const __HAVE_FLOAT64X: u32 = 1; +pub const __HAVE_FLOAT64X_LONG_DOUBLE: u32 = 1; +pub const __HAVE_FLOAT16: u32 = 0; +pub const __HAVE_FLOAT32: u32 = 1; +pub const __HAVE_FLOAT64: u32 = 1; +pub const __HAVE_FLOAT32X: u32 = 1; +pub const __HAVE_FLOAT128X: u32 = 0; +pub const __HAVE_DISTINCT_FLOAT16: u32 = 0; +pub const __HAVE_DISTINCT_FLOAT32: u32 = 0; +pub const __HAVE_DISTINCT_FLOAT64: u32 = 0; +pub const __HAVE_DISTINCT_FLOAT32X: u32 = 0; +pub const __HAVE_DISTINCT_FLOAT64X: u32 = 0; +pub const __HAVE_DISTINCT_FLOAT128X: u32 = 0; +pub const __HAVE_FLOATN_NOT_TYPEDEF: u32 = 0; +pub const __ldiv_t_defined: u32 = 1; +pub const __lldiv_t_defined: u32 = 1; +pub const RAND_MAX: u32 = 2147483647; +pub const EXIT_FAILURE: u32 = 1; +pub const EXIT_SUCCESS: u32 = 0; +pub const _SYS_TYPES_H: u32 = 1; +pub const __clock_t_defined: u32 = 1; +pub const __clockid_t_defined: u32 = 1; +pub const __time_t_defined: u32 = 1; +pub const __timer_t_defined: u32 = 1; +pub const __BIT_TYPES_DEFINED__: u32 = 1; +pub const _ENDIAN_H: u32 = 1; +pub const _BITS_ENDIAN_H: u32 = 1; +pub const __LITTLE_ENDIAN: u32 = 1234; +pub const __BIG_ENDIAN: u32 = 4321; +pub const __PDP_ENDIAN: u32 = 3412; +pub const _BITS_ENDIANNESS_H: u32 = 1; +pub const __BYTE_ORDER: u32 = 1234; +pub const __FLOAT_WORD_ORDER: u32 = 1234; +pub const LITTLE_ENDIAN: u32 = 1234; +pub const BIG_ENDIAN: u32 = 4321; +pub const PDP_ENDIAN: u32 = 3412; +pub const BYTE_ORDER: u32 = 1234; +pub const _BITS_BYTESWAP_H: u32 = 1; +pub const _BITS_UINTN_IDENTITY_H: u32 = 1; +pub const _SYS_SELECT_H: u32 = 1; +pub const __FD_ZERO_STOS: &[u8; 6] = b"stosq\0"; +pub const __sigset_t_defined: u32 = 1; +pub const __timeval_defined: u32 = 1; +pub const _STRUCT_TIMESPEC: u32 = 1; +pub const FD_SETSIZE: u32 = 1024; +pub const _BITS_PTHREADTYPES_COMMON_H: u32 = 1; +pub const _THREAD_SHARED_TYPES_H: u32 = 1; +pub const _BITS_PTHREADTYPES_ARCH_H: u32 = 1; +pub const __SIZEOF_PTHREAD_MUTEX_T: u32 = 40; +pub const __SIZEOF_PTHREAD_ATTR_T: u32 = 56; +pub const __SIZEOF_PTHREAD_RWLOCK_T: u32 = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: u32 = 32; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: u32 = 4; +pub const __SIZEOF_PTHREAD_COND_T: u32 = 48; +pub const __SIZEOF_PTHREAD_CONDATTR_T: u32 = 4; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: u32 = 8; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: u32 = 4; +pub const _THREAD_MUTEX_INTERNAL_H: u32 = 1; +pub const __PTHREAD_MUTEX_HAVE_PREV: u32 = 1; +pub const __have_pthread_attr_t: u32 = 1; +pub const _ALLOCA_H: u32 = 1; +pub const SGX_FLAGS_INITTED: u32 = 1; +pub const SGX_FLAGS_DEBUG: u32 = 2; +pub const SGX_FLAGS_MODE64BIT: u32 = 4; +pub const SGX_FLAGS_PROVISION_KEY: u32 = 16; +pub const SGX_FLAGS_EINITTOKEN_KEY: u32 = 32; +pub const SGX_FLAGS_KSS: u32 = 128; +pub const SGX_FLAGS_AEX_NOTIFY: u32 = 1024; +pub const SGX_FLAGS_NON_CHECK_BITS: u64 = 71776119061217280; +pub const SGX_XFRM_LEGACY: u32 = 3; +pub const SGX_XFRM_AVX: u32 = 6; +pub const SGX_XFRM_AVX512: u32 = 230; +pub const SGX_XFRM_MPX: u32 = 24; +pub const SGX_XFRM_PKRU: u32 = 512; +pub const SGX_XFRM_AMX: u32 = 393216; +pub const SGX_XFRM_RESERVED: i32 = -393960; +pub const SGX_KEYSELECT_EINITTOKEN: u32 = 0; +pub const SGX_KEYSELECT_PROVISION: u32 = 1; +pub const SGX_KEYSELECT_PROVISION_SEAL: u32 = 2; +pub const SGX_KEYSELECT_REPORT: u32 = 3; +pub const SGX_KEYSELECT_SEAL: u32 = 4; +pub const SGX_KEYPOLICY_MRENCLAVE: u32 = 1; +pub const SGX_KEYPOLICY_MRSIGNER: u32 = 2; +pub const SGX_KEYPOLICY_NOISVPRODID: u32 = 4; +pub const SGX_KEYPOLICY_CONFIGID: u32 = 8; +pub const SGX_KEYPOLICY_ISVFAMILYID: u32 = 16; +pub const SGX_KEYPOLICY_ISVEXTPRODID: u32 = 32; +pub const SGX_KEYID_SIZE: u32 = 32; +pub const SGX_CPUSVN_SIZE: u32 = 16; +pub const SGX_CONFIGID_SIZE: u32 = 64; +pub const SGX_KEY_REQUEST_RESERVED2_BYTES: u32 = 434; +pub const SGX_HASH_SIZE: u32 = 32; +pub const SGX_MAC_SIZE: u32 = 16; +pub const SGX_REPORT_DATA_SIZE: u32 = 64; +pub const SGX_ISVEXT_PROD_ID_SIZE: u32 = 16; +pub const SGX_ISV_FAMILY_ID_SIZE: u32 = 16; +pub const SGX_TARGET_INFO_RESERVED1_BYTES: u32 = 2; +pub const SGX_TARGET_INFO_RESERVED2_BYTES: u32 = 8; +pub const SGX_TARGET_INFO_RESERVED3_BYTES: u32 = 384; +pub const SGX_REPORT_BODY_RESERVED1_BYTES: u32 = 12; +pub const SGX_REPORT_BODY_RESERVED2_BYTES: u32 = 32; +pub const SGX_REPORT_BODY_RESERVED3_BYTES: u32 = 32; +pub const SGX_REPORT_BODY_RESERVED4_BYTES: u32 = 42; +pub const _TIME_H: u32 = 1; +pub const _BITS_TIME_H: u32 = 1; +pub const CLOCK_REALTIME: u32 = 0; +pub const CLOCK_MONOTONIC: u32 = 1; +pub const CLOCK_PROCESS_CPUTIME_ID: u32 = 2; +pub const CLOCK_THREAD_CPUTIME_ID: u32 = 3; +pub const CLOCK_MONOTONIC_RAW: u32 = 4; +pub const CLOCK_REALTIME_COARSE: u32 = 5; +pub const CLOCK_MONOTONIC_COARSE: u32 = 6; +pub const CLOCK_BOOTTIME: u32 = 7; +pub const CLOCK_REALTIME_ALARM: u32 = 8; +pub const CLOCK_BOOTTIME_ALARM: u32 = 9; +pub const CLOCK_TAI: u32 = 11; +pub const TIMER_ABSTIME: u32 = 1; +pub const __struct_tm_defined: u32 = 1; +pub const __itimerspec_defined: u32 = 1; +pub const _BITS_TYPES_LOCALE_T_H: u32 = 1; +pub const _BITS_TYPES___LOCALE_T_H: u32 = 1; +pub const TIME_UTC: u32 = 1; +pub const ROOT_KEY_ID_SIZE: u32 = 48; +pub const PLATFORM_INSTANCE_ID_SIZE: u32 = 16; +pub const MAX_SA_SIZE: u32 = 20; +pub const MAX_SA_NUMBER_PER_TCB: u32 = 20; +pub const MAX_SA_LIST_SIZE: u32 = 320; +pub type __u_char = ::std::os::raw::c_uchar; +pub type __u_short = ::std::os::raw::c_ushort; +pub type __u_int = ::std::os::raw::c_uint; +pub type __u_long = ::std::os::raw::c_ulong; +pub type __int8_t = ::std::os::raw::c_schar; +pub type __uint8_t = ::std::os::raw::c_uchar; +pub type __int16_t = ::std::os::raw::c_short; +pub type __uint16_t = ::std::os::raw::c_ushort; +pub type __int32_t = ::std::os::raw::c_int; +pub type __uint32_t = ::std::os::raw::c_uint; +pub type __int64_t = ::std::os::raw::c_long; +pub type __uint64_t = ::std::os::raw::c_ulong; +pub type __int_least8_t = __int8_t; +pub type __uint_least8_t = __uint8_t; +pub type __int_least16_t = __int16_t; +pub type __uint_least16_t = __uint16_t; +pub type __int_least32_t = __int32_t; +pub type __uint_least32_t = __uint32_t; +pub type __int_least64_t = __int64_t; +pub type __uint_least64_t = __uint64_t; +pub type __quad_t = ::std::os::raw::c_long; +pub type __u_quad_t = ::std::os::raw::c_ulong; +pub type __intmax_t = ::std::os::raw::c_long; +pub type __uintmax_t = ::std::os::raw::c_ulong; +pub type __dev_t = ::std::os::raw::c_ulong; +pub type __uid_t = ::std::os::raw::c_uint; +pub type __gid_t = ::std::os::raw::c_uint; +pub type __ino_t = ::std::os::raw::c_ulong; +pub type __ino64_t = ::std::os::raw::c_ulong; +pub type __mode_t = ::std::os::raw::c_uint; +pub type __nlink_t = ::std::os::raw::c_ulong; +pub type __off_t = ::std::os::raw::c_long; +pub type __off64_t = ::std::os::raw::c_long; +pub type __pid_t = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __fsid_t { + pub __val: [::std::os::raw::c_int; 2usize], +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __fsid_t"][::std::mem::size_of::<__fsid_t>() - 8usize]; + ["Alignment of __fsid_t"][::std::mem::align_of::<__fsid_t>() - 4usize]; + ["Offset of field: __fsid_t::__val"][::std::mem::offset_of!(__fsid_t, __val) - 0usize]; +}; +pub type __clock_t = ::std::os::raw::c_long; +pub type __rlim_t = ::std::os::raw::c_ulong; +pub type __rlim64_t = ::std::os::raw::c_ulong; +pub type __id_t = ::std::os::raw::c_uint; +pub type __time_t = ::std::os::raw::c_long; +pub type __useconds_t = ::std::os::raw::c_uint; +pub type __suseconds_t = ::std::os::raw::c_long; +pub type __daddr_t = ::std::os::raw::c_int; +pub type __key_t = ::std::os::raw::c_int; +pub type __clockid_t = ::std::os::raw::c_int; +pub type __timer_t = *mut ::std::os::raw::c_void; +pub type __blksize_t = ::std::os::raw::c_long; +pub type __blkcnt_t = ::std::os::raw::c_long; +pub type __blkcnt64_t = ::std::os::raw::c_long; +pub type __fsblkcnt_t = ::std::os::raw::c_ulong; +pub type __fsblkcnt64_t = ::std::os::raw::c_ulong; +pub type __fsfilcnt_t = ::std::os::raw::c_ulong; +pub type __fsfilcnt64_t = ::std::os::raw::c_ulong; +pub type __fsword_t = ::std::os::raw::c_long; +pub type __ssize_t = ::std::os::raw::c_long; +pub type __syscall_slong_t = ::std::os::raw::c_long; +pub type __syscall_ulong_t = ::std::os::raw::c_ulong; +pub type __loff_t = __off64_t; +pub type __caddr_t = *mut ::std::os::raw::c_char; +pub type __intptr_t = ::std::os::raw::c_long; +pub type __socklen_t = ::std::os::raw::c_uint; +pub type __sig_atomic_t = ::std::os::raw::c_int; +pub type int_least8_t = __int_least8_t; +pub type int_least16_t = __int_least16_t; +pub type int_least32_t = __int_least32_t; +pub type int_least64_t = __int_least64_t; +pub type uint_least8_t = __uint_least8_t; +pub type uint_least16_t = __uint_least16_t; +pub type uint_least32_t = __uint_least32_t; +pub type uint_least64_t = __uint_least64_t; +pub type int_fast8_t = ::std::os::raw::c_schar; +pub type int_fast16_t = ::std::os::raw::c_long; +pub type int_fast32_t = ::std::os::raw::c_long; +pub type int_fast64_t = ::std::os::raw::c_long; +pub type uint_fast8_t = ::std::os::raw::c_uchar; +pub type uint_fast16_t = ::std::os::raw::c_ulong; +pub type uint_fast32_t = ::std::os::raw::c_ulong; +pub type uint_fast64_t = ::std::os::raw::c_ulong; +pub type intmax_t = __intmax_t; +pub type uintmax_t = __uintmax_t; +pub type wchar_t = ::std::os::raw::c_int; +pub const idtype_t_P_ALL: idtype_t = 0; +pub const idtype_t_P_PID: idtype_t = 1; +pub const idtype_t_P_PGID: idtype_t = 2; +pub type idtype_t = ::std::os::raw::c_uint; +pub type _Float32 = f32; +pub type _Float64 = f64; +pub type _Float32x = f64; +pub type _Float64x = u128; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct div_t { + pub quot: ::std::os::raw::c_int, + pub rem: ::std::os::raw::c_int, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of div_t"][::std::mem::size_of::() - 8usize]; + ["Alignment of div_t"][::std::mem::align_of::() - 4usize]; + ["Offset of field: div_t::quot"][::std::mem::offset_of!(div_t, quot) - 0usize]; + ["Offset of field: div_t::rem"][::std::mem::offset_of!(div_t, rem) - 4usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ldiv_t { + pub quot: ::std::os::raw::c_long, + pub rem: ::std::os::raw::c_long, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of ldiv_t"][::std::mem::size_of::() - 16usize]; + ["Alignment of ldiv_t"][::std::mem::align_of::() - 8usize]; + ["Offset of field: ldiv_t::quot"][::std::mem::offset_of!(ldiv_t, quot) - 0usize]; + ["Offset of field: ldiv_t::rem"][::std::mem::offset_of!(ldiv_t, rem) - 8usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct lldiv_t { + pub quot: ::std::os::raw::c_longlong, + pub rem: ::std::os::raw::c_longlong, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of lldiv_t"][::std::mem::size_of::() - 16usize]; + ["Alignment of lldiv_t"][::std::mem::align_of::() - 8usize]; + ["Offset of field: lldiv_t::quot"][::std::mem::offset_of!(lldiv_t, quot) - 0usize]; + ["Offset of field: lldiv_t::rem"][::std::mem::offset_of!(lldiv_t, rem) - 8usize]; +}; +extern "C" { + pub fn __ctype_get_mb_cur_max() -> usize; +} +extern "C" { + pub fn atof(__nptr: *const ::std::os::raw::c_char) -> f64; +} +extern "C" { + pub fn atoi(__nptr: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn atol(__nptr: *const ::std::os::raw::c_char) -> ::std::os::raw::c_long; +} +extern "C" { + pub fn atoll(__nptr: *const ::std::os::raw::c_char) -> ::std::os::raw::c_longlong; +} +extern "C" { + pub fn strtod( + __nptr: *const ::std::os::raw::c_char, + __endptr: *mut *mut ::std::os::raw::c_char, + ) -> f64; +} +extern "C" { + pub fn strtof( + __nptr: *const ::std::os::raw::c_char, + __endptr: *mut *mut ::std::os::raw::c_char, + ) -> f32; +} +extern "C" { + pub fn strtol( + __nptr: *const ::std::os::raw::c_char, + __endptr: *mut *mut ::std::os::raw::c_char, + __base: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_long; +} +extern "C" { + pub fn strtoul( + __nptr: *const ::std::os::raw::c_char, + __endptr: *mut *mut ::std::os::raw::c_char, + __base: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_ulong; +} +extern "C" { + pub fn strtoq( + __nptr: *const ::std::os::raw::c_char, + __endptr: *mut *mut ::std::os::raw::c_char, + __base: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + pub fn strtouq( + __nptr: *const ::std::os::raw::c_char, + __endptr: *mut *mut ::std::os::raw::c_char, + __base: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_ulonglong; +} +extern "C" { + pub fn strtoll( + __nptr: *const ::std::os::raw::c_char, + __endptr: *mut *mut ::std::os::raw::c_char, + __base: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_longlong; +} +extern "C" { + pub fn strtoull( + __nptr: *const ::std::os::raw::c_char, + __endptr: *mut *mut ::std::os::raw::c_char, + __base: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_ulonglong; +} +extern "C" { + pub fn l64a(__n: ::std::os::raw::c_long) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn a64l(__s: *const ::std::os::raw::c_char) -> ::std::os::raw::c_long; +} +pub type u_char = __u_char; +pub type u_short = __u_short; +pub type u_int = __u_int; +pub type u_long = __u_long; +pub type quad_t = __quad_t; +pub type u_quad_t = __u_quad_t; +pub type fsid_t = __fsid_t; +pub type loff_t = __loff_t; +pub type ino_t = __ino_t; +pub type dev_t = __dev_t; +pub type gid_t = __gid_t; +pub type mode_t = __mode_t; +pub type nlink_t = __nlink_t; +pub type uid_t = __uid_t; +pub type off_t = __off_t; +pub type pid_t = __pid_t; +pub type id_t = __id_t; +pub type daddr_t = __daddr_t; +pub type caddr_t = __caddr_t; +pub type key_t = __key_t; +pub type clock_t = __clock_t; +pub type clockid_t = __clockid_t; +pub type time_t = __time_t; +pub type timer_t = __timer_t; +pub type ulong = ::std::os::raw::c_ulong; +pub type ushort = ::std::os::raw::c_ushort; +pub type uint = ::std::os::raw::c_uint; +pub type u_int8_t = __uint8_t; +pub type u_int16_t = __uint16_t; +pub type u_int32_t = __uint32_t; +pub type u_int64_t = __uint64_t; +pub type register_t = ::std::os::raw::c_long; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __sigset_t { + pub __val: [::std::os::raw::c_ulong; 16usize], +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __sigset_t"][::std::mem::size_of::<__sigset_t>() - 128usize]; + ["Alignment of __sigset_t"][::std::mem::align_of::<__sigset_t>() - 8usize]; + ["Offset of field: __sigset_t::__val"][::std::mem::offset_of!(__sigset_t, __val) - 0usize]; +}; +pub type sigset_t = __sigset_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct timeval { + pub tv_sec: __time_t, + pub tv_usec: __suseconds_t, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of timeval"][::std::mem::size_of::() - 16usize]; + ["Alignment of timeval"][::std::mem::align_of::() - 8usize]; + ["Offset of field: timeval::tv_sec"][::std::mem::offset_of!(timeval, tv_sec) - 0usize]; + ["Offset of field: timeval::tv_usec"][::std::mem::offset_of!(timeval, tv_usec) - 8usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct timespec { + pub tv_sec: __time_t, + pub tv_nsec: __syscall_slong_t, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of timespec"][::std::mem::size_of::() - 16usize]; + ["Alignment of timespec"][::std::mem::align_of::() - 8usize]; + ["Offset of field: timespec::tv_sec"][::std::mem::offset_of!(timespec, tv_sec) - 0usize]; + ["Offset of field: timespec::tv_nsec"][::std::mem::offset_of!(timespec, tv_nsec) - 8usize]; +}; +pub type suseconds_t = __suseconds_t; +pub type __fd_mask = ::std::os::raw::c_long; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct fd_set { + pub __fds_bits: [__fd_mask; 16usize], +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of fd_set"][::std::mem::size_of::() - 128usize]; + ["Alignment of fd_set"][::std::mem::align_of::() - 8usize]; + ["Offset of field: fd_set::__fds_bits"][::std::mem::offset_of!(fd_set, __fds_bits) - 0usize]; +}; +pub type fd_mask = __fd_mask; +extern "C" { + pub fn select( + __nfds: ::std::os::raw::c_int, + __readfds: *mut fd_set, + __writefds: *mut fd_set, + __exceptfds: *mut fd_set, + __timeout: *mut timeval, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn pselect( + __nfds: ::std::os::raw::c_int, + __readfds: *mut fd_set, + __writefds: *mut fd_set, + __exceptfds: *mut fd_set, + __timeout: *const timespec, + __sigmask: *const __sigset_t, + ) -> ::std::os::raw::c_int; +} +pub type blksize_t = __blksize_t; +pub type blkcnt_t = __blkcnt_t; +pub type fsblkcnt_t = __fsblkcnt_t; +pub type fsfilcnt_t = __fsfilcnt_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_internal_list { + pub __prev: *mut __pthread_internal_list, + pub __next: *mut __pthread_internal_list, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __pthread_internal_list"][::std::mem::size_of::<__pthread_internal_list>() - 16usize]; + ["Alignment of __pthread_internal_list"] + [::std::mem::align_of::<__pthread_internal_list>() - 8usize]; + ["Offset of field: __pthread_internal_list::__prev"] + [::std::mem::offset_of!(__pthread_internal_list, __prev) - 0usize]; + ["Offset of field: __pthread_internal_list::__next"] + [::std::mem::offset_of!(__pthread_internal_list, __next) - 8usize]; +}; +pub type __pthread_list_t = __pthread_internal_list; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_internal_slist { + pub __next: *mut __pthread_internal_slist, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __pthread_internal_slist"] + [::std::mem::size_of::<__pthread_internal_slist>() - 8usize]; + ["Alignment of __pthread_internal_slist"] + [::std::mem::align_of::<__pthread_internal_slist>() - 8usize]; + ["Offset of field: __pthread_internal_slist::__next"] + [::std::mem::offset_of!(__pthread_internal_slist, __next) - 0usize]; +}; +pub type __pthread_slist_t = __pthread_internal_slist; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_mutex_s { + pub __lock: ::std::os::raw::c_int, + pub __count: ::std::os::raw::c_uint, + pub __owner: ::std::os::raw::c_int, + pub __nusers: ::std::os::raw::c_uint, + pub __kind: ::std::os::raw::c_int, + pub __spins: ::std::os::raw::c_short, + pub __elision: ::std::os::raw::c_short, + pub __list: __pthread_list_t, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __pthread_mutex_s"][::std::mem::size_of::<__pthread_mutex_s>() - 40usize]; + ["Alignment of __pthread_mutex_s"][::std::mem::align_of::<__pthread_mutex_s>() - 8usize]; + ["Offset of field: __pthread_mutex_s::__lock"] + [::std::mem::offset_of!(__pthread_mutex_s, __lock) - 0usize]; + ["Offset of field: __pthread_mutex_s::__count"] + [::std::mem::offset_of!(__pthread_mutex_s, __count) - 4usize]; + ["Offset of field: __pthread_mutex_s::__owner"] + [::std::mem::offset_of!(__pthread_mutex_s, __owner) - 8usize]; + ["Offset of field: __pthread_mutex_s::__nusers"] + [::std::mem::offset_of!(__pthread_mutex_s, __nusers) - 12usize]; + ["Offset of field: __pthread_mutex_s::__kind"] + [::std::mem::offset_of!(__pthread_mutex_s, __kind) - 16usize]; + ["Offset of field: __pthread_mutex_s::__spins"] + [::std::mem::offset_of!(__pthread_mutex_s, __spins) - 20usize]; + ["Offset of field: __pthread_mutex_s::__elision"] + [::std::mem::offset_of!(__pthread_mutex_s, __elision) - 22usize]; + ["Offset of field: __pthread_mutex_s::__list"] + [::std::mem::offset_of!(__pthread_mutex_s, __list) - 24usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_rwlock_arch_t { + pub __readers: ::std::os::raw::c_uint, + pub __writers: ::std::os::raw::c_uint, + pub __wrphase_futex: ::std::os::raw::c_uint, + pub __writers_futex: ::std::os::raw::c_uint, + pub __pad3: ::std::os::raw::c_uint, + pub __pad4: ::std::os::raw::c_uint, + pub __cur_writer: ::std::os::raw::c_int, + pub __shared: ::std::os::raw::c_int, + pub __rwelision: ::std::os::raw::c_schar, + pub __pad1: [::std::os::raw::c_uchar; 7usize], + pub __pad2: ::std::os::raw::c_ulong, + pub __flags: ::std::os::raw::c_uint, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __pthread_rwlock_arch_t"][::std::mem::size_of::<__pthread_rwlock_arch_t>() - 56usize]; + ["Alignment of __pthread_rwlock_arch_t"] + [::std::mem::align_of::<__pthread_rwlock_arch_t>() - 8usize]; + ["Offset of field: __pthread_rwlock_arch_t::__readers"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __readers) - 0usize]; + ["Offset of field: __pthread_rwlock_arch_t::__writers"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __writers) - 4usize]; + ["Offset of field: __pthread_rwlock_arch_t::__wrphase_futex"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __wrphase_futex) - 8usize]; + ["Offset of field: __pthread_rwlock_arch_t::__writers_futex"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __writers_futex) - 12usize]; + ["Offset of field: __pthread_rwlock_arch_t::__pad3"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __pad3) - 16usize]; + ["Offset of field: __pthread_rwlock_arch_t::__pad4"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __pad4) - 20usize]; + ["Offset of field: __pthread_rwlock_arch_t::__cur_writer"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __cur_writer) - 24usize]; + ["Offset of field: __pthread_rwlock_arch_t::__shared"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __shared) - 28usize]; + ["Offset of field: __pthread_rwlock_arch_t::__rwelision"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __rwelision) - 32usize]; + ["Offset of field: __pthread_rwlock_arch_t::__pad1"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __pad1) - 33usize]; + ["Offset of field: __pthread_rwlock_arch_t::__pad2"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __pad2) - 40usize]; + ["Offset of field: __pthread_rwlock_arch_t::__flags"] + [::std::mem::offset_of!(__pthread_rwlock_arch_t, __flags) - 48usize]; +}; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct __pthread_cond_s { + pub __bindgen_anon_1: __pthread_cond_s__bindgen_ty_1, + pub __bindgen_anon_2: __pthread_cond_s__bindgen_ty_2, + pub __g_refs: [::std::os::raw::c_uint; 2usize], + pub __g_size: [::std::os::raw::c_uint; 2usize], + pub __g1_orig_size: ::std::os::raw::c_uint, + pub __wrefs: ::std::os::raw::c_uint, + pub __g_signals: [::std::os::raw::c_uint; 2usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union __pthread_cond_s__bindgen_ty_1 { + pub __wseq: ::std::os::raw::c_ulonglong, + pub __wseq32: __pthread_cond_s__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_cond_s__bindgen_ty_1__bindgen_ty_1 { + pub __low: ::std::os::raw::c_uint, + pub __high: ::std::os::raw::c_uint, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __pthread_cond_s__bindgen_ty_1__bindgen_ty_1"] + [::std::mem::size_of::<__pthread_cond_s__bindgen_ty_1__bindgen_ty_1>() - 8usize]; + ["Alignment of __pthread_cond_s__bindgen_ty_1__bindgen_ty_1"] + [::std::mem::align_of::<__pthread_cond_s__bindgen_ty_1__bindgen_ty_1>() - 4usize]; + ["Offset of field: __pthread_cond_s__bindgen_ty_1__bindgen_ty_1::__low"] + [::std::mem::offset_of!(__pthread_cond_s__bindgen_ty_1__bindgen_ty_1, __low) - 0usize]; + ["Offset of field: __pthread_cond_s__bindgen_ty_1__bindgen_ty_1::__high"] + [::std::mem::offset_of!(__pthread_cond_s__bindgen_ty_1__bindgen_ty_1, __high) - 4usize]; +}; +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __pthread_cond_s__bindgen_ty_1"] + [::std::mem::size_of::<__pthread_cond_s__bindgen_ty_1>() - 8usize]; + ["Alignment of __pthread_cond_s__bindgen_ty_1"] + [::std::mem::align_of::<__pthread_cond_s__bindgen_ty_1>() - 8usize]; + ["Offset of field: __pthread_cond_s__bindgen_ty_1::__wseq"] + [::std::mem::offset_of!(__pthread_cond_s__bindgen_ty_1, __wseq) - 0usize]; + ["Offset of field: __pthread_cond_s__bindgen_ty_1::__wseq32"] + [::std::mem::offset_of!(__pthread_cond_s__bindgen_ty_1, __wseq32) - 0usize]; +}; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __pthread_cond_s__bindgen_ty_2 { + pub __g1_start: ::std::os::raw::c_ulonglong, + pub __g1_start32: __pthread_cond_s__bindgen_ty_2__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __pthread_cond_s__bindgen_ty_2__bindgen_ty_1 { + pub __low: ::std::os::raw::c_uint, + pub __high: ::std::os::raw::c_uint, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __pthread_cond_s__bindgen_ty_2__bindgen_ty_1"] + [::std::mem::size_of::<__pthread_cond_s__bindgen_ty_2__bindgen_ty_1>() - 8usize]; + ["Alignment of __pthread_cond_s__bindgen_ty_2__bindgen_ty_1"] + [::std::mem::align_of::<__pthread_cond_s__bindgen_ty_2__bindgen_ty_1>() - 4usize]; + ["Offset of field: __pthread_cond_s__bindgen_ty_2__bindgen_ty_1::__low"] + [::std::mem::offset_of!(__pthread_cond_s__bindgen_ty_2__bindgen_ty_1, __low) - 0usize]; + ["Offset of field: __pthread_cond_s__bindgen_ty_2__bindgen_ty_1::__high"] + [::std::mem::offset_of!(__pthread_cond_s__bindgen_ty_2__bindgen_ty_1, __high) - 4usize]; +}; +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __pthread_cond_s__bindgen_ty_2"] + [::std::mem::size_of::<__pthread_cond_s__bindgen_ty_2>() - 8usize]; + ["Alignment of __pthread_cond_s__bindgen_ty_2"] + [::std::mem::align_of::<__pthread_cond_s__bindgen_ty_2>() - 8usize]; + ["Offset of field: __pthread_cond_s__bindgen_ty_2::__g1_start"] + [::std::mem::offset_of!(__pthread_cond_s__bindgen_ty_2, __g1_start) - 0usize]; + ["Offset of field: __pthread_cond_s__bindgen_ty_2::__g1_start32"] + [::std::mem::offset_of!(__pthread_cond_s__bindgen_ty_2, __g1_start32) - 0usize]; +}; +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __pthread_cond_s"][::std::mem::size_of::<__pthread_cond_s>() - 48usize]; + ["Alignment of __pthread_cond_s"][::std::mem::align_of::<__pthread_cond_s>() - 8usize]; + ["Offset of field: __pthread_cond_s::__g_refs"] + [::std::mem::offset_of!(__pthread_cond_s, __g_refs) - 16usize]; + ["Offset of field: __pthread_cond_s::__g_size"] + [::std::mem::offset_of!(__pthread_cond_s, __g_size) - 24usize]; + ["Offset of field: __pthread_cond_s::__g1_orig_size"] + [::std::mem::offset_of!(__pthread_cond_s, __g1_orig_size) - 32usize]; + ["Offset of field: __pthread_cond_s::__wrefs"] + [::std::mem::offset_of!(__pthread_cond_s, __wrefs) - 36usize]; + ["Offset of field: __pthread_cond_s::__g_signals"] + [::std::mem::offset_of!(__pthread_cond_s, __g_signals) - 40usize]; +}; +pub type pthread_t = ::std::os::raw::c_ulong; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_mutexattr_t { + pub __size: [::std::os::raw::c_char; 4usize], + pub __align: ::std::os::raw::c_int, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pthread_mutexattr_t"][::std::mem::size_of::() - 4usize]; + ["Alignment of pthread_mutexattr_t"][::std::mem::align_of::() - 4usize]; + ["Offset of field: pthread_mutexattr_t::__size"] + [::std::mem::offset_of!(pthread_mutexattr_t, __size) - 0usize]; + ["Offset of field: pthread_mutexattr_t::__align"] + [::std::mem::offset_of!(pthread_mutexattr_t, __align) - 0usize]; +}; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_condattr_t { + pub __size: [::std::os::raw::c_char; 4usize], + pub __align: ::std::os::raw::c_int, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pthread_condattr_t"][::std::mem::size_of::() - 4usize]; + ["Alignment of pthread_condattr_t"][::std::mem::align_of::() - 4usize]; + ["Offset of field: pthread_condattr_t::__size"] + [::std::mem::offset_of!(pthread_condattr_t, __size) - 0usize]; + ["Offset of field: pthread_condattr_t::__align"] + [::std::mem::offset_of!(pthread_condattr_t, __align) - 0usize]; +}; +pub type pthread_key_t = ::std::os::raw::c_uint; +pub type pthread_once_t = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_attr_t { + pub __size: [::std::os::raw::c_char; 56usize], + pub __align: ::std::os::raw::c_long, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pthread_attr_t"][::std::mem::size_of::() - 56usize]; + ["Alignment of pthread_attr_t"][::std::mem::align_of::() - 8usize]; + ["Offset of field: pthread_attr_t::__size"] + [::std::mem::offset_of!(pthread_attr_t, __size) - 0usize]; + ["Offset of field: pthread_attr_t::__align"] + [::std::mem::offset_of!(pthread_attr_t, __align) - 0usize]; +}; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_mutex_t { + pub __data: __pthread_mutex_s, + pub __size: [::std::os::raw::c_char; 40usize], + pub __align: ::std::os::raw::c_long, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pthread_mutex_t"][::std::mem::size_of::() - 40usize]; + ["Alignment of pthread_mutex_t"][::std::mem::align_of::() - 8usize]; + ["Offset of field: pthread_mutex_t::__data"] + [::std::mem::offset_of!(pthread_mutex_t, __data) - 0usize]; + ["Offset of field: pthread_mutex_t::__size"] + [::std::mem::offset_of!(pthread_mutex_t, __size) - 0usize]; + ["Offset of field: pthread_mutex_t::__align"] + [::std::mem::offset_of!(pthread_mutex_t, __align) - 0usize]; +}; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_cond_t { + pub __data: __pthread_cond_s, + pub __size: [::std::os::raw::c_char; 48usize], + pub __align: ::std::os::raw::c_longlong, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pthread_cond_t"][::std::mem::size_of::() - 48usize]; + ["Alignment of pthread_cond_t"][::std::mem::align_of::() - 8usize]; + ["Offset of field: pthread_cond_t::__data"] + [::std::mem::offset_of!(pthread_cond_t, __data) - 0usize]; + ["Offset of field: pthread_cond_t::__size"] + [::std::mem::offset_of!(pthread_cond_t, __size) - 0usize]; + ["Offset of field: pthread_cond_t::__align"] + [::std::mem::offset_of!(pthread_cond_t, __align) - 0usize]; +}; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_rwlock_t { + pub __data: __pthread_rwlock_arch_t, + pub __size: [::std::os::raw::c_char; 56usize], + pub __align: ::std::os::raw::c_long, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pthread_rwlock_t"][::std::mem::size_of::() - 56usize]; + ["Alignment of pthread_rwlock_t"][::std::mem::align_of::() - 8usize]; + ["Offset of field: pthread_rwlock_t::__data"] + [::std::mem::offset_of!(pthread_rwlock_t, __data) - 0usize]; + ["Offset of field: pthread_rwlock_t::__size"] + [::std::mem::offset_of!(pthread_rwlock_t, __size) - 0usize]; + ["Offset of field: pthread_rwlock_t::__align"] + [::std::mem::offset_of!(pthread_rwlock_t, __align) - 0usize]; +}; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_rwlockattr_t { + pub __size: [::std::os::raw::c_char; 8usize], + pub __align: ::std::os::raw::c_long, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pthread_rwlockattr_t"][::std::mem::size_of::() - 8usize]; + ["Alignment of pthread_rwlockattr_t"][::std::mem::align_of::() - 8usize]; + ["Offset of field: pthread_rwlockattr_t::__size"] + [::std::mem::offset_of!(pthread_rwlockattr_t, __size) - 0usize]; + ["Offset of field: pthread_rwlockattr_t::__align"] + [::std::mem::offset_of!(pthread_rwlockattr_t, __align) - 0usize]; +}; +pub type pthread_spinlock_t = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_barrier_t { + pub __size: [::std::os::raw::c_char; 32usize], + pub __align: ::std::os::raw::c_long, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pthread_barrier_t"][::std::mem::size_of::() - 32usize]; + ["Alignment of pthread_barrier_t"][::std::mem::align_of::() - 8usize]; + ["Offset of field: pthread_barrier_t::__size"] + [::std::mem::offset_of!(pthread_barrier_t, __size) - 0usize]; + ["Offset of field: pthread_barrier_t::__align"] + [::std::mem::offset_of!(pthread_barrier_t, __align) - 0usize]; +}; +#[repr(C)] +#[derive(Copy, Clone)] +pub union pthread_barrierattr_t { + pub __size: [::std::os::raw::c_char; 4usize], + pub __align: ::std::os::raw::c_int, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of pthread_barrierattr_t"][::std::mem::size_of::() - 4usize]; + ["Alignment of pthread_barrierattr_t"] + [::std::mem::align_of::() - 4usize]; + ["Offset of field: pthread_barrierattr_t::__size"] + [::std::mem::offset_of!(pthread_barrierattr_t, __size) - 0usize]; + ["Offset of field: pthread_barrierattr_t::__align"] + [::std::mem::offset_of!(pthread_barrierattr_t, __align) - 0usize]; +}; +extern "C" { + pub fn random() -> ::std::os::raw::c_long; +} +extern "C" { + pub fn srandom(__seed: ::std::os::raw::c_uint); +} +extern "C" { + pub fn initstate( + __seed: ::std::os::raw::c_uint, + __statebuf: *mut ::std::os::raw::c_char, + __statelen: usize, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn setstate(__statebuf: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct random_data { + pub fptr: *mut i32, + pub rptr: *mut i32, + pub state: *mut i32, + pub rand_type: ::std::os::raw::c_int, + pub rand_deg: ::std::os::raw::c_int, + pub rand_sep: ::std::os::raw::c_int, + pub end_ptr: *mut i32, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of random_data"][::std::mem::size_of::() - 48usize]; + ["Alignment of random_data"][::std::mem::align_of::() - 8usize]; + ["Offset of field: random_data::fptr"][::std::mem::offset_of!(random_data, fptr) - 0usize]; + ["Offset of field: random_data::rptr"][::std::mem::offset_of!(random_data, rptr) - 8usize]; + ["Offset of field: random_data::state"][::std::mem::offset_of!(random_data, state) - 16usize]; + ["Offset of field: random_data::rand_type"] + [::std::mem::offset_of!(random_data, rand_type) - 24usize]; + ["Offset of field: random_data::rand_deg"] + [::std::mem::offset_of!(random_data, rand_deg) - 28usize]; + ["Offset of field: random_data::rand_sep"] + [::std::mem::offset_of!(random_data, rand_sep) - 32usize]; + ["Offset of field: random_data::end_ptr"] + [::std::mem::offset_of!(random_data, end_ptr) - 40usize]; +}; +extern "C" { + pub fn random_r(__buf: *mut random_data, __result: *mut i32) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn srandom_r( + __seed: ::std::os::raw::c_uint, + __buf: *mut random_data, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn initstate_r( + __seed: ::std::os::raw::c_uint, + __statebuf: *mut ::std::os::raw::c_char, + __statelen: usize, + __buf: *mut random_data, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn setstate_r( + __statebuf: *mut ::std::os::raw::c_char, + __buf: *mut random_data, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn rand() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn srand(__seed: ::std::os::raw::c_uint); +} +extern "C" { + pub fn rand_r(__seed: *mut ::std::os::raw::c_uint) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn drand48() -> f64; +} +extern "C" { + pub fn erand48(__xsubi: *mut ::std::os::raw::c_ushort) -> f64; +} +extern "C" { + pub fn lrand48() -> ::std::os::raw::c_long; +} +extern "C" { + pub fn nrand48(__xsubi: *mut ::std::os::raw::c_ushort) -> ::std::os::raw::c_long; +} +extern "C" { + pub fn mrand48() -> ::std::os::raw::c_long; +} +extern "C" { + pub fn jrand48(__xsubi: *mut ::std::os::raw::c_ushort) -> ::std::os::raw::c_long; +} +extern "C" { + pub fn srand48(__seedval: ::std::os::raw::c_long); +} +extern "C" { + pub fn seed48(__seed16v: *mut ::std::os::raw::c_ushort) -> *mut ::std::os::raw::c_ushort; +} +extern "C" { + pub fn lcong48(__param: *mut ::std::os::raw::c_ushort); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct drand48_data { + pub __x: [::std::os::raw::c_ushort; 3usize], + pub __old_x: [::std::os::raw::c_ushort; 3usize], + pub __c: ::std::os::raw::c_ushort, + pub __init: ::std::os::raw::c_ushort, + pub __a: ::std::os::raw::c_ulonglong, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of drand48_data"][::std::mem::size_of::() - 24usize]; + ["Alignment of drand48_data"][::std::mem::align_of::() - 8usize]; + ["Offset of field: drand48_data::__x"][::std::mem::offset_of!(drand48_data, __x) - 0usize]; + ["Offset of field: drand48_data::__old_x"] + [::std::mem::offset_of!(drand48_data, __old_x) - 6usize]; + ["Offset of field: drand48_data::__c"][::std::mem::offset_of!(drand48_data, __c) - 12usize]; + ["Offset of field: drand48_data::__init"] + [::std::mem::offset_of!(drand48_data, __init) - 14usize]; + ["Offset of field: drand48_data::__a"][::std::mem::offset_of!(drand48_data, __a) - 16usize]; +}; +extern "C" { + pub fn drand48_r(__buffer: *mut drand48_data, __result: *mut f64) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn erand48_r( + __xsubi: *mut ::std::os::raw::c_ushort, + __buffer: *mut drand48_data, + __result: *mut f64, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn lrand48_r( + __buffer: *mut drand48_data, + __result: *mut ::std::os::raw::c_long, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn nrand48_r( + __xsubi: *mut ::std::os::raw::c_ushort, + __buffer: *mut drand48_data, + __result: *mut ::std::os::raw::c_long, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn mrand48_r( + __buffer: *mut drand48_data, + __result: *mut ::std::os::raw::c_long, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jrand48_r( + __xsubi: *mut ::std::os::raw::c_ushort, + __buffer: *mut drand48_data, + __result: *mut ::std::os::raw::c_long, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn srand48_r( + __seedval: ::std::os::raw::c_long, + __buffer: *mut drand48_data, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn seed48_r( + __seed16v: *mut ::std::os::raw::c_ushort, + __buffer: *mut drand48_data, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn lcong48_r( + __param: *mut ::std::os::raw::c_ushort, + __buffer: *mut drand48_data, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn malloc(__size: ::std::os::raw::c_ulong) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn calloc( + __nmemb: ::std::os::raw::c_ulong, + __size: ::std::os::raw::c_ulong, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn realloc( + __ptr: *mut ::std::os::raw::c_void, + __size: ::std::os::raw::c_ulong, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn reallocarray( + __ptr: *mut ::std::os::raw::c_void, + __nmemb: usize, + __size: usize, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn free(__ptr: *mut ::std::os::raw::c_void); +} +extern "C" { + pub fn alloca(__size: ::std::os::raw::c_ulong) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn valloc(__size: usize) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn posix_memalign( + __memptr: *mut *mut ::std::os::raw::c_void, + __alignment: usize, + __size: usize, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn aligned_alloc(__alignment: usize, __size: usize) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn abort() -> !; +} +extern "C" { + pub fn atexit(__func: ::std::option::Option) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn at_quick_exit( + __func: ::std::option::Option, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn on_exit( + __func: ::std::option::Option< + unsafe extern "C" fn( + __status: ::std::os::raw::c_int, + __arg: *mut ::std::os::raw::c_void, + ), + >, + __arg: *mut ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn exit(__status: ::std::os::raw::c_int) -> !; +} +extern "C" { + pub fn quick_exit(__status: ::std::os::raw::c_int) -> !; +} +extern "C" { + pub fn _Exit(__status: ::std::os::raw::c_int) -> !; +} +extern "C" { + pub fn getenv(__name: *const ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn putenv(__string: *mut ::std::os::raw::c_char) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn setenv( + __name: *const ::std::os::raw::c_char, + __value: *const ::std::os::raw::c_char, + __replace: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn unsetenv(__name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clearenv() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn mktemp(__template: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn mkstemp(__template: *mut ::std::os::raw::c_char) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn mkstemps( + __template: *mut ::std::os::raw::c_char, + __suffixlen: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn mkdtemp(__template: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn system(__command: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn realpath( + __name: *const ::std::os::raw::c_char, + __resolved: *mut ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_char; +} +pub type __compar_fn_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: *const ::std::os::raw::c_void, + arg2: *const ::std::os::raw::c_void, + ) -> ::std::os::raw::c_int, +>; +extern "C" { + pub fn bsearch( + __key: *const ::std::os::raw::c_void, + __base: *const ::std::os::raw::c_void, + __nmemb: usize, + __size: usize, + __compar: __compar_fn_t, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn qsort( + __base: *mut ::std::os::raw::c_void, + __nmemb: usize, + __size: usize, + __compar: __compar_fn_t, + ); +} +extern "C" { + pub fn abs(__x: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn labs(__x: ::std::os::raw::c_long) -> ::std::os::raw::c_long; +} +extern "C" { + pub fn llabs(__x: ::std::os::raw::c_longlong) -> ::std::os::raw::c_longlong; +} +extern "C" { + pub fn div(__numer: ::std::os::raw::c_int, __denom: ::std::os::raw::c_int) -> div_t; +} +extern "C" { + pub fn ldiv(__numer: ::std::os::raw::c_long, __denom: ::std::os::raw::c_long) -> ldiv_t; +} +extern "C" { + pub fn lldiv( + __numer: ::std::os::raw::c_longlong, + __denom: ::std::os::raw::c_longlong, + ) -> lldiv_t; +} +extern "C" { + pub fn ecvt( + __value: f64, + __ndigit: ::std::os::raw::c_int, + __decpt: *mut ::std::os::raw::c_int, + __sign: *mut ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn fcvt( + __value: f64, + __ndigit: ::std::os::raw::c_int, + __decpt: *mut ::std::os::raw::c_int, + __sign: *mut ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn gcvt( + __value: f64, + __ndigit: ::std::os::raw::c_int, + __buf: *mut ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn ecvt_r( + __value: f64, + __ndigit: ::std::os::raw::c_int, + __decpt: *mut ::std::os::raw::c_int, + __sign: *mut ::std::os::raw::c_int, + __buf: *mut ::std::os::raw::c_char, + __len: usize, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fcvt_r( + __value: f64, + __ndigit: ::std::os::raw::c_int, + __decpt: *mut ::std::os::raw::c_int, + __sign: *mut ::std::os::raw::c_int, + __buf: *mut ::std::os::raw::c_char, + __len: usize, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn mblen(__s: *const ::std::os::raw::c_char, __n: usize) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn mbtowc( + __pwc: *mut wchar_t, + __s: *const ::std::os::raw::c_char, + __n: usize, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn wctomb(__s: *mut ::std::os::raw::c_char, __wchar: wchar_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn mbstowcs(__pwcs: *mut wchar_t, __s: *const ::std::os::raw::c_char, __n: usize) -> usize; +} +extern "C" { + pub fn wcstombs(__s: *mut ::std::os::raw::c_char, __pwcs: *const wchar_t, __n: usize) -> usize; +} +extern "C" { + pub fn rpmatch(__response: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getsubopt( + __optionp: *mut *mut ::std::os::raw::c_char, + __tokens: *const *mut ::std::os::raw::c_char, + __valuep: *mut *mut ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getloadavg(__loadavg: *mut f64, __nelem: ::std::os::raw::c_int) + -> ::std::os::raw::c_int; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _attributes_t { + pub flags: u64, + pub xfrm: u64, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _attributes_t"][::std::mem::size_of::<_attributes_t>() - 16usize]; + ["Alignment of _attributes_t"][::std::mem::align_of::<_attributes_t>() - 8usize]; + ["Offset of field: _attributes_t::flags"] + [::std::mem::offset_of!(_attributes_t, flags) - 0usize]; + ["Offset of field: _attributes_t::xfrm"][::std::mem::offset_of!(_attributes_t, xfrm) - 8usize]; +}; +pub type sgx_attributes_t = _attributes_t; +pub type sgx_misc_select_t = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _sgx_misc_attribute_t { + pub secs_attr: sgx_attributes_t, + pub misc_select: sgx_misc_select_t, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _sgx_misc_attribute_t"][::std::mem::size_of::<_sgx_misc_attribute_t>() - 24usize]; + ["Alignment of _sgx_misc_attribute_t"] + [::std::mem::align_of::<_sgx_misc_attribute_t>() - 8usize]; + ["Offset of field: _sgx_misc_attribute_t::secs_attr"] + [::std::mem::offset_of!(_sgx_misc_attribute_t, secs_attr) - 0usize]; + ["Offset of field: _sgx_misc_attribute_t::misc_select"] + [::std::mem::offset_of!(_sgx_misc_attribute_t, misc_select) - 16usize]; +}; +pub type sgx_misc_attribute_t = _sgx_misc_attribute_t; +pub type sgx_key_128bit_t = [u8; 16usize]; +pub type sgx_isv_svn_t = u16; +pub type sgx_config_svn_t = u16; +pub type sgx_config_id_t = [u8; 64usize]; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _sgx_cpu_svn_t { + pub svn: [u8; 16usize], +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _sgx_cpu_svn_t"][::std::mem::size_of::<_sgx_cpu_svn_t>() - 16usize]; + ["Alignment of _sgx_cpu_svn_t"][::std::mem::align_of::<_sgx_cpu_svn_t>() - 1usize]; + ["Offset of field: _sgx_cpu_svn_t::svn"][::std::mem::offset_of!(_sgx_cpu_svn_t, svn) - 0usize]; +}; +pub type sgx_cpu_svn_t = _sgx_cpu_svn_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _sgx_key_id_t { + pub id: [u8; 32usize], +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _sgx_key_id_t"][::std::mem::size_of::<_sgx_key_id_t>() - 32usize]; + ["Alignment of _sgx_key_id_t"][::std::mem::align_of::<_sgx_key_id_t>() - 1usize]; + ["Offset of field: _sgx_key_id_t::id"][::std::mem::offset_of!(_sgx_key_id_t, id) - 0usize]; +}; +pub type sgx_key_id_t = _sgx_key_id_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _key_request_t { + pub key_name: u16, + pub key_policy: u16, + pub isv_svn: sgx_isv_svn_t, + pub reserved1: u16, + pub cpu_svn: sgx_cpu_svn_t, + pub attribute_mask: sgx_attributes_t, + pub key_id: sgx_key_id_t, + pub misc_mask: sgx_misc_select_t, + pub config_svn: sgx_config_svn_t, + pub reserved2: [u8; 434usize], +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _key_request_t"][::std::mem::size_of::<_key_request_t>() - 512usize]; + ["Alignment of _key_request_t"][::std::mem::align_of::<_key_request_t>() - 8usize]; + ["Offset of field: _key_request_t::key_name"] + [::std::mem::offset_of!(_key_request_t, key_name) - 0usize]; + ["Offset of field: _key_request_t::key_policy"] + [::std::mem::offset_of!(_key_request_t, key_policy) - 2usize]; + ["Offset of field: _key_request_t::isv_svn"] + [::std::mem::offset_of!(_key_request_t, isv_svn) - 4usize]; + ["Offset of field: _key_request_t::reserved1"] + [::std::mem::offset_of!(_key_request_t, reserved1) - 6usize]; + ["Offset of field: _key_request_t::cpu_svn"] + [::std::mem::offset_of!(_key_request_t, cpu_svn) - 8usize]; + ["Offset of field: _key_request_t::attribute_mask"] + [::std::mem::offset_of!(_key_request_t, attribute_mask) - 24usize]; + ["Offset of field: _key_request_t::key_id"] + [::std::mem::offset_of!(_key_request_t, key_id) - 40usize]; + ["Offset of field: _key_request_t::misc_mask"] + [::std::mem::offset_of!(_key_request_t, misc_mask) - 72usize]; + ["Offset of field: _key_request_t::config_svn"] + [::std::mem::offset_of!(_key_request_t, config_svn) - 76usize]; + ["Offset of field: _key_request_t::reserved2"] + [::std::mem::offset_of!(_key_request_t, reserved2) - 78usize]; +}; +pub type sgx_key_request_t = _key_request_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _sgx_measurement_t { + pub m: [u8; 32usize], +} +impl From<[u8; 32usize]> for _sgx_measurement_t { + fn from(array: [u8; 32usize]) -> Self { + Self { m: array } + } +} +impl From<_sgx_measurement_t> for [u8; 32usize] { + fn from(struct_: _sgx_measurement_t) -> Self { + struct_.m + } +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _sgx_measurement_t"][::std::mem::size_of::<_sgx_measurement_t>() - 32usize]; + ["Alignment of _sgx_measurement_t"][::std::mem::align_of::<_sgx_measurement_t>() - 1usize]; + ["Offset of field: _sgx_measurement_t::m"] + [::std::mem::offset_of!(_sgx_measurement_t, m) - 0usize]; +}; +pub type sgx_measurement_t = _sgx_measurement_t; +pub type sgx_mac_t = [u8; 16usize]; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _sgx_report_data_t { + pub d: [u8; 64usize], +} +impl From<[u8; 64usize]> for _sgx_report_data_t { + fn from(array: [u8; 64usize]) -> Self { + Self { d: array } + } +} +impl From<_sgx_report_data_t> for [u8; 64usize] { + fn from(struct_: _sgx_report_data_t) -> Self { + struct_.d + } +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _sgx_report_data_t"][::std::mem::size_of::<_sgx_report_data_t>() - 64usize]; + ["Alignment of _sgx_report_data_t"][::std::mem::align_of::<_sgx_report_data_t>() - 1usize]; + ["Offset of field: _sgx_report_data_t::d"] + [::std::mem::offset_of!(_sgx_report_data_t, d) - 0usize]; +}; +pub type sgx_report_data_t = _sgx_report_data_t; +pub type sgx_prod_id_t = u16; +pub type sgx_isvext_prod_id_t = [u8; 16usize]; +pub type sgx_isvfamily_id_t = [u8; 16usize]; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _target_info_t { + pub mr_enclave: sgx_measurement_t, + pub attributes: sgx_attributes_t, + pub reserved1: [u8; 2usize], + pub config_svn: sgx_config_svn_t, + pub misc_select: sgx_misc_select_t, + pub reserved2: [u8; 8usize], + pub config_id: sgx_config_id_t, + pub reserved3: [u8; 384usize], +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _target_info_t"][::std::mem::size_of::<_target_info_t>() - 512usize]; + ["Alignment of _target_info_t"][::std::mem::align_of::<_target_info_t>() - 8usize]; + ["Offset of field: _target_info_t::mr_enclave"] + [::std::mem::offset_of!(_target_info_t, mr_enclave) - 0usize]; + ["Offset of field: _target_info_t::attributes"] + [::std::mem::offset_of!(_target_info_t, attributes) - 32usize]; + ["Offset of field: _target_info_t::reserved1"] + [::std::mem::offset_of!(_target_info_t, reserved1) - 48usize]; + ["Offset of field: _target_info_t::config_svn"] + [::std::mem::offset_of!(_target_info_t, config_svn) - 50usize]; + ["Offset of field: _target_info_t::misc_select"] + [::std::mem::offset_of!(_target_info_t, misc_select) - 52usize]; + ["Offset of field: _target_info_t::reserved2"] + [::std::mem::offset_of!(_target_info_t, reserved2) - 56usize]; + ["Offset of field: _target_info_t::config_id"] + [::std::mem::offset_of!(_target_info_t, config_id) - 64usize]; + ["Offset of field: _target_info_t::reserved3"] + [::std::mem::offset_of!(_target_info_t, reserved3) - 128usize]; +}; +pub type sgx_target_info_t = _target_info_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _report_body_t { + pub cpu_svn: sgx_cpu_svn_t, + pub misc_select: sgx_misc_select_t, + pub reserved1: [u8; 12usize], + pub isv_ext_prod_id: sgx_isvext_prod_id_t, + pub attributes: sgx_attributes_t, + pub mr_enclave: sgx_measurement_t, + pub reserved2: [u8; 32usize], + pub mr_signer: sgx_measurement_t, + pub reserved3: [u8; 32usize], + pub config_id: sgx_config_id_t, + pub isv_prod_id: sgx_prod_id_t, + pub isv_svn: sgx_isv_svn_t, + pub config_svn: sgx_config_svn_t, + pub reserved4: [u8; 42usize], + pub isv_family_id: sgx_isvfamily_id_t, + pub report_data: sgx_report_data_t, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _report_body_t"][::std::mem::size_of::<_report_body_t>() - 384usize]; + ["Alignment of _report_body_t"][::std::mem::align_of::<_report_body_t>() - 8usize]; + ["Offset of field: _report_body_t::cpu_svn"] + [::std::mem::offset_of!(_report_body_t, cpu_svn) - 0usize]; + ["Offset of field: _report_body_t::misc_select"] + [::std::mem::offset_of!(_report_body_t, misc_select) - 16usize]; + ["Offset of field: _report_body_t::reserved1"] + [::std::mem::offset_of!(_report_body_t, reserved1) - 20usize]; + ["Offset of field: _report_body_t::isv_ext_prod_id"] + [::std::mem::offset_of!(_report_body_t, isv_ext_prod_id) - 32usize]; + ["Offset of field: _report_body_t::attributes"] + [::std::mem::offset_of!(_report_body_t, attributes) - 48usize]; + ["Offset of field: _report_body_t::mr_enclave"] + [::std::mem::offset_of!(_report_body_t, mr_enclave) - 64usize]; + ["Offset of field: _report_body_t::reserved2"] + [::std::mem::offset_of!(_report_body_t, reserved2) - 96usize]; + ["Offset of field: _report_body_t::mr_signer"] + [::std::mem::offset_of!(_report_body_t, mr_signer) - 128usize]; + ["Offset of field: _report_body_t::reserved3"] + [::std::mem::offset_of!(_report_body_t, reserved3) - 160usize]; + ["Offset of field: _report_body_t::config_id"] + [::std::mem::offset_of!(_report_body_t, config_id) - 192usize]; + ["Offset of field: _report_body_t::isv_prod_id"] + [::std::mem::offset_of!(_report_body_t, isv_prod_id) - 256usize]; + ["Offset of field: _report_body_t::isv_svn"] + [::std::mem::offset_of!(_report_body_t, isv_svn) - 258usize]; + ["Offset of field: _report_body_t::config_svn"] + [::std::mem::offset_of!(_report_body_t, config_svn) - 260usize]; + ["Offset of field: _report_body_t::reserved4"] + [::std::mem::offset_of!(_report_body_t, reserved4) - 262usize]; + ["Offset of field: _report_body_t::isv_family_id"] + [::std::mem::offset_of!(_report_body_t, isv_family_id) - 304usize]; + ["Offset of field: _report_body_t::report_data"] + [::std::mem::offset_of!(_report_body_t, report_data) - 320usize]; +}; +pub type sgx_report_body_t = _report_body_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _report_t { + pub body: sgx_report_body_t, + pub key_id: sgx_key_id_t, + pub mac: sgx_mac_t, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _report_t"][::std::mem::size_of::<_report_t>() - 432usize]; + ["Alignment of _report_t"][::std::mem::align_of::<_report_t>() - 8usize]; + ["Offset of field: _report_t::body"][::std::mem::offset_of!(_report_t, body) - 0usize]; + ["Offset of field: _report_t::key_id"][::std::mem::offset_of!(_report_t, key_id) - 384usize]; + ["Offset of field: _report_t::mac"][::std::mem::offset_of!(_report_t, mac) - 416usize]; +}; +pub type sgx_report_t = _report_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct tm { + pub tm_sec: ::std::os::raw::c_int, + pub tm_min: ::std::os::raw::c_int, + pub tm_hour: ::std::os::raw::c_int, + pub tm_mday: ::std::os::raw::c_int, + pub tm_mon: ::std::os::raw::c_int, + pub tm_year: ::std::os::raw::c_int, + pub tm_wday: ::std::os::raw::c_int, + pub tm_yday: ::std::os::raw::c_int, + pub tm_isdst: ::std::os::raw::c_int, + pub tm_gmtoff: ::std::os::raw::c_long, + pub tm_zone: *const ::std::os::raw::c_char, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of tm"][::std::mem::size_of::() - 56usize]; + ["Alignment of tm"][::std::mem::align_of::() - 8usize]; + ["Offset of field: tm::tm_sec"][::std::mem::offset_of!(tm, tm_sec) - 0usize]; + ["Offset of field: tm::tm_min"][::std::mem::offset_of!(tm, tm_min) - 4usize]; + ["Offset of field: tm::tm_hour"][::std::mem::offset_of!(tm, tm_hour) - 8usize]; + ["Offset of field: tm::tm_mday"][::std::mem::offset_of!(tm, tm_mday) - 12usize]; + ["Offset of field: tm::tm_mon"][::std::mem::offset_of!(tm, tm_mon) - 16usize]; + ["Offset of field: tm::tm_year"][::std::mem::offset_of!(tm, tm_year) - 20usize]; + ["Offset of field: tm::tm_wday"][::std::mem::offset_of!(tm, tm_wday) - 24usize]; + ["Offset of field: tm::tm_yday"][::std::mem::offset_of!(tm, tm_yday) - 28usize]; + ["Offset of field: tm::tm_isdst"][::std::mem::offset_of!(tm, tm_isdst) - 32usize]; + ["Offset of field: tm::tm_gmtoff"][::std::mem::offset_of!(tm, tm_gmtoff) - 40usize]; + ["Offset of field: tm::tm_zone"][::std::mem::offset_of!(tm, tm_zone) - 48usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct itimerspec { + pub it_interval: timespec, + pub it_value: timespec, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of itimerspec"][::std::mem::size_of::() - 32usize]; + ["Alignment of itimerspec"][::std::mem::align_of::() - 8usize]; + ["Offset of field: itimerspec::it_interval"] + [::std::mem::offset_of!(itimerspec, it_interval) - 0usize]; + ["Offset of field: itimerspec::it_value"] + [::std::mem::offset_of!(itimerspec, it_value) - 16usize]; +}; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sigevent { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __locale_struct { + pub __locales: [*mut __locale_data; 13usize], + pub __ctype_b: *const ::std::os::raw::c_ushort, + pub __ctype_tolower: *const ::std::os::raw::c_int, + pub __ctype_toupper: *const ::std::os::raw::c_int, + pub __names: [*const ::std::os::raw::c_char; 13usize], +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of __locale_struct"][::std::mem::size_of::<__locale_struct>() - 232usize]; + ["Alignment of __locale_struct"][::std::mem::align_of::<__locale_struct>() - 8usize]; + ["Offset of field: __locale_struct::__locales"] + [::std::mem::offset_of!(__locale_struct, __locales) - 0usize]; + ["Offset of field: __locale_struct::__ctype_b"] + [::std::mem::offset_of!(__locale_struct, __ctype_b) - 104usize]; + ["Offset of field: __locale_struct::__ctype_tolower"] + [::std::mem::offset_of!(__locale_struct, __ctype_tolower) - 112usize]; + ["Offset of field: __locale_struct::__ctype_toupper"] + [::std::mem::offset_of!(__locale_struct, __ctype_toupper) - 120usize]; + ["Offset of field: __locale_struct::__names"] + [::std::mem::offset_of!(__locale_struct, __names) - 128usize]; +}; +pub type __locale_t = *mut __locale_struct; +pub type locale_t = __locale_t; +extern "C" { + pub fn clock() -> clock_t; +} +extern "C" { + pub fn time(__timer: *mut time_t) -> time_t; +} +extern "C" { + pub fn difftime(__time1: time_t, __time0: time_t) -> f64; +} +extern "C" { + pub fn mktime(__tp: *mut tm) -> time_t; +} +extern "C" { + pub fn strftime( + __s: *mut ::std::os::raw::c_char, + __maxsize: usize, + __format: *const ::std::os::raw::c_char, + __tp: *const tm, + ) -> usize; +} +extern "C" { + pub fn strftime_l( + __s: *mut ::std::os::raw::c_char, + __maxsize: usize, + __format: *const ::std::os::raw::c_char, + __tp: *const tm, + __loc: locale_t, + ) -> usize; +} +extern "C" { + pub fn gmtime(__timer: *const time_t) -> *mut tm; +} +extern "C" { + pub fn localtime(__timer: *const time_t) -> *mut tm; +} +extern "C" { + pub fn gmtime_r(__timer: *const time_t, __tp: *mut tm) -> *mut tm; +} +extern "C" { + pub fn localtime_r(__timer: *const time_t, __tp: *mut tm) -> *mut tm; +} +extern "C" { + pub fn asctime(__tp: *const tm) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn ctime(__timer: *const time_t) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn asctime_r( + __tp: *const tm, + __buf: *mut ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn ctime_r( + __timer: *const time_t, + __buf: *mut ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub static mut __tzname: [*mut ::std::os::raw::c_char; 2usize]; +} +extern "C" { + pub static mut __daylight: ::std::os::raw::c_int; +} +extern "C" { + pub static mut __timezone: ::std::os::raw::c_long; +} +extern "C" { + pub static mut tzname: [*mut ::std::os::raw::c_char; 2usize]; +} +extern "C" { + pub fn tzset(); +} +extern "C" { + pub static mut daylight: ::std::os::raw::c_int; +} +extern "C" { + pub static mut timezone: ::std::os::raw::c_long; +} +extern "C" { + pub fn timegm(__tp: *mut tm) -> time_t; +} +extern "C" { + pub fn timelocal(__tp: *mut tm) -> time_t; +} +extern "C" { + pub fn dysize(__year: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn nanosleep( + __requested_time: *const timespec, + __remaining: *mut timespec, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clock_getres(__clock_id: clockid_t, __res: *mut timespec) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clock_gettime(__clock_id: clockid_t, __tp: *mut timespec) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clock_settime(__clock_id: clockid_t, __tp: *const timespec) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clock_nanosleep( + __clock_id: clockid_t, + __flags: ::std::os::raw::c_int, + __req: *const timespec, + __rem: *mut timespec, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clock_getcpuclockid(__pid: pid_t, __clock_id: *mut clockid_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn timer_create( + __clock_id: clockid_t, + __evp: *mut sigevent, + __timerid: *mut timer_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn timer_delete(__timerid: timer_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn timer_settime( + __timerid: timer_t, + __flags: ::std::os::raw::c_int, + __value: *const itimerspec, + __ovalue: *mut itimerspec, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn timer_gettime(__timerid: timer_t, __value: *mut itimerspec) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn timer_getoverrun(__timerid: timer_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn timespec_get( + __ts: *mut timespec, + __base: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +pub const SGX_QL_QV_RESULT_OK: _sgx_ql_qv_result_t = 0; +pub const SGX_QL_QV_RESULT_MIN: _sgx_ql_qv_result_t = 40961; +pub const SGX_QL_QV_RESULT_CONFIG_NEEDED: _sgx_ql_qv_result_t = 40961; +pub const SGX_QL_QV_RESULT_OUT_OF_DATE: _sgx_ql_qv_result_t = 40962; +pub const SGX_QL_QV_RESULT_OUT_OF_DATE_CONFIG_NEEDED: _sgx_ql_qv_result_t = 40963; +pub const SGX_QL_QV_RESULT_INVALID_SIGNATURE: _sgx_ql_qv_result_t = 40964; +pub const SGX_QL_QV_RESULT_REVOKED: _sgx_ql_qv_result_t = 40965; +pub const SGX_QL_QV_RESULT_UNSPECIFIED: _sgx_ql_qv_result_t = 40966; +pub const SGX_QL_QV_RESULT_SW_HARDENING_NEEDED: _sgx_ql_qv_result_t = 40967; +pub const SGX_QL_QV_RESULT_CONFIG_AND_SW_HARDENING_NEEDED: _sgx_ql_qv_result_t = 40968; +pub const SGX_QL_QV_RESULT_MAX: _sgx_ql_qv_result_t = 41215; +pub type _sgx_ql_qv_result_t = ::std::os::raw::c_uint; +pub use self::_sgx_ql_qv_result_t as sgx_ql_qv_result_t; +pub const _pck_cert_flag_enum_t_PCK_FLAG_FALSE: _pck_cert_flag_enum_t = 0; +pub const _pck_cert_flag_enum_t_PCK_FLAG_TRUE: _pck_cert_flag_enum_t = 1; +pub const _pck_cert_flag_enum_t_PCK_FLAG_UNDEFINED: _pck_cert_flag_enum_t = 2; +pub type _pck_cert_flag_enum_t = ::std::os::raw::c_uint; +pub use self::_pck_cert_flag_enum_t as pck_cert_flag_enum_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _sgx_ql_qv_supplemental_t { + pub __bindgen_anon_1: _sgx_ql_qv_supplemental_t__bindgen_ty_1, + pub earliest_issue_date: time_t, + pub latest_issue_date: time_t, + pub earliest_expiration_date: time_t, + pub tcb_level_date_tag: time_t, + pub pck_crl_num: u32, + pub root_ca_crl_num: u32, + pub tcb_eval_ref_num: u32, + pub root_key_id: [u8; 48usize], + pub pck_ppid: sgx_key_128bit_t, + pub tcb_cpusvn: sgx_cpu_svn_t, + pub tcb_pce_isvsvn: sgx_isv_svn_t, + pub pce_id: u16, + pub tee_type: u32, + pub sgx_type: u8, + pub platform_instance_id: [u8; 16usize], + pub dynamic_platform: pck_cert_flag_enum_t, + pub cached_keys: pck_cert_flag_enum_t, + pub smt_enabled: pck_cert_flag_enum_t, + pub sa_list: [::std::os::raw::c_char; 320usize], +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _sgx_ql_qv_supplemental_t__bindgen_ty_1 { + pub version: u32, + pub __bindgen_anon_1: _sgx_ql_qv_supplemental_t__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _sgx_ql_qv_supplemental_t__bindgen_ty_1__bindgen_ty_1 { + pub major_version: u16, + pub minor_version: u16, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _sgx_ql_qv_supplemental_t__bindgen_ty_1__bindgen_ty_1"] + [::std::mem::size_of::<_sgx_ql_qv_supplemental_t__bindgen_ty_1__bindgen_ty_1>() - 4usize]; + ["Alignment of _sgx_ql_qv_supplemental_t__bindgen_ty_1__bindgen_ty_1"] + [::std::mem::align_of::<_sgx_ql_qv_supplemental_t__bindgen_ty_1__bindgen_ty_1>() - 2usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t__bindgen_ty_1__bindgen_ty_1::major_version"][::std::mem::offset_of!( + _sgx_ql_qv_supplemental_t__bindgen_ty_1__bindgen_ty_1, + major_version + ) + - 0usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t__bindgen_ty_1__bindgen_ty_1::minor_version"][::std::mem::offset_of!( + _sgx_ql_qv_supplemental_t__bindgen_ty_1__bindgen_ty_1, + minor_version + ) + - 2usize]; +}; +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _sgx_ql_qv_supplemental_t__bindgen_ty_1"] + [::std::mem::size_of::<_sgx_ql_qv_supplemental_t__bindgen_ty_1>() - 4usize]; + ["Alignment of _sgx_ql_qv_supplemental_t__bindgen_ty_1"] + [::std::mem::align_of::<_sgx_ql_qv_supplemental_t__bindgen_ty_1>() - 4usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t__bindgen_ty_1::version"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t__bindgen_ty_1, version) - 0usize]; +}; +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _sgx_ql_qv_supplemental_t"] + [::std::mem::size_of::<_sgx_ql_qv_supplemental_t>() - 496usize]; + ["Alignment of _sgx_ql_qv_supplemental_t"] + [::std::mem::align_of::<_sgx_ql_qv_supplemental_t>() - 8usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::earliest_issue_date"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, earliest_issue_date) - 8usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::latest_issue_date"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, latest_issue_date) - 16usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::earliest_expiration_date"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, earliest_expiration_date) - 24usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::tcb_level_date_tag"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, tcb_level_date_tag) - 32usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::pck_crl_num"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, pck_crl_num) - 40usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::root_ca_crl_num"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, root_ca_crl_num) - 44usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::tcb_eval_ref_num"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, tcb_eval_ref_num) - 48usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::root_key_id"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, root_key_id) - 52usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::pck_ppid"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, pck_ppid) - 100usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::tcb_cpusvn"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, tcb_cpusvn) - 116usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::tcb_pce_isvsvn"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, tcb_pce_isvsvn) - 132usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::pce_id"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, pce_id) - 134usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::tee_type"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, tee_type) - 136usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::sgx_type"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, sgx_type) - 140usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::platform_instance_id"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, platform_instance_id) - 141usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::dynamic_platform"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, dynamic_platform) - 160usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::cached_keys"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, cached_keys) - 164usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::smt_enabled"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, smt_enabled) - 168usize]; + ["Offset of field: _sgx_ql_qv_supplemental_t::sa_list"] + [::std::mem::offset_of!(_sgx_ql_qv_supplemental_t, sa_list) - 172usize]; +}; +pub type sgx_ql_qv_supplemental_t = _sgx_ql_qv_supplemental_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _tee_supp_data_descriptor_t { + pub major_version: u16, + pub data_size: u32, + pub p_data: *mut u8, +} +#[allow(clippy::unnecessary_operation, clippy::identity_op)] +const _: () = { + ["Size of _tee_supp_data_descriptor_t"] + [::std::mem::size_of::<_tee_supp_data_descriptor_t>() - 16usize]; + ["Alignment of _tee_supp_data_descriptor_t"] + [::std::mem::align_of::<_tee_supp_data_descriptor_t>() - 8usize]; + ["Offset of field: _tee_supp_data_descriptor_t::major_version"] + [::std::mem::offset_of!(_tee_supp_data_descriptor_t, major_version) - 0usize]; + ["Offset of field: _tee_supp_data_descriptor_t::data_size"] + [::std::mem::offset_of!(_tee_supp_data_descriptor_t, data_size) - 4usize]; + ["Offset of field: _tee_supp_data_descriptor_t::p_data"] + [::std::mem::offset_of!(_tee_supp_data_descriptor_t, p_data) - 8usize]; +}; +pub type tee_supp_data_descriptor_t = _tee_supp_data_descriptor_t; +extern "C" { + pub fn dcap_quote_open() -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn dcap_get_quote_size(handle: *mut ::std::os::raw::c_void) -> u32; +} +extern "C" { + pub fn dcap_generate_quote( + handle: *mut ::std::os::raw::c_void, + quote_buf: *mut u8, + report_data: *const sgx_report_data_t, + ) -> i32; +} +extern "C" { + pub fn dcap_get_supplemental_data_size(handle: *mut ::std::os::raw::c_void) -> u32; +} +extern "C" { + pub fn dcap_verify_quote( + handle: *mut ::std::os::raw::c_void, + quote_buf: *const u8, + quote_size: u32, + collateral_expiration_status: *mut u32, + quote_verification_result: *mut sgx_ql_qv_result_t, + supplemental_data_size: u32, + supplemental_data: *mut u8, + ) -> i32; +} +extern "C" { + pub fn dcap_quote_close(handle: *mut ::std::os::raw::c_void); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct __locale_data { + pub _address: u8, +} diff --git a/src/config.rs b/src/config.rs index e4f8e89..015de9a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,13 +1,12 @@ use crate::{RaTlsConfigBuilder, RaTlsError}; #[cfg(feature = "occlum")] -use occlum_sgx::SGXQuote; +use crate::quote::Quote; -// FIXME: this only suppresses the warnings -#[allow(unused_imports)] -pub use occlum_sgx::SGXMeasurement; use rustls::{ClientConfig, ServerConfig}; +pub type Measurement = [u8; 32]; + #[derive(Default, Debug)] pub struct RaTlsConfig { #[cfg(feature = "occlum")] @@ -17,8 +16,8 @@ pub struct RaTlsConfig { #[cfg(feature = "occlum")] #[derive(Default, Debug, Clone)] pub struct InstanceMeasurement { - pub(crate) mrsigners: Option>, - pub(crate) mrenclaves: Option>, + pub(crate) mrsigners: Option>, + pub(crate) mrenclaves: Option>, pub(crate) product_ids: Option>, pub(crate) versions: Option>, } @@ -29,14 +28,14 @@ impl InstanceMeasurement { Self::default() } - pub fn with_mrsigners(self, mrsigners: Vec) -> Self { + pub fn with_mrsigners(self, mrsigners: Vec) -> Self { Self { mrsigners: Some(mrsigners), ..self } } - pub fn with_mrenclaves(self, mrenclaves: Vec) -> Self { + pub fn with_mrenclaves(self, mrenclaves: Vec) -> Self { Self { mrenclaves: Some(mrenclaves), ..self @@ -57,18 +56,18 @@ impl InstanceMeasurement { } } - pub(crate) fn check_quote_measurements(&self, quote: &SGXQuote) -> bool { + pub(crate) fn check_quote_measurements(&self, quote: &Quote) -> bool { let mut result = false; if let Some(mrsigners) = &self.mrsigners { result = true; - let value = quote.mrsigner(); + let value = quote.mrsigner().into(); if !mrsigners.contains(&value) { return false; } } if let Some(mrenclaves) = &self.mrenclaves { result = true; - let value = quote.mrenclave(); + let value = quote.mrenclave().into(); if !mrenclaves.contains(&value) { return false; } @@ -76,7 +75,7 @@ impl InstanceMeasurement { if let Some(product_ids) = &self.product_ids { result = true; - let value = quote.product_id(); + let value = quote.product_id().into(); if !product_ids.contains(&value) { return false; } @@ -84,7 +83,7 @@ impl InstanceMeasurement { if let Some(versions) = &self.versions { result = true; - let value = quote.version(); + let value = quote.version().into(); if !versions.contains(&value) { return false; } @@ -106,14 +105,14 @@ impl RaTlsConfig { } #[cfg(feature = "occlum")] - pub(crate) fn is_allowed_quote(&self, quote: &SGXQuote) -> Result<(), RaTlsError> { + pub(crate) fn is_allowed_quote(&self, quote: &Quote) -> Result<(), RaTlsError> { match self .allowed_instances .iter() .any(|im| im.check_quote_measurements(quote)) { true => Ok(()), - false => Err(RaTlsError::QuoteVerifyError(format!( + false => Err(RaTlsError::QuoteError(format!( "{:?} is not allowed", quote ))), diff --git a/src/error.rs b/src/error.rs index 4d1811f..68d790d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -3,7 +3,8 @@ use std::{error::Error, fmt::Display}; #[derive(Debug)] pub enum RaTlsError { CertificateBuildError(String), - QuoteVerifyError(String), + QuoteError(String), + DcapError(String), } impl Display for RaTlsError { @@ -12,7 +13,8 @@ impl Display for RaTlsError { RaTlsError::CertificateBuildError(ref message) => { write!(f, "CertificateBuildError: {}", message) } - RaTlsError::QuoteVerifyError(ref message) => write!(f, "QuoteVerifyError: {}", message), + RaTlsError::QuoteError(ref message) => write!(f, "QuoteVerifyError: {}", message), + RaTlsError::DcapError(ref message) => write!(f, "DcapError: {}", message), } } } diff --git a/src/lib.rs b/src/lib.rs index d34889d..6595312 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,13 +1,17 @@ -mod racert; mod client; mod config; mod error; mod http; +mod racert; mod server; #[cfg(feature = "occlum")] mod utils; +#[cfg(feature = "occlum")] +mod bindings; pub mod prelude; +#[cfg(feature = "occlum")] +mod quote; //mod sscert; pub use crate::config::RaTlsConfig; diff --git a/src/prelude.rs b/src/prelude.rs index cd0c335..c09960d 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1,8 +1,7 @@ pub use crate::RaTlsConfig; -pub use crate::SGXMeasurement; #[cfg(feature = "occlum")] -pub use crate::InstanceMeasurement; +pub use crate::config::InstanceMeasurement; #[cfg(feature = "reqwest")] pub use crate::reqwest::ReqwestUseRatls; diff --git a/src/quote.rs b/src/quote.rs new file mode 100644 index 0000000..6b2e8e0 --- /dev/null +++ b/src/quote.rs @@ -0,0 +1,334 @@ +use crate::bindings::*; +use crate::error::RaTlsError; +use lazy_static::lazy_static; +use log::{trace, warn}; +use std::fmt::Debug; +use std::ops::Deref; +use std::sync::Mutex; +use std::time::Instant; + +pub struct Quote { + buf: Vec, + report_body: *const sgx_report_body_t, +} + +impl TryFrom> for Quote { + type Error = RaTlsError; + fn try_from(buf: Vec) -> Result { + let report_body_offset = size_of::(); + let report_body_size = size_of::(); + + if buf.len() < report_body_offset + report_body_size { + let minimal = report_body_offset + report_body_size; + let actual = buf.len(); + return Err(RaTlsError::QuoteError(format!( + "Failed to parse DCAP quote, min {minimal}, act {actual}" + ))); + } + + let report_body = buf.as_slice()[report_body_offset..].as_ptr() as *const sgx_report_body_t; + + Ok(Self { buf, report_body }) + } +} + +#[repr(C)] +struct QuoteHeader { + pub version: u16, + pub att_key_type: u16, + pub att_key_data_0: u32, + pub qe_svn: u16, + pub pce_svn: u16, + pub vendor_id: [u8; 16], + pub user_data: [u8; 20], +} + +impl TryFrom<&[u8]> for Quote { + type Error = RaTlsError; + + fn try_from(buf: &[u8]) -> Result { + buf.to_vec().try_into() + } +} + +impl TryFrom for Quote { + type Error = RaTlsError; + + fn try_from(value: ReportData) -> Result { + Self::from_report_data(value) + } +} + +impl Deref for Quote { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.buf.as_ref() + } +} + +impl Quote { + pub fn from_report_data(data: ReportData) -> Result { + IOCTL_CLIENT + .lock() + .unwrap() + .generate_quote(data)? + .try_into() + } + + pub fn from_slice(slice: &[u8]) -> Result { + slice.try_into() + } + + pub fn as_slice(&self) -> &[u8] { + self + } + + pub fn verify(&self) -> Result { + IOCTL_CLIENT.lock().unwrap().verify_quote(self.buf.as_ref()) + } + + pub fn isv_family_id(&self) -> sgx_isvfamily_id_t { + unsafe { (*self.report_body).isv_family_id } + } + + pub fn isv_ext_prod_id(&self) -> sgx_isvext_prod_id_t { + unsafe { (*self.report_body).isv_ext_prod_id } + } + + pub fn config_id(&self) -> sgx_config_id_t { + unsafe { (*self.report_body).config_id } + } + + pub fn mrenclave(&self) -> sgx_measurement_t { + unsafe { (*self.report_body).mr_enclave } + } + + pub fn mrsigner(&self) -> sgx_measurement_t { + unsafe { (*self.report_body).mr_signer } + } + + pub fn product_id(&self) -> sgx_prod_id_t { + unsafe { (*self.report_body).isv_prod_id } + } + + pub fn version(&self) -> sgx_isv_svn_t { + unsafe { (*self.report_body).isv_svn } + } + + pub fn report_data(&self) -> ReportData { + unsafe { (*self.report_body).report_data.into() } + } +} + +impl Debug for Quote { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("SGXQuote") + .field("mrenclave", &self.mrenclave()) + .field("mrsigner", &self.mrsigner()) + .field("report_body", &self.report_data()) + .field("product_id", &self.product_id()) + .field("version", &self.version()) + .field("family_id", &self.isv_family_id()) + .field("ext_prod_id", &self.isv_ext_prod_id()) + .field("config_id", &self.config_id()) + .finish() + } +} + +lazy_static! { + pub static ref IOCTL_CLIENT: Mutex = { + let client = IoctlClient::new(); + Mutex::new(client) + }; +} + +pub struct IoctlClient { + fd: HandleType, + quote_size: Option, + supplemental_size: Option, +} + +// Needed to numb the compiler +unsafe impl Send for IoctlClient {} + +impl IoctlClient { + fn new() -> Self { + Self { + fd: std::ptr::null_mut(), + quote_size: None, + supplemental_size: None, + } + } + + fn handle(&mut self) -> Result { + if self.fd.is_null() { + let handle = unsafe { dcap_quote_open() }; + if self.fd.is_null() { + return Err(RaTlsError::DcapError( + "Failed to open DCAP quote device".to_string(), + )); + } + self.fd = handle; + } + Ok(self.fd) + } + + fn get_quote_size(&mut self) -> Result { + if self.quote_size.is_none() { + let size = unsafe { dcap_get_quote_size(self.fd) }; + trace!("DCAP quote size is {}", size); + self.quote_size = Some(size); + } + + Ok(*self.quote_size.as_ref().unwrap()) + } + + fn get_supplemental_data_size(&mut self) -> Result { + if self.supplemental_size.is_none() { + let size = unsafe { dcap_get_supplemental_data_size(self.handle()?) }; + trace!("DCAP supplemental data size is {}", size); + self.quote_size = Some(size); + } + + Ok(*self.supplemental_size.as_ref().unwrap()) + } + + pub fn generate_quote(&mut self, report_data: ReportData) -> Result, RaTlsError> { + let instant = Instant::now(); + let quote_buf = self.generate_quote_inner(report_data)?; + trace!("Generated quote in {:?}ms", instant.elapsed().as_millis()); + Ok(quote_buf) + } + + fn generate_quote_inner(&mut self, report_data: ReportData) -> Result, RaTlsError> { + let quote_size = self.get_quote_size()?; + let mut quote_buf: Vec = vec![0; quote_size as usize]; + + let instant = Instant::now(); + let ret_code = unsafe { + dcap_generate_quote(self.handle()?, quote_buf.as_mut_ptr(), &report_data.into()) + }; + trace!("Generated quote in {:?}ms", instant.elapsed().as_millis()); + + if ret_code < 0 { + return Err(RaTlsError::DcapError( + "Failed to generate DCAP quote".to_string(), + )); + } + + Ok(quote_buf) + } + + pub fn verify_quote(&mut self, quote_buf: &[u8]) -> Result { + let instant = Instant::now(); + let result = self.verify_quote_inner(quote_buf)?; + trace!("Verified quote in {:?}ms", instant.elapsed().as_millis()); + + if result.is_negligible() { + if !result.is_ok() { + warn!("DCAP quote verification returned: {:?}", result); + } + return Ok(result); + } + + Err(RaTlsError::QuoteError(format!( + "DCAP quote verification returned: {:?}", + result + ))) + } + + fn verify_quote_inner(&mut self, quote_buf: &[u8]) -> Result { + let supplemental_data_size = self.get_supplemental_data_size()?; + + let mut status = 1; + let mut result = SGX_QL_QV_RESULT_UNSPECIFIED; + let mut suppl_buf: Vec = vec![0; supplemental_data_size as usize]; + + let ret_code = unsafe { + dcap_verify_quote( + self.handle()?, + quote_buf.as_ptr(), + quote_buf.len() as u32, + &mut status, + &mut result, + supplemental_data_size, + suppl_buf.as_mut_ptr(), + ) + }; + + if ret_code < 0 { + return Err(RaTlsError::DcapError( + "Failed to verify DCAP quote".to_string(), + )); + } + + Ok(result.into()) + } +} + +impl Drop for IoctlClient { + fn drop(&mut self) { + unsafe { + if !self.fd.is_null() { + dcap_quote_close(self.fd); + } + } + } +} + +type HandleType = *mut ::std::os::raw::c_void; +pub type ReportData = [u8; 64]; + +#[derive(Debug)] +pub enum VerifyResult { + Ok, + ConfigNeeded, + OutOfDate, + OutOfDateConfigNeeded, + InvalidSignature, + Revoked, + Unspecified, + SwHardeningNeeded, + ConfigAndSwHardeningNeeded, +} + +impl From for VerifyResult { + fn from(result: sgx_ql_qv_result_t) -> Self { + match result { + SGX_QL_QV_RESULT_OK => VerifyResult::Ok, + SGX_QL_QV_RESULT_CONFIG_NEEDED => VerifyResult::ConfigNeeded, + SGX_QL_QV_RESULT_OUT_OF_DATE => VerifyResult::OutOfDate, + SGX_QL_QV_RESULT_OUT_OF_DATE_CONFIG_NEEDED => VerifyResult::OutOfDateConfigNeeded, + SGX_QL_QV_RESULT_INVALID_SIGNATURE => VerifyResult::InvalidSignature, + SGX_QL_QV_RESULT_REVOKED => VerifyResult::Revoked, + SGX_QL_QV_RESULT_SW_HARDENING_NEEDED => VerifyResult::SwHardeningNeeded, + SGX_QL_QV_RESULT_CONFIG_AND_SW_HARDENING_NEEDED => { + VerifyResult::ConfigAndSwHardeningNeeded + } + //SGX_QL_QV_RESULT_UNSPECIFIED => QuoteVerifyResult::Unspecified, + _ => VerifyResult::Unspecified, + } + } +} + +impl VerifyResult { + pub fn is_ok(&self) -> bool { + match self { + VerifyResult::Ok => true, + _ => false, + } + } + + pub fn is_negligible(&self) -> bool { + match self { + VerifyResult::Ok => true, + VerifyResult::ConfigNeeded => true, + VerifyResult::OutOfDate => true, + VerifyResult::OutOfDateConfigNeeded => true, + VerifyResult::SwHardeningNeeded => true, + VerifyResult::ConfigAndSwHardeningNeeded => true, + _ => false, + } + } +} diff --git a/src/racert.rs b/src/racert.rs index 625a5be..284fb0a 100644 --- a/src/racert.rs +++ b/src/racert.rs @@ -6,7 +6,9 @@ use crate::{error::RaTlsError, RaTlsConfig}; use log::error; #[cfg(feature = "occlum")] -use occlum_sgx::SGXQuote; +use crate::quote::Quote; +//#[cfg(feature = "occlum")] +//use occlum_sgx::SGXQuote; use rcgen::{CertificateParams, CustomExtension, DistinguishedName, KeyPair}; use rustls::crypto::aws_lc_rs::sign::any_supported_type; use rustls::pki_types::{PrivateKeyDer, PrivatePkcs8KeyDer}; @@ -77,7 +79,7 @@ impl RaTlsCertificateBuilder { fn get_quote(&self, key_pair: &KeyPair) -> Result, Box> { let public_key = key_pair.public_key_raw().to_vec(); let report_data = hash_sha512(public_key); - let quote = SGXQuote::from_report_data(&report_data)?; + let quote = Quote::from_report_data(report_data.into())?; Ok(quote.as_slice().to_vec()) } @@ -123,7 +125,7 @@ impl RaTlsCertificate for CertificateDer<'_> { let report_oid = Oid::from(&REPORT_OID).unwrap(); if let Ok(Some(report)) = x509.get_extension_unique(&report_oid) { - let quote = SGXQuote::from_slice(report.value)?; + let quote = Quote::from_slice(report.value)?; // ECDSA quote verification using SGX DCAP driver quote.verify()?; @@ -134,7 +136,7 @@ impl RaTlsCertificate for CertificateDer<'_> { _ => return Err("Unexpected public key type".into()), }; - let report_data = &*quote.report_data(); + let report_data = quote.report_data(); if hash_sha512(public_key) != report_data { return Err("Invalid quote report data".into());